Skip to content

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

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
Collaborator

AI Generated Description

Summary

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

  • Add extensible ISpanCustomizer.OnSpanExport and ordered configuration registration through BraintrustConfig.FromEnvironment(...) / Of(...).
  • Hooks transform detached OpenTelemetry.Proto.Trace.V1.Span messages, not application Activity instances.
  • Preserve IDs after each hook and across the full batch, support ordered replacement/redaction/routing, and fail closed before any transport send.
  • Preserve the existing exporter’s resource/scope metadata, auth, limits, and lifecycle. No customizers means no snapshot conversion overhead.

.NET representation decision

The upstream .NET OTel exporter accepts Activity, which cannot be safely cloned with identical IDs through public APIs. An optional HTTP handler decodes its OTLP batch, runs hooks, and reserializes before transmission. This adds a decode/encode pass only when configured. Vendored official opentelemetry-proto v1.5.0 schemas retain license headers and a pinned source reference; generated public types use Google.Protobuf and private build-time Grpc.Tools. Upstream retries can invoke hooks again; this is documented.

Verification

  • Customizer transport suite: 10 passed, including real upstream OtlpTraceExporter serialization and no-send failures.
  • Full core test project: 197 passed.
  • Release build of the entire solution succeeded.
  • dotnet format Braintrust.Sdk.sln --verify-no-changes --no-restore passed.
  • Standalone public API smoke with a real local HTTP receiver: redaction, preserved span identity, and unchanged application Activity.

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