diff --git a/CHANGELOG.md b/CHANGELOG.md index ee6f198c435d..9b44e14e5a5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -204,6 +204,8 @@ v0.37.0 (2023-10-10) - Fix initialization of the RAPL collector for the node_exporter integration and the prometheus.exporter.unix component. (@marctc) +- Set instrumentation scope attribute for traces emitted by Flow component. (@hainenber) + ### Other changes - Use Go 1.21.1 for builds. (@rfratto) diff --git a/pkg/flow/tracing/wrap_tracer.go b/pkg/flow/tracing/wrap_tracer.go index 9ffb5e7b4d38..197e7ce3200b 100644 --- a/pkg/flow/tracing/wrap_tracer.go +++ b/pkg/flow/tracing/wrap_tracer.go @@ -2,6 +2,8 @@ package tracing import ( "context" + "path/filepath" + "strings" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -41,6 +43,12 @@ type wrappedProvider struct { var _ trace.TracerProvider = (*wrappedProvider)(nil) func (wp *wrappedProvider) Tracer(name string, options ...trace.TracerOption) trace.Tracer { + // Inject the component name as instrumentation scope attribute. + // This would not have component's exact ID, aligning with OTEL's definition + if wp.id != "" { + otelComponentName := strings.TrimSuffix(wp.id, filepath.Ext(wp.id)) + options = append(options, trace.WithInstrumentationAttributes(attribute.String(wp.spanName, otelComponentName))) + } innerTracer := wp.inner.Tracer(name, options...) return &wrappedTracer{ inner: innerTracer,