How does Tracing Work?

There are four key components within tracing - Instrumentation, Exporter, Protocol, and Collector. We've built all four of these within our tracing tool so it is easy to start troubleshooting your application and surfacing issues.

Instrumentation

In order for an application to emit traces for analysis, the application must be instrumented. Your application can be manually or automatically instrumented.

Many of our auto-instrumentation plugins will collect spans for you with just a few lines of code. All of these instrumentors are managed via a single repository called OpenInference.

We support a simplified register OTEL code that sets up tracig automatically:

from arize_otel import register_otel, Endpoints

# Setup OTEL via our convenience function
register_otel(
    endpoints = Endpoints.ARIZE,
    space_id = "your-space-id", # in app space settings page
    api_key = "your-api-key", # in app space settings page
    model_id = "your-model-id", # name this to whatever you would like
)

The above code sets up your span processors, exporters and endpoints automatically.

If you would like more control over the OTEL instrumentation the full boiler plate is here:

import os
from openinference.semconv.trace import OpenInferenceSpanKindValues, SpanAttributes
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.export import BatchSpanProcessor

arize_space_id_var = "ARIZE_SPACE_ID"
arize_api_key_var = "ARIZE_API_KEY"

# Set the Space and API keys as headers for authentication
headers = f"space_id={arize_space_id_var},api_key={arize_api_key_var}"
os.environ['OTEL_EXPORTER_OTLP_TRACES_HEADERS'] = headers

# Set resource attributes for the name and version for your application
trace_attributes = {
  "model_id": "your model name", # This is how your model will show up in Arize
  "model_version": "v1", # You can filter your spans by model version in Arize
}

endpoint = "https://otlp.arize.com/v1"

span_exporter = OTLPSpanExporter(endpoint=endpoint)
tracer_provider = trace_sdk.TracerProvider(
  resource=Resource(attributes=trace_attributes)
)

tracer_provider.add_span_processor(
  BatchSpanProcessor(
  span_exporter=OTLPSpanExporter(endpoint=endpoint)
  )
)
trace_api.set_tracer_provider(tracer_provider=tracer_provider)

tracer = trace_api.get_tracer(__name__)

SpanProcessor

There are 2 main span processors:

  • Batch Processor - Used for product deployments, this is non-blocking for your application. We default to batch for register otel

  • SimpleSpanProcessor - This is a synchronous logging instrumentation where the log call is blocking, delays in collector will back up into your application. Used for debugging setups

Exporter

An exporter takes the spans created via instrumentation and exports them to a collector. In simple terms, it just sends the data to Arize.

The exporter used for Arize is the GRPC exporter.

OpenTelemetry Protocol

OpenTelemetetry Protocol (or OTLP for short) is the means by which traces arrive from your application to the Arize collector. Arize currently supports OTLP over GRPC.

Collector

The Arize server is a collector and a UI that helps you troubleshoot your application in real time. Arize receives your logs and visualizes them on our dashboard. We use many technologies under the hood to ensure we can support millions of traces and return you aggregations and insights on your data.

Last updated

Copyright © 2023 Arize AI, Inc