Skip to content

Commit

Permalink
Only set trace attributes if they exists
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Nov 9, 2024
1 parent df2e1ed commit bad8fa3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/pkg/opentelemetry/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ func (c *Controller) Trace(ss ptrace.ScopeSpans) {
kvs []attribute.KeyValue
)

tracer := c.tracerProvider.Tracer(
ss.Scope().Name(),
to := []trace.TracerOption{
trace.WithInstrumentationVersion(ss.Scope().Version()),
trace.WithInstrumentationAttributes(attrs(ss.Scope().Attributes())...),
trace.WithSchemaURL(ss.SchemaUrl()),
)
}

if m := ss.Scope().Attributes(); m.Len() > 0 {
to = append(to, trace.WithInstrumentationAttributes(attrs(m)...))
}

tracer := c.tracerProvider.Tracer(ss.Scope().Name(), to...)
for k := 0; k < ss.Spans().Len(); k++ {
pSpan := ss.Spans().At(k)

Expand Down

0 comments on commit bad8fa3

Please sign in to comment.