Skip to content

Unify dropping approach on over limited span #1708

@XSAM

Description

@XSAM

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.

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.

// 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]
}

// 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions