Skip to content

feat: add span customizers (SDK-316) - #217

Draft
Andrew Kent (realark) wants to merge 1 commit into
mainfrom
ark/SDK-316-span-customizers
Draft

Andrew Kent (realark) wants to merge 1 commit into
mainfrom
ark/SDK-316-span-customizers

Conversation

@realark

@realark Andrew Kent (realark) commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

AI Generated Description

Summary

Implements SDK-316 using the span customizer specification and the Java exporter reference.

  • Add Braintrust::SpanCustomizer#on_span_export and ordered span_customizers: registration through init/config/exporter APIs.
  • Customize detached completed OpenTelemetry SpanData after origin enrichment, before destination grouping and OTLP serialization.
  • Allow mutations/replacements/rerouting while preserving trace, span, and parent IDs and isolating original application/exporter data.
  • Fail the entire batch before any transmission on hook, identity, return-type, or serialization errors; no fallback to unredacted spans.
  • Keep the no-customizer path unchanged and document configuration, concurrency, retry, and failure semantics.

Verification

  • Customizer/exporter/origin/config/state/tracing regression selection: 76 tests, 183 assertions, zero failures/errors/skips.
  • Standalone real local HTTP/OTLP smoke: redaction with preserved span identity and unchanged application data.
  • Changed-file Standard lint and repository precommit passed.

Tradeoffs

Configured customization deep-copies SDK SpanData and buffers encoded destination groups before sending, providing fail-closed batch behavior. Transport retries reuse encoded bytes; an explicit export resubmission reruns hooks. Arbitrary non-marshallable state added to SpanData subclasses fails closed.

@realark

Copy link
Copy Markdown
Contributor Author

CI triage: this failure is reproducible on unmodified main, independently of span customizers.

The PR CI job completed its preceding appraisal suites, including customizer cases, before stopping at this unrelated RubyLLM upgrade. Other matrix jobs were fail-fast cancelled. No test skips, weakened cassette matchers, or dependency downgrades were introduced to hide this failure. RubyLLM 2.0 compatibility needs a separate integration update; this span-customizer PR is still blocked by that baseline issue.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant