Skip to content

Commit

Permalink
feat(tracing): inject comp ID as instru scope attr
Browse files Browse the repository at this point in the history
Signed-off-by: hainenber <[email protected]>
  • Loading branch information
hainenber committed Oct 7, 2023
1 parent 2ed7500 commit 6f30a7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ v0.37.0-rc.1 (2023-10-06)
- 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)
Expand Down
8 changes: 8 additions & 0 deletions pkg/flow/tracing/wrap_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package tracing

import (
"context"
"path/filepath"
"strings"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6f30a7d

Please sign in to comment.