Skip to content

Commit 715467c

Browse files
authored
Merge pull request #6569 from jsternberg/otel-sdk-lock-version
telemetry: lock the semconv version of the otel sdk
2 parents dafbfc2 + 153f7f1 commit 715467c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

cli/command/telemetry.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/google/uuid"
1212
"go.opentelemetry.io/otel"
1313
"go.opentelemetry.io/otel/metric"
14+
otelsdk "go.opentelemetry.io/otel/sdk"
1415
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
1516
"go.opentelemetry.io/otel/sdk/metric/metricdata"
1617
"go.opentelemetry.io/otel/sdk/resource"
@@ -146,7 +147,7 @@ func defaultResourceOptions() []resource.Option {
146147
semconv.ServiceInstanceID(uuid.NewString()),
147148
),
148149
resource.WithFromEnv(),
149-
resource.WithTelemetrySDK(),
150+
resource.WithDetectors(telemetrySDK{}),
150151
}
151152
}
152153

@@ -157,7 +158,10 @@ func (r *telemetryResource) AppendOptions(opts ...resource.Option) {
157158
r.opts = append(r.opts, opts...)
158159
}
159160

160-
type serviceNameDetector struct{}
161+
type (
162+
serviceNameDetector struct{}
163+
telemetrySDK struct{}
164+
)
161165

162166
func (serviceNameDetector) Detect(ctx context.Context) (*resource.Resource, error) {
163167
return resource.StringDetector(
@@ -169,6 +173,16 @@ func (serviceNameDetector) Detect(ctx context.Context) (*resource.Resource, erro
169173
).Detect(ctx)
170174
}
171175

176+
// Detect returns a *Resource that describes the OpenTelemetry SDK used.
177+
func (telemetrySDK) Detect(context.Context) (*resource.Resource, error) {
178+
return resource.NewWithAttributes(
179+
semconv.SchemaURL,
180+
semconv.TelemetrySDKName("opentelemetry"),
181+
semconv.TelemetrySDKLanguageGo,
182+
semconv.TelemetrySDKVersion(otelsdk.Version()),
183+
), nil
184+
}
185+
172186
// cliReader is an implementation of Reader that will automatically
173187
// report to a designated Exporter when Shutdown is called.
174188
type cliReader struct {

0 commit comments

Comments
 (0)