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

add process prefix to runtime go metrics #1549

Merged
merged 3 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Changed

- All metric instruments from the `go.opentelemetry.io/contrib/instrumentation/runtime` package have been renamed from `runtime.go.*` to `process.runtime.go.*` so as to comply with OpenTelemetry semantic conventions. (#1549)

### Fixed

- Change the `http-server-duration` instrument in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` to record milliseconds instead of microseconds match what is specified in the OpenTelemetry specification. (#1414, #1537)
Expand Down
26 changes: 13 additions & 13 deletions instrumentation/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (r *runtime) register() error {
}

if _, err := r.meter.NewInt64UpDownCounterObserver(
"runtime.go.goroutines",
"process.runtime.go.goroutines",
func(_ context.Context, result metric.Int64ObserverResult) {
result.Observe(int64(goruntime.NumGoroutine()))
},
Expand All @@ -139,7 +139,7 @@ func (r *runtime) register() error {
}

if _, err := r.meter.NewInt64CounterObserver(
"runtime.go.cgo.calls",
"process.runtime.go.cgo.calls",
func(_ context.Context, result metric.Int64ObserverResult) {
result.Observe(goruntime.NumCgoCall())
},
Expand Down Expand Up @@ -212,31 +212,31 @@ func (r *runtime) registerMemStats() error {
})

if heapAlloc, err = batchObserver.NewInt64UpDownCounterObserver(
"runtime.go.mem.heap_alloc",
"process.runtime.go.mem.heap_alloc",
metric.WithUnit(unit.Bytes),
metric.WithDescription("Bytes of allocated heap objects"),
); err != nil {
return err
}

if heapIdle, err = batchObserver.NewInt64UpDownCounterObserver(
"runtime.go.mem.heap_idle",
"process.runtime.go.mem.heap_idle",
metric.WithUnit(unit.Bytes),
metric.WithDescription("Bytes in idle (unused) spans"),
); err != nil {
return err
}

if heapInuse, err = batchObserver.NewInt64UpDownCounterObserver(
"runtime.go.mem.heap_inuse",
"process.runtime.go.mem.heap_inuse",
metric.WithUnit(unit.Bytes),
metric.WithDescription("Bytes in in-use spans"),
); err != nil {
return err
}

if heapObjects, err = batchObserver.NewInt64UpDownCounterObserver(
"runtime.go.mem.heap_objects",
"process.runtime.go.mem.heap_objects",
metric.WithDescription("Number of allocated heap objects"),
); err != nil {
return err
Expand All @@ -245,37 +245,37 @@ func (r *runtime) registerMemStats() error {
// FYI see https://github.com/golang/go/issues/32284 to help
// understand the meaning of this value.
if heapReleased, err = batchObserver.NewInt64UpDownCounterObserver(
"runtime.go.mem.heap_released",
"process.runtime.go.mem.heap_released",
metric.WithUnit(unit.Bytes),
metric.WithDescription("Bytes of idle spans whose physical memory has been returned to the OS"),
); err != nil {
return err
}

if heapSys, err = batchObserver.NewInt64UpDownCounterObserver(
"runtime.go.mem.heap_sys",
"process.runtime.go.mem.heap_sys",
metric.WithUnit(unit.Bytes),
metric.WithDescription("Bytes of heap memory obtained from the OS"),
); err != nil {
return err
}

if ptrLookups, err = batchObserver.NewInt64CounterObserver(
"runtime.go.mem.lookups",
"process.runtime.go.mem.lookups",
metric.WithDescription("Number of pointer lookups performed by the runtime"),
); err != nil {
return err
}

if liveObjects, err = batchObserver.NewInt64UpDownCounterObserver(
"runtime.go.mem.live_objects",
"process.runtime.go.mem.live_objects",
metric.WithDescription("Number of live objects is the number of cumulative Mallocs - Frees"),
); err != nil {
return err
}

if gcCount, err = batchObserver.NewInt64CounterObserver(
"runtime.go.gc.count",
"process.runtime.go.gc.count",
metric.WithDescription("Number of completed garbage collection cycles"),
); err != nil {
return err
Expand All @@ -285,15 +285,15 @@ func (r *runtime) registerMemStats() error {
// individual pauses, but we may lose individual pauses if the
// observation interval is too slow.
if pauseTotalNs, err = batchObserver.NewInt64CounterObserver(
"runtime.go.gc.pause_total_ns",
"process.runtime.go.gc.pause_total_ns",
// TODO: nanoseconds units
metric.WithDescription("Cumulative nanoseconds in GC stop-the-world pauses since the program started"),
); err != nil {
return err
}

if gcPauseNs, err = r.meter.NewInt64Histogram(
"runtime.go.gc.pause_ns",
"process.runtime.go.gc.pause_ns",
// TODO: nanoseconds units
metric.WithDescription("Amount of nanoseconds in GC stop-the-world pauses"),
); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func TestRuntime(t *testing.T) {
func getGCCount(provider *metrictest.MeterProvider) int {
for _, b := range provider.MeasurementBatches {
for _, m := range b.Measurements {
if m.Instrument.Descriptor().Name() == "runtime.go.gc.count" {
if m.Instrument.Descriptor().Name() == "process.runtime.go.gc.count" {
return int(m.Number.CoerceToInt64(m.Instrument.Descriptor().NumberKind()))
}
}
}
panic("Could not locate a runtime.go.gc.count metric in test output")
panic("Could not locate a process.runtime.go.gc.count metric in test output")
}

func testMinimumInterval(t *testing.T, shouldHappen bool, opts ...runtime.Option) {
Expand Down