Set up Tracing
There are several ways to log traces to Arize.
1. Use Tracing Integrations (Auto-Instrumentation)
Arize makes it easy to log traces with minimal changes by using our tracing integrations. These can then be further customized.
LLM Models | Orchestration Frameworks | Other |
---|---|---|
2. Manual Instrumentation
In some cases, you might want full control over what is being traced in your application. Arize supports OpenTelemetry (OTEL) which means that you can create and customize your spans using the OpenTelemetry Trace API.
Step 1: Install Prerequisities
Python 3.6 or higher
OpenTelemetry API and SDK1
Step 2: Configuring a Tracer
Manually configuring an OTEL tracer involves some boilerplate code that Arize takes care of for you. We recommend using the register_otel
helper method below to configure a tracer.
If you need more control over your tracer's configuration, see the Manually Configuring an OTEL Tracer section below.
Step 3: Creating Spans
If you're using a Tracing Integration, these will take care of automatically creating the spans for your application. You can then further customize those spans - for more information check out setting up hybrid instrumentation.
If you want fully customize the spans, you can do that using manual instrumentation. You'll typically want it to be started as the current span.
You can also use start_span
to create a span without making it the current span. This is usually done to track concurrent or asynchronous operations.
Creating nested spans
If you have a distinct sub-operation you'd like to track as a part of another one, you can create span to represent the relationship:\
When you view spans in a trace visualization tool, child
will be tracked as a nested span under parent
.
Creating spans with a decorator
It's common to have a single span track the execution of an entire function. In that scenario, there is a decorator you can use to reduce code:
Use of the decorator is equivalent to creating the span inside do_work()
and ending it when do_work()
is finished.
To use the decorator, you must have a tracer
instance in scope for your function declaration.
If you need to add attributes or events then it's less convenient to use a decorator.
Last updated