Core concepts
span
A span is a traceable unit of execution that records a name, start/end times, attributes, and parent-child relationships. VeADK builds a tree of spans for each request, covering nodes such as agent runs, model calls, and tool executions, and annotates them per the generative-AI semantic conventions with attributes likegen_ai.operation.name and gen_ai.span.kind.
The tracer OpentelemetryTracer
OpentelemetryTracer is the unified tracing entry point. It holds a list of exporters, wires each one into the tracing pipeline on initialization, and automatically attaches an in-memory exporter for local retention and dumping.
exporter
An exporter sends span data to a specific backend platform. Each exporter targets one backend and can be used alone or combined. VeADK ships the following exporters:Attaching a tracer to an agent
Complete model configuration first. This example stores traces locally and does not require an external observability backend. Running it prints a model response and the path to a JSON trace fileapp.py
Tracer parameters
OpentelemetryTracer accepts the following fields:
InMemoryExporter is managed automatically by OpentelemetryTracer and retains completed, sampled spans. Do not add it to the exporters list manually, or initialization fails.Reusing a preconfigured global TracerProvider
By default,OpentelemetryTracer creates and sets the global TracerProvider during initialization. If a global TracerProvider already exists at that point (for example, set by another library or the application itself), VeADK reuses it instead of overriding it.
When a global provider already exists, the APMPlusExporter object remains in the exporter list, but its span processor is not registered by this tracer. Cozeloop, TLS, and in-memory exporters are still attached. This also applies to exporters created with ENABLE_APMPLUS=true
apmplus_managed_externally only indicates that a provider already existed at initialization. It does not inspect that provider’s destination or confirm delivery to APMPlus. If your application already configures OpenTelemetry, configure the APMPlus destination there and verify the Trace ID in the backend
Enabling exporters via environment variables
Besides constructing exporters explicitly,Agent attaches the matching exporter at runtime based on the following environment variables (enabled when set to true). If the agent provides no tracers, an OpentelemetryTracer is created automatically:
Content tracing
By default, spans record the input and output content of the agent, model, and tools. In scenarios involving sensitive data, you can disable content capture and reduce content captured by VeADK. This is controlled byOpenTelemetryConfig.trace_content.
Local dumping
The in-memory exporter built intoOpentelemetryTracer retains spans by session_id. Call dump to export the current session’s spans to a local JSON file for offline analysis:
span_id, trace_id, start/end times, attributes, and parent span. See In-memory exporter for details.