-
Couldn't load subscription status.
- Fork 1.2k
Description
The SDK will discard attributes, links and events if they beyond the configured limit, but we have different approaches in SDK.
It drops the oldest attributes, links and events.
opentelemetry-go/sdk/trace/span.go
Lines 545 to 547 in 0fe65e6
| span.attributes = newAttributesMap(cfg.SpanLimits.AttributeCountLimit) | |
| span.messageEvents = newEvictedQueue(cfg.SpanLimits.EventCountLimit) | |
| span.links = newEvictedQueue(cfg.SpanLimits.LinkCountLimit) |
But drop the newest attributes in events and links.
opentelemetry-go/sdk/trace/span.go
Lines 303 to 307 in 0fe65e6
| // Discard over limited attributes | |
| if len(c.Attributes) > s.spanLimits.AttributePerEventCountLimit { | |
| s.addDroppedAttributeCount(len(c.Attributes) - s.spanLimits.AttributePerEventCountLimit) | |
| c.Attributes = c.Attributes[:s.spanLimits.AttributePerEventCountLimit] | |
| } |
opentelemetry-go/sdk/trace/span.go
Lines 433 to 437 in 0fe65e6
| // Discard over limited attributes | |
| if len(link.Attributes) > s.spanLimits.AttributePerLinkCountLimit { | |
| s.addDroppedAttributeCount(len(link.Attributes) - s.spanLimits.AttributePerLinkCountLimit) | |
| link.Attributes = link.Attributes[:s.spanLimits.AttributePerLinkCountLimit] | |
| } |
Though the specification does not describe how to discard over limited data on span, I think we need to unify our dropping approach at least to prevent "random drop".
I slightly prefer this comment, which suggests we should drop the newest data.