Skip to main content
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.

Install

Usage

Span shape

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.

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.

Custom TracerProvider

Any other OpenTelemetry backend

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.