OpenTelemetryΒΆ

Burr has two integrations with OpenTelemetry:

  1. Burr can log traces to OpenTelemetry

  2. Burr can capture any traces logged within an action and log them to OpenTelemetry

See the following resources for more information:

Reference for the various useful methods:

class burr.integrations.opentelemetry.OpenTelemetryBridge(tracer_name: str = None, tracer: Tracer = None)ΒΆ

Adapter to log Burr events to OpenTelemetry. At a high level, this works as follows:

  1. On any of the start/pre hooks (pre_run_execute_call, pre_run_step, pre_start_span), we start a new span

  2. On any of the post ones we exit the span, accounting for the error (setting it if needed)

  3. On do_log_attributes, we log the attributes to the current span – these are serialized using the serde module

This works by logging to OpenTelemetry, and setting the span processor to be the right one (that knows about the tracker).

You can use this as follows:

# replace with instructions from your prefered vendor
my_vendor_library_or_tracer_provider.init()

app = (
    ApplicationBuilder()
    .with_entrypoint("prompt")
    .with_state(chat_history=[])
    .with_graph(graph)
    .with_hooks(OpenTelemetryBridge())
    .build()
)

app.run() # will log to OpenTelemetry
post_run_step(*, exception: Exception, **future_kwargs: Any)ΒΆ

Run after a step is executed.

Parameters:
  • state – State after step execution

  • action – Action that was executed

  • result – Result of the action

  • sequence_id – Sequence ID of the action

  • exception – Exception that was raised

  • future_kwargs – Future keyword arguments

pre_run_step(*, action: Action, **future_kwargs: Any)ΒΆ

Run before a step is executed.

Parameters:
  • state – State prior to step execution

  • action – Action to be executed

  • inputs – Inputs to the action

  • sequence_id – Sequence ID of the action

  • future_kwargs – Future keyword arguments

burr.integrations.opentelemetry.init_instruments(
*instruments: Literal['openai', 'anthropic', 'cohere', 'google_generativeai', 'mistral', 'ollama', 'transformers', 'together', 'bedrock', 'replicate', 'vertexai', 'groq', 'watsonx', 'alephalpha', 'pinecone', 'qdrant', 'chroma', 'milvus', 'weaviate', 'lancedb', 'marqo', 'redis', 'langchain', 'llama_index', 'haystack', 'requests', 'httpx', 'urllib', 'urllib3'],
init_all: bool = False,
) NoneΒΆ

Instruments the specified libraries, or all that are installed if it is enabled.

This will check if any libraries are available in the current environment and initialize if they are. See the INSTRUMENTS_SPECS field for the list of available libraries.

Parameters:
  • instruments – Name of libraries to instrument (e.g., requests, openai)

  • init_all – If True, initialize all available instruments for imported packages.

Returns: