Skip to content

Commit 250a11e

Browse files
authored
Add experimental x package to otlptracegrpc (#7401)
Part of #7007 - Generate the base `x` package content - Add a README.md describing the observability feature - Add the observability feature
1 parent 466f0cd commit 250a11e

File tree

6 files changed

+215
-0
lines changed

6 files changed

+215
-0
lines changed

exporters/otlp/otlptrace/otlptracegrpc/internal/gen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/ot
2323
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/collector.go.tmpl "--data={}" --out=otlptracetest/collector.go
2424
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/data.go.tmpl "--data={}" --out=otlptracetest/data.go
2525
//go:generate gotmpl --body=../../../../../internal/shared/otlp/otlptrace/otlptracetest/otlptest.go.tmpl "--data={}" --out=otlptracetest/otlptest.go
26+
27+
//go:generate gotmpl --body=../../../../../internal/shared/x/x.go.tmpl "--data={ \"pkg\": \"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc\" }" --out=x/x.go
28+
//go:generate gotmpl --body=../../../../../internal/shared/x/x_test.go.tmpl "--data={}" --out=x/x_test.go
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Experimental Features
2+
3+
The `otlptracegrpc` exporter contains features that have not yet stabilized in the OpenTelemetry specification.
4+
These features are added to the `otlptracegrpc` exporter prior to stabilization in the specification so that users can start experimenting with them and provide feedback.
5+
6+
These feature may change in backwards incompatible ways as feedback is applied.
7+
See the [Compatibility and Stability](#compatibility-and-stability) section for more information.
8+
9+
## Features
10+
11+
- [Observability](#observability)
12+
13+
### Observability
14+
15+
The `otlptracegrpc` exporter provides a observability feature that allows you to monitor the SDK itself.
16+
17+
To opt-in, set the environment variable `OTEL_GO_X_OBSERVABILITY` to `true`.
18+
19+
When enabled, the SDK will create the following metrics using the global `MeterProvider`:
20+
21+
- `otel.sdk.exporter.span.inflight`
22+
- `otel.sdk.exporter.span.exported`
23+
- `otel.sdk.exporter.operation.duration`
24+
25+
Please see the [Semantic conventions for OpenTelemetry SDK metrics] documentation for more details on these metrics.
26+
27+
[Semantic conventions for OpenTelemetry SDK metrics]: https://github.com/open-telemetry/semantic-conventions/blob/v1.37.0/docs/otel/sdk-metrics.md
28+
29+
## Compatibility and Stability
30+
31+
Experimental features do not fall within the scope of the OpenTelemetry Go versioning and stability [policy](../../../../../../VERSIONING.md).
32+
These features may be removed or modified in successive version releases, including patch versions.
33+
34+
When an experimental feature is promoted to a stable feature, a migration path will be included in the changelog entry of the release.
35+
There is no guarantee that any environment variable feature flags that enabled the experimental feature will be supported by the stable version.
36+
If they are supported, they may be accompanied with a deprecation notice stating a timeline for the removal of that support.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package x // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/x"
5+
6+
import "strings"
7+
8+
// Observability is an experimental feature flag that determines if exporter
9+
// observability metrics are enabled.
10+
//
11+
// To enable this feature set the OTEL_GO_X_OBSERVABILITY environment variable
12+
// to the case-insensitive string value of "true" (i.e. "True" and "TRUE"
13+
// will also enable this).
14+
var Observability = newFeature(
15+
[]string{"OBSERVABILITY"},
16+
func(v string) (string, bool) {
17+
if strings.EqualFold(v, "true") {
18+
return v, true
19+
}
20+
return "", false
21+
},
22+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package x
5+
6+
import (
7+
"testing"
8+
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
func TestObservability(t *testing.T) {
13+
const key = "OTEL_GO_X_OBSERVABILITY"
14+
require.Contains(t, Observability.Keys(), key)
15+
16+
t.Run("100", run(setenv(key, "100"), assertDisabled(Observability)))
17+
t.Run("true", run(setenv(key, "true"), assertEnabled(Observability, "true")))
18+
t.Run("True", run(setenv(key, "True"), assertEnabled(Observability, "True")))
19+
t.Run("false", run(setenv(key, "false"), assertDisabled(Observability)))
20+
t.Run("empty", run(assertDisabled(Observability)))
21+
}

exporters/otlp/otlptrace/otlptracegrpc/internal/x/x.go

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exporters/otlp/otlptrace/otlptracegrpc/internal/x/x_test.go

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)