Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record links with empty span context #5308

Closed
MrAlias opened this issue May 7, 2024 · 1 comment · Fixed by #5315
Closed

Record links with empty span context #5308

MrAlias opened this issue May 7, 2024 · 1 comment · Fixed by #5315
Assignees
Labels
area:trace Part of OpenTelemetry tracing good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@MrAlias
Copy link
Contributor

MrAlias commented May 7, 2024

Links with invalid span context are now recommended to be recorded by the specification if they have non-empty attributes or trace state.

Implementations SHOULD record links containing SpanContext with empty TraceId or SpanId (all zeros) as long as either the attribute set or TraceState is non-empty.

Our implementation does not currently follow this behavior:

func (s *recordingSpan) AddLink(link trace.Link) {
if !s.IsRecording() || !link.SpanContext.IsValid() {
return
}
l := Link{SpanContext: link.SpanContext, Attributes: link.Attributes}
// Discard attributes over limit.
limit := s.tracer.provider.spanLimits.AttributePerLinkCountLimit
if limit == 0 {
// Drop all attributes.
l.DroppedAttributeCount = len(l.Attributes)
l.Attributes = nil
} else if limit > 0 && len(l.Attributes) > limit {
l.DroppedAttributeCount = len(l.Attributes) - limit
l.Attributes = l.Attributes[:limit]
}
s.mu.Lock()
s.links.add(l)
s.mu.Unlock()
}

The implementation needs to be updated and tests added to prevent regression.

@MrAlias MrAlias added the area:trace Part of OpenTelemetry tracing label May 7, 2024
@MrAlias MrAlias added this to the v1.27.0 milestone May 7, 2024
@MrAlias MrAlias added help wanted Extra attention is needed good first issue Good for newcomers labels May 7, 2024
@amanakin
Copy link
Contributor

amanakin commented May 8, 2024

Hi! I'd like to take that one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:trace Part of OpenTelemetry tracing good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants