Skip to main content

Respan instrumentation plugin for Braintrust

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

respan_instrumentation_braintrust-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file respan_instrumentation_braintrust-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_braintrust-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7f64ea2ba326586a8c82f4b7d92c630e7ba3886af895d92aab6318a78c432fef
MD5 5507f1e598b43afb65f58a0a0febb89d
BLAKE2b-256 fa9e3059b58e0cd37c0113a608ad7c711ad869aa65de44df05b658212981e6a0

See more details on using hashes here.

File details

Details for the file respan_instrumentation_braintrust-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_braintrust-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a37ccc2fdce1d856cdbf8c0fda947dd71040fa03172af9432fc0c73b9c60e944
MD5 6b2b8e35d769392c3dc5751e215dd825
BLAKE2b-256 4af9a5982dafcb1b4a1e38012c4766416635e58bb0dff753173e1b283593e07b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page