feat: add span customizers - #2489
Merged
Merged
Conversation
Andrew Kent (realark)
force-pushed
the
ark/SDK-362-span-hooks
branch
2 times, most recently
from
September 18, 2026 22:00
fe46755 to
0f02f1c
Compare
Andrew Kent (realark)
force-pushed
the
ark/SDK-362-span-hooks
branch
2 times, most recently
from
September 21, 2026 07:22
125ec72 to
acd90fa
Compare
Andrew Kent (realark)
requested review from
Abhijeet Prasad (AbhiPrasad) and
Luca Forstner (lforst)
September 21, 2026 12:34
Andrew Kent (realark)
marked this pull request as ready for review
September 21, 2026 12:34
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Andrew Kent (realark)
force-pushed
the
ark/SDK-362-span-hooks
branch
from
September 21, 2026 17:07
acd90fa to
848630b
Compare
Andrew Kent (realark)
force-pushed
the
ark/SDK-362-span-hooks
branch
2 times, most recently
from
September 22, 2026 18:14
9859aef to
453252f
Compare
Andrew Kent (realark)
force-pushed
the
ark/SDK-362-span-hooks
branch
from
September 22, 2026 18:15
453252f to
e85b4ab
Compare
Luca Forstner (lforst)
approved these changes
Sep 23, 2026
Andrew Kent (realark)
added a commit
to braintrustdata/braintrust-sdk-python
that referenced
this pull request
Sep 23, 2026
- support span customizers: https://github.com/braintrustdata/braintrust-spec/blob/main/skills/instrumentation-spec/references/features/span-customizers.md - re-implement masking function with span customizer # AI Generated Description ## Summary Implements SDK-316 using the [span customizer specification](https://github.com/braintrustdata/braintrust-spec/blob/main/skills/instrumentation-spec/references/features/span-customizers.md) and the [JavaScript reference](braintrustdata/braintrust-sdk-javascript#2489). - 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.