Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

appender-tracing: configurable collision policy for span-attribute enrichment #3498

Copy link
Copy link
@cijothomas

Description

@cijothomas
Issue body actions

Context

PR #3482 stabilized tracing-span attribute enrichment in opentelemetry-appender-tracing. With enrichment enabled, attributes from active tracing::span!s are copied onto each emitted log record alongside the event's own fields.

This raises the probability of duplicate attribute keys in a single log record:

  • A key set on a tracing::span! can collide with a field on the inner tracing::event!.
  • The same key on a parent and a child span will both be copied.

Today the appender appends in deterministic order (root → leaf → event) and relies on the SDK to handle duplicates. The SDK does not do this either today (tracked in #3497).

Proposal

Independently of the SDK-level fix, give the appender a configuration knob to control collision behavior on the enrichment path specifically — for users who want guaranteed-unique keys without paying the dedup cost on every other code path.

Strawman:

pub enum SpanAttributeCollisionPolicy {
    /// Append in root → leaf → event order; let the SDK handle dedup. (default)
    AppendInOrder,
    /// Last-write-wins: event > leaf > root.
    LastWins,
}

OpenTelemetryTracingBridge::builder(&provider)
    .with_span_attributes(SpanAttributes::all())
    .with_span_attribute_collision_policy(SpanAttributeCollisionPolicy::LastWins)
    .build();

Open questions:

Refs

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.