Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new metric process.runtime.uptime and deprecate runtime.uptime metric in instrumentation/runtime/runtime.go file #5317

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Added

- Add the new `go.opentelemetry.io/contrib/instrgen` package to provide auto-generated source code instrumentation. (#3068, #3108)
- Add a new metric `process.runtime.uptime` that uses an asynchronous gauge function (#5293, #5294)
AkhigbeEromo marked this conversation as resolved.
Show resolved Hide resolved

### Deprecated

- The `runtime.uptime` metric in `instrumentation/runtime/runtime.go` is deprecated(#5293, #5294)
AkhigbeEromo marked this conversation as resolved.
Show resolved Hide resolved

### Removed

Expand Down
12 changes: 12 additions & 0 deletions instrumentation/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@

func (r *runtime) register() error {
startTime := time.Now()
// DEPRECATED: This metric is deprecated in favor of processUptime
dmathieu marked this conversation as resolved.
Show resolved Hide resolved
uptime, err := r.meter.Int64ObservableCounter(
"runtime.uptime",
metric.WithUnit("ms"),
Expand All @@ -117,6 +118,15 @@
return err
}

processUptime, err := r.meter.Int64ObservableGauge(
"process.runtime.uptime",
metric.WithUnit("ms"),
metric.WithDescription("Milliseconds since application was initialized"),
)
if err != nil {
return err

Check warning on line 127 in instrumentation/runtime/runtime.go

View check run for this annotation

Codecov / codecov/patch

instrumentation/runtime/runtime.go#L121-L127

Added lines #L121 - L127 were not covered by tests
}

goroutines, err := r.meter.Int64ObservableUpDownCounter(
"process.runtime.go.goroutines",
metric.WithDescription("Number of goroutines that currently exist"),
Expand All @@ -136,10 +146,12 @@
_, err = r.meter.RegisterCallback(
func(ctx context.Context, o metric.Observer) error {
o.ObserveInt64(uptime, time.Since(startTime).Milliseconds())
o.ObserveInt64(processUptime, time.Since(startTime).Milliseconds())

Check warning on line 149 in instrumentation/runtime/runtime.go

View check run for this annotation

Codecov / codecov/patch

instrumentation/runtime/runtime.go#L149

Added line #L149 was not covered by tests
o.ObserveInt64(goroutines, int64(goruntime.NumGoroutine()))
o.ObserveInt64(cgoCalls, goruntime.NumCgoCall())
return nil
},
processUptime,
uptime,
goroutines,
cgoCalls,
Expand Down