Set up Tracing
Last updated
Was this helpful?
Last updated
Was this helpful?
We recommend starting with the auto-instrumentation first. If you require more control or want to further customize, you can leverage our OTEL compliant instrumentation API directly.
Arize makes it easy to log traces with minimal changes by using our tracing integrations. These can then be further .
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.
Notebooks
LlamaIndex Tracing
Langchain Tracing
Logging data manually
Example code
Python 3.6 or higher
OpenTelemetry API and SDK1
Manually configuring an OTEL tracer involves some boilerplate code that Arize takes care of for you. We recommend using the register
helper function below to configure a tracer.
If you want fully customize the spans, you can do that using manual instrumentation.
First we should set the tracer for our manual spans below
Next we create spans by starting spans and defining our name and other attributes
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.
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
.
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 more control over your tracer's configuration, see the section below.
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 .
If you need to add or then it's less convenient to use a decorator.
Or you can import it via a node command when you run your server as outline in the using import or require:
The values of instrumentation-scope-name
and instrumentation-scope-version
should uniquely identify the , such as the package, module or class name. While the name is required, the version is still recommended despite being optional.
In the case of the , there are two places where a tracer may be acquired with an appropriate Instrumentation Scope:
Step 5: Create spans Now that you have initialized, you can create .
: Starts a new span without setting it on context.
: Starts a new span and calls the given callback function passing it the created span as the first argument. The new span gets set in context and this context is activated for the duration of the function call.
Step 3: Create spans Now that you have initialized, you can create .
This documentation includes material adapted from the OpenTelemetry JS "Instrumentation" documentation, originally authored by the OpenTelemetry Authors, available . It is used under the Create Commons Attribution 4.0 license (). It has been modified here to provide relevant examples for Arize.