Skip to main content

Respan Braintrust Instrumentation

Send Braintrust spans to Respan through the current Respan OTLP tracing pipeline.

Installation

pip install respan-ai respan-instrumentation-braintrust braintrust

Quick Start

import braintrust
from respan import Respan
from respan_instrumentation_braintrust import BraintrustInstrumentor

respan = Respan(instrumentations=[BraintrustInstrumentor()])

logger = braintrust.init_logger(
    project="braintrust-demo",
    async_flush=False,
)

with respan.propagate_attributes(group_identifier="Braintrust Demo"):
    with logger.start_span(name="Braintrust Demo", type="task") as root:
        with root.start_span(name="answer_question", type="llm") as span:
            span.log(
                input=[{"role": "user", "content": "What is Respan?"}],
                output="Respan captures production LLM traces.",
                metadata={"model": "gpt-4o-mini"},
                metrics={"prompt_tokens": 8, "completion_tokens": 9},
            )

    logger.flush()

respan.flush()
respan.shutdown()

How It Works

BraintrustInstrumentor installs itself as Braintrust's background logger. When Braintrust flushes, the instrumentor translates Braintrust records into canonical Respan/OpenTelemetry spans and injects them into the same pipeline used by respan-tracing.

The instrumentation maps Braintrust span types as follows:

  • llm and chat -> chat
  • tool and function -> tool
  • eval and automation -> workflow
  • task, score, facet, and preprocessor -> task

Braintrust-specific record fields are stored as metadata, while shared Respan and GenAI span fields use constants from respan-sdk and upstream semantic convention packages.

Metadata

Release files for respan-instrumentation-braintrust 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for respan-instrumentation-braintrust 0.1.1
File Size Uploaded
respan_instrumentation_braintrust-0.1.1.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for respan-instrumentation-braintrust 0.1.1
File Interpreter ABI Platform
respan_instrumentation_braintrust-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / respan_instrumentation_braintrust-0.1.1.tar.gz

Download URL respan_instrumentation_braintrust-0.1.1.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
addd09e7d4d4c18223cd54f9d938c260eb21ad399d6a7ed1ed7885bf7d9787e7
BLAKE2b-256 checksum
How to use checksums
7663962b0401fc35e50227e0acda3338cec2a3464c310b282da92151d783ef11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / respan_instrumentation_braintrust-0.1.1-py3-none-any.whl

Download URL respan_instrumentation_braintrust-0.1.1-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3edd366f7b6e7f508fd4e27dbd6fa8bb672b612c64b229a106a1fb18db32573
BLAKE2b-256 checksum
How to use checksums
bafcca49dc8a63b660db9256e49ae75da68922e9a897e22010d7de2cc2b3a965
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page