Skip to content

feat: add span customizers - #2489

Merged
Luca Forstner (lforst) merged 3 commits into
mainfrom
ark/SDK-362-span-hooks
Sep 23, 2026
Merged

Luca Forstner (lforst) merged 3 commits into
mainfrom
ark/SDK-362-span-hooks

Conversation

@realark

Copy link
Copy Markdown
Contributor

No description provided.

@realark
Andrew Kent (realark) force-pushed the ark/SDK-362-span-hooks branch 2 times, most recently from fe46755 to 0f02f1c Compare September 18, 2026 22:00
@realark Andrew Kent (realark) changed the title span hooks feat: add span export hooks Sep 18, 2026
@realark
Andrew Kent (realark) force-pushed the ark/SDK-362-span-hooks branch 2 times, most recently from 125ec72 to acd90fa Compare September 21, 2026 07:22
@realark
Andrew Kent (realark) marked this pull request as ready for review September 21, 2026 12:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-21T12:41:21.860032Z acd90fa Draft marked ready
ℹ️ About Codex in GitHub

Your 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.

@realark Andrew Kent (realark) changed the title feat: add span export hooks feat: add span customizers Sep 22, 2026
@realark
Andrew Kent (realark) force-pushed the ark/SDK-362-span-hooks branch 2 times, most recently from 9859aef to 453252f Compare September 22, 2026 18:14
@lforst
Luca Forstner (lforst) merged commit 7519017 into main Sep 23, 2026
57 checks passed
@lforst
Luca Forstner (lforst) deleted the ark/SDK-362-span-hooks branch September 23, 2026 15:21
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.
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.

2 participants