Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Changed

- `go.opentelemetry.io/contrib/instrumentation/runtime` now produces the new metrics by default. Set `OTEL_GO_X_DEPRECATED_RUNTIME_METRICS=true` environment variable to additionally produce the deprecated metrics. (#7418)
Comment thread
dashpole marked this conversation as resolved.
- The semantic conventions have been upgraded from `v1.30.0` to `v1.32.0` in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#7361)
- The semantic conventions have been upgraded from `v1.26.0` to `v1.32.0` in `go.opentelemetry.io/contrib/detectors/aws/ec2`. (#7373)
- The semantic conventions have been upgraded from `v1.26.0` to `v1.32.0` in `go.opentelemetry.io/contrib/detectors/aws/eks`. (#7375)
Expand Down
24 changes: 12 additions & 12 deletions instrumentation/runtime/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
//
// The metric events produced are:
//
// go.memory.used By Memory used by the Go runtime.
// go.memory.limit By Go runtime memory limit configured by the user, if a limit exists.
// go.memory.allocated By Memory allocated to the heap by the application.
// go.memory.allocations {allocation} Count of allocations to the heap by the application.
// go.memory.gc.goal By Heap size target for the end of the GC cycle.
// go.goroutine.count {goroutine} Count of live goroutines.
// go.processor.limit {thread} The number of OS threads that can execute user-level Go code simultaneously.
// go.config.gogc % Heap size target percentage configured by the user, otherwise 100.
//
// When the OTEL_GO_X_DEPRECATED_RUNTIME_METRICS environment variable is set to
// true, the following deprecated metrics are produced:
//
// runtime.go.cgo.calls - Number of cgo calls made by the current process
// runtime.go.gc.count - Number of completed garbage collection cycles
// runtime.go.gc.pause_ns (ns) Amount of nanoseconds in GC stop-the-world pauses
Expand All @@ -19,16 +31,4 @@
// runtime.go.mem.heap_sys (bytes) Bytes of heap memory obtained from the OS
// runtime.go.mem.live_objects - Number of live objects is the number of cumulative Mallocs - Frees
// runtime.uptime (ms) Milliseconds since application was initialized
//
// When the OTEL_GO_X_DEPRECATED_RUNTIME_METRICS environment variable is set to
// false, the metrics produced are:
//
// go.memory.used By Memory used by the Go runtime.
// go.memory.limit By Go runtime memory limit configured by the user, if a limit exists.
// go.memory.allocated By Memory allocated to the heap by the application.
// go.memory.allocations {allocation} Count of allocations to the heap by the application.
// go.memory.gc.goal By Heap size target for the end of the GC cycle.
// go.goroutine.count {goroutine} Count of live goroutines.
// go.processor.limit {thread} The number of OS threads that can execute user-level Go code simultaneously.
// go.config.gogc % Heap size target percentage configured by the user, otherwise 100.
package runtime // import "go.opentelemetry.io/contrib/instrumentation/runtime"
13 changes: 2 additions & 11 deletions instrumentation/runtime/internal/x/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,13 @@ change in backwards incompatible ways as feedback is applied.

### Include Deprecated Metrics

Once new experimental runtime metrics are added, they will be produced
**in addition to** the existing runtime metrics. Users that migrate right away
can disable the old runtime metrics:

```console
export OTEL_GO_X_DEPRECATED_RUNTIME_METRICS=false
```

In a later release, the deprecated runtime metrics will stop being produced by
default. To temporarily re-enable the deprecated metrics:
To temporarily re-enable the deprecated metrics:

```console
export OTEL_GO_X_DEPRECATED_RUNTIME_METRICS=true
```

After two additional releases, the deprecated runtime metrics will be removed,
Eventually, the deprecated runtime metrics will be removed,
and setting the environment variable will no longer have any effect.

The value set must be the case-insensitive string of `"true"` to enable the
Expand Down
20 changes: 10 additions & 10 deletions instrumentation/runtime/internal/x/x.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ package x // import "go.opentelemetry.io/contrib/instrumentation/runtime/interna

import (
"os"
"strings"
"strconv"
)

// DeprecatedRuntimeMetrics is an experimental feature flag that defines if the deprecated
// runtime metrics should be produced. During development of the new
// conventions, it is enabled by default.
//
// To disable this feature set the OTEL_GO_X_DEPRECATED_RUNTIME_METRICS environment variable
// to the case-insensitive string value of "false" (i.e. "False" and "FALSE"
// To enable this feature set the OTEL_GO_X_DEPRECATED_RUNTIME_METRICS environment variable
// to the case-insensitive string value of "true" (i.e. "True" and "TRUE"
// will also enable this).
var DeprecatedRuntimeMetrics = newFeature("DEPRECATED_RUNTIME_METRICS", true)
var DeprecatedRuntimeMetrics = newFeature("DEPRECATED_RUNTIME_METRICS", false)

// BoolFeature is an experimental feature control flag. It provides a uniform way
// to interact with these feature flags and parse their values.
Expand All @@ -43,11 +43,11 @@ func (f BoolFeature) Key() string { return f.key }
// Enabled returns if the feature is enabled.
func (f BoolFeature) Enabled() bool {
v := os.Getenv(f.key)
if strings.ToLower(v) == "false" {
return false
}
if strings.ToLower(v) == "true" {
return true

val, err := strconv.ParseBool(v)
if err != nil {
return f.defaultVal
}
return f.defaultVal

return val
}
2 changes: 1 addition & 1 deletion instrumentation/runtime/internal/x/x_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestDeprecatedRuntimeMetrics(t *testing.T) {
t.Run("False", run(setenv(key, "False"), assertEnabled(DeprecatedRuntimeMetrics, false)))
t.Run("FALSE", run(setenv(key, "FALSE"), assertEnabled(DeprecatedRuntimeMetrics, false)))
t.Run("1", run(setenv(key, "1"), assertEnabled(DeprecatedRuntimeMetrics, true)))
t.Run("empty", run(assertEnabled(DeprecatedRuntimeMetrics, true)))
t.Run("empty", run(assertEnabled(DeprecatedRuntimeMetrics, false)))
}

func run(steps ...func(*testing.T)) func(*testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion instrumentation/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
metric.WithInstrumentationVersion(Version()),
)
if x.DeprecatedRuntimeMetrics.Enabled() {
return deprecatedruntime.Start(meter, c.MinimumReadMemStatsInterval)
if err := deprecatedruntime.Start(meter, c.MinimumReadMemStatsInterval); err != nil {
return err
}

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

View check run for this annotation

Codecov / codecov/patch

instrumentation/runtime/runtime.go#L47-L49

Added lines #L47 - L49 were not covered by tests
}
memoryUsed, err := goconv.NewMemoryUsed(meter)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion instrumentation/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func TestRuntimeWithLimit(t *testing.T) {
// buffer for allocating memory
var buffer [][]byte
_ = allocateMemory(buffer)
t.Setenv("OTEL_GO_X_DEPRECATED_RUNTIME_METRICS", "false")
debug.SetMemoryLimit(1234567890)
// reset to default
defer debug.SetMemoryLimit(math.MaxInt64)
Expand Down
Loading