Skip to content

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

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

Andrew Kent (realark) wants to merge 2 commits 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 JavaScript reference.

  • Add SpanCustomizer.on_span_export, SpanExportData, set_span_customizers, and auto_instrument(span_customizers=...).
  • Customize native instrumentation records after lazy resolution, before merging, masking, attachments, and serialization. Manual spans, datasets, feedback, and separate OTel exporters remain outside the scope.
  • Preserve identity/routing/merge fields, ordered replacements, immutable registration snapshots, fail-open continuation, and transformed-record reuse on retries.
  • Mark previously unmarked Pipecat and legacy LangChain instrumentation spans; document lifecycle and fail-open redaction risks.

Verification

  • Dedicated customizer suite: 10 passed.
  • Isolated core suite: 863 passed, 64 skipped, 12 xfailed.
  • test_types: pyright/mypy clean, 35 runtime tests passed.
  • Pipecat customizer regression passed on 1.3.0 and latest (1.10.0).
  • Standalone SDK smoke: incremental input/output redaction, stable span identity, manual-span exclusion.
  • Changed-file pre-commit checks passed.

The core suite required clearing local Braintrust endpoint environment overrides to match recorded cassettes. It exits successfully but prints an atexit closed-output-stream warning. No cassettes were changed.

Contract note

Like JavaScript, failures are fail open. Throwing is not a safe way to block export; the API docs state this explicitly.

@realark

Andrew Kent (realark) commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the CI regression in 5111069. The Discovery Engine subprocess test treated every auto_instrument parameter as a boolean flag, passing span_customizers=False. It now disables only parameters whose defaults are boolean, leaving the new list-valued option at its default.

Verification:

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