Automatic tracing of typesafe-sdk-go with braintrust-sdk-go
trace/contrib/typesafe is an HTTP middleware for braintrust-sdk-go that traces every POST /v1/systemone call made through this SDK. It wraps the *http.Client passed to typesafe.WithHTTPClient, so no manual span code is needed in application code.
This package lives on the feat/typesafe-tracing branch of a fork and is not merged upstream yet. The install step below points at that branch directly.
The middleware matches the span shape the official Python and JS TypeSafe integrations use, not the generic llm shape used for chat completion providers elsewhere in braintrust-sdk-go.
Field
Value
Span name
typesafe.systemOne
braintrust.span_attributes.type
question
braintrust.input_json
state, plus questions as an id-tagged list
braintrust.output_json
answers as an id-tagged list
braintrust.metadata
provider: "typesafe", model
braintrust.metrics
prompt_tokens, completion_tokens, tokens, from usage
Full runnable example
examples/braintrust/main.go. It has its own go.mod, so braintrust-sdk-go and OpenTelemetry stay out of the core SDK’s dependency graph.
The middleware sets standard OpenTelemetry span attributes, so it works with Datadog, Honeycomb, or a raw OTel collector too. Only the braintrust.* attribute names are Braintrust-specific.
Assistant
Responses are generated using AI and may contain mistakes.