Skip to content

Commit 5a888fc

Browse files
committed
add OTEL_GO_X_SELF_OBSERVABILITY feature gate
1 parent e2aee3a commit 5a888fc

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

sdk/internal/x/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ All other values are ignored.
2222
[OpenTelemetry resource semantic conventions]: https://opentelemetry.io/docs/specs/semconv/resource/
2323
[resource detectors]: https://pkg.go.dev/go.opentelemetry.io/otel/sdk/resource#Detector
2424

25+
### SDK Self-Observability
26+
27+
To enable experimental metric and trace instrumentation in SDKs, set the `OTEL_GO_X_SELF_OBSERVABILITY` environment variable.
28+
If enabled, this instrumentation uses the global `TracerProvider` and `MeterProvider`.
29+
The value set must be the case-insensitive string of `"true"` to enable the feature.
30+
All other values are ignored.
31+
2532
#### Examples
2633

2734
Enable experimental resource semantic conventions.

sdk/internal/x/x.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ var Resource = newFeature("RESOURCE", func(v string) (string, bool) {
2525
return "", false
2626
})
2727

28+
// SelfObservability is an experimental feature flag that determines if SDK
29+
// self-observability metrics are enabled.
30+
//
31+
// To enable this feature set the OTEL_GO_X_SELF_OBSERVABILITY environment variable
32+
// to the case-insensitive string value of "true" (i.e. "True" and "TRUE"
33+
// will also enable this).
34+
var SelfObservability = newFeature("SELF_OBSERVABILITY", func(v string) (string, bool) {
35+
if strings.ToLower(v) == "true" {
36+
return v, true
37+
}
38+
return "", false
39+
})
40+
2841
// Feature is an experimental feature control flag. It provides a uniform way
2942
// to interact with these feature flags and parse their values.
3043
type Feature[T any] struct {

0 commit comments

Comments
 (0)