How Trace IDs Work in ABV
ABV uses the W3C Trace Context standard for trace IDs:- Trace IDs: 32-character lowercase hexadecimal strings (e.g.,
abcdef1234567890abcdef1234567890) - Span IDs (observation IDs): 16-character lowercase hexadecimal strings (e.g.,
fedcba0987654321)
Understand Default Behavior
- Distributed tracing: Can’t correlate events across multiple services
- External system integration: Can’t map ABV traces to your support tickets, orders, or sessions
- Programmatic access: Can’t fetch specific traces via API using your own IDs
- Trace ID: Random 32-character hex string (W3C Trace Context compliant)
- Span ID: Random 16-character hex string
Generate Deterministic Trace IDs from External IDs
- Same input always produces the same trace ID
- Correlate ABV traces with support tickets, order IDs, session tokens
- Re-generate the same trace ID later for scoring or retrieval
Use Custom Trace IDs in Your Code
parentSpanContext with an arbitrary spanId. This detaches the span from the active context.Propagate Trace IDs Across Services
Access Trace IDs Programmatically
Why Use Custom Trace IDs?
Distributed Tracing: Correlate Events Across Microservices
Distributed Tracing: Correlate Events Across Microservices
- API gateway logs: “Request received at 10:45:12”
- Auth service logs: “User validated at 10:45:13”
- LLM backend logs: “LLM call failed at 10:45:15”
- No connection between these events
- API gateway generates a trace ID when the request arrives
- Passes trace ID to auth service via HTTP header (
traceparent) - Auth service extracts trace ID and uses it for its logs
- Auth service forwards trace ID to LLM backend
- LLM backend logs events with the same trace ID
- ABV groups all events into one trace
- Root cause analysis: See exactly where requests fail in multi-service workflows
- Performance optimization: Identify slow services in the critical path
- Debugging: Trace request flow end-to-end with one query
Deeplinking: Jump from Your UI to ABV Traces
Deeplinking: Jump from Your UI to ABV Traces
f3a2b1c9-4567-8901-2345-6789abcdef01). Your support ticket has ID ticket-12345. No connection between them.The solution with deterministic trace IDs:
Generate ABV trace IDs from your external IDs:- Instant navigation from your tools to ABV traces
- No manual searching or copy-pasting trace IDs
- Better support workflows: “View this user’s LLM traces” → one click
Evaluations: Score Traces by External IDs
Evaluations: Score Traces by External IDs
experiment-2025-01-v2). You need to fetch all traces from that experiment and score them programmatically.The problem:
ABV’s random trace IDs don’t map to your experiment IDs. You can add metadata (metadata.experiment_id = "experiment-2025-01-v2"), but fetching and scoring requires API queries.The solution with deterministic trace IDs:
Generate trace IDs that include your experiment ID:- Programmatic access to specific traces using your IDs
- Batch scoring for experiments without complex queries
- Reproducible evaluations (same seed = same trace ID every time)
API Integration: Fetch Traces Using Your IDs
API Integration: Fetch Traces Using Your IDs
- Direct trace retrieval by ID (no complex metadata queries)
- Faster API responses (indexed by trace ID)
- Simpler code—no need to parse query results
OpenTelemetry Compatibility: Standards-Based Distributed Tracing
OpenTelemetry Compatibility: Standards-Based Distributed Tracing
00: Version (fixed)<trace-id>: 32-character hex string<parent-span-id>: 16-character hex string<trace-flags>: 01 (sampled) or 00 (not sampled)
- Use the same trace IDs across ABV and other observability tools (Datadog, Honeycomb, Jaeger)
- Vendor-neutral: Switch tools without changing instrumentation
- Standards-based: Follow W3C best practices for distributed tracing
Implementation Guide
Python SDK: Decorator Pattern
Python SDK: Decorator Pattern
@observe() decorator to automatically trace functions. Pass custom trace IDs via the special abv_trace_id keyword argument.Setup:abv_trace_idis a special keyword argument recognized by@observe()- Trace ID must be a 32-character lowercase hexadecimal string
- Use
abv.create_trace_id(seed="...")to generate W3C-compliant IDs from any string
Python SDK: Manual Span Creation
Python SDK: Manual Span Creation
JavaScript/TypeScript SDK: Custom Trace IDs
JavaScript/TypeScript SDK: Custom Trace IDs
@abvdev/tracing package to create spans with custom trace IDs.Setup:parentSpanContext.spanIdmust be a valid 16-character hex string- The parent span doesn’t actually exist—it’s only used for trace ID inheritance
- Setting
parentSpanContextdetaches the span from the active context
JavaScript/TypeScript SDK: Access Current Trace ID
JavaScript/TypeScript SDK: Access Current Trace ID
- Log trace ID to external systems (Datadog, Splunk)
- Include trace ID in API responses for debugging
- Pass trace ID to downstream services via HTTP headers
Distributed Tracing: Propagate Trace IDs Across Services
Distributed Tracing: Propagate Trace IDs Across Services
OpenTelemetry: Using Trace IDs
OpenTelemetry: Using Trace IDs
- ABV’s span processors automatically extract trace IDs from OpenTelemetry spans
- No code changes needed—just configure ABVSpanProcessor
- Trace IDs in ABV Dashboard match OpenTelemetry trace IDs exactly