Skip to content

Stabilize span attributes customization: builder API shape #3481

@cijothomas

Description

@cijothomas

Context

The experimental_span_attributes feature in opentelemetry-appender-tracing
is ready to be stabilized. Today its only API is:

.with_span_attribute_allowlist(["session.id"])  // requires cargo feature

When we drop the cargo feature, we also need a way to enable the
behavior at runtime — not every user wants to pay per-span overhead.

Two builder shapes under consideration. Pick one.


Option A — two methods, allowlist implies enable

.with_span_attributes(true)                       // enable, copy all
.with_span_attribute_allowlist(["session.id"])    // implies enable + filter
  • Two methods; subtle interaction if both called.
  • bool argument enables conditional config: b.with_span_attributes(cfg.enable).

Option B — one method, allowlist semantics

.with_span_attributes([])                         // enable, copy all
.with_span_attributes(["session.id"])             // enable, allowlist
// (not called)                                   // disabled
  • Single method, no boolean trap.
  • Empty iterator = "enable all" sentinel — slight cognitive load.
  • Conditional enable requires if cfg.enable { b = b.with_span_attributes(...) }.

In both options:

  • Default is disabled (no per-span work).
  • Last call wins if invoked twice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions