- Improved Developer Experience: A more intuitive API means less code to write for tracing your application, simplifying the integration process.
- Unified Context Sharing: Seamlessly hook into the tracing context of the current span to update it or create child spans. This is particularly beneficial for integrating with other instrumented libraries.
- Broad Third-Party Integrations: Any library instrumented with OpenTelemetry will work out-of-the-box with the ABV SDK. Spans from these libraries are automatically captured and correctly nested within your ABV traces.
Quickstart
There are three main ways of instrumenting your application with the new ABV SDK. All of them are fully interoperable with each other. Install packageUsing Observe Decorator
The @observe decorator is the simplest way to instrument your application. It is a function decorator that can be applied to any function. It sets the current span in the context for automatic nesting of child spans and automatically ends it when the function returns. It also automatically captures the function name, arguments, and return value.Using Context Managers
Context managers are the recommended way to instrument chunks of work in your application as they automatically handle the start and end of spans, and set the current span in the context for automatic nesting of child spans. They provide more control than the @observe decorator.Using Manual Observations
Manual observations give you control over when spans start and end and do not set the current span in the context for automatic nesting of child spans. You must explicitly call .end() when theyāre complete.Learn more
Setup Instrumentation Evaluation Advanced usage Troubleshooting & FAQKey Features Supported
The Python SDK provides full support for all ABV features:- Observability & Tracing: Comprehensive tracing of LLM applications
- Sessions: Group related traces by user journey
- User Tracking: Associate traces with specific users
- Metadata: Add structured context to traces
- Tags: Label and categorize traces
- Model Usage & Cost Tracking: Monitor tokens and costs
- Masking Sensitive Data: Redact PII and secrets
- Sampling: Control trace volume
- Prompt Management: Fetch and link prompts to traces
- Evaluations: Run evaluations and create datasets
- Guardrails: Implement LLM security guardrails
OTEL and ABV
The ABV SDK is built upon OpenTelemetry (OTEL), a standard for observability. Understanding the relation between OTEL and ABV is not required to use the SDK, but it is helpful to have a basic understanding of the concepts. OTEL related concepts are abstracted away and you can use the SDK without being deeply familiar with them.
- OTEL Trace: An OTEL-trace represents the entire lifecycle of a request or transaction as it moves through your application and its services. A trace is typically a sequence of operations, like an LLM generating a response followed by a parsing step. The root (first) span created in a sequence defines the OTEL-trace. OTEL-traces do not have a start and end time, they are defined by the root span.
- OTEL Span: A span represents a single unit of work or operation within a trace. Spans have a start and end time, a name, and can have attributes (key-value pairs of metadata). Spans can be nested to create a hierarchy, showing parent-child relationships between operations.
- ABV Trace: A ABV trace collects observations and holds trace attributes such as
session_id,user_idas well as overall input and outputs. It shares the same ID as the OTEL trace and its attributes are set via specific OTEL span attributes that are automatically propagated to the ABV trace. - ABV Observation: In ABV terminology, an āobservationā is a ABV-specific representation of an OTEL span. It can be a generic span (ABV-span) or a specialized āgenerationā (ABV-generation) or a point in time event (ABV-event)
- ABV Span: A ABV-span is a generic OTEL-span in ABV, designed for non-LLM operations.
- ABV Generation: A ABV-generation is a specialized type of OTEL-span in ABV, designed specifically for Large Language Model (LLM) calls. It includes additional fields like
model,model_parameters,usage_details(tokens), andcost_details. - ABV Event: A ABV-event tracks a point in time action.
- Context Propagation: OpenTelemetry automatically handles the propagation of the current trace and span context. This means when you call another function (whether itās also traced by ABV, an OTEL-instrumented library, or a manually created span), the new span will automatically become a child of the currently active span, forming a correct trace hierarchy.
ABVSpan, ABVGeneration) that offer convenient methods for interacting with ABV-specific features like scoring and media handling, while still being native OTEL spans under the hood. You can also use these wrapper objects to add ABV trace attributes.