Expand description
Telemetry Module (Core)
Provides centralized observability primitives for the A3S Code agent:
- Span name and attribute key constants
- LLM cost tracking (model, tokens, cost per call)
- Tool execution metrics (duration, success/failure)
- Span helper functions using
tracing(no OTel dependency)
For OpenTelemetry initialization (OTLP exporter, subscriber setup),
see the telemetry_init module in the a3s-code server crate.
§Span Hierarchy
a3s.agent.execute
+-- a3s.agent.context_resolve
+-- a3s.agent.turn (repeated)
| +-- a3s.llm.completion
| +-- a3s.tool.execute (repeated)
+-- a3s.agent.turn_notifyStructs§
- Cost
Summary - Aggregated cost summary
- DayCost
Breakdown - Cost breakdown by day
- LlmCost
Record - Cost record for a single LLM call
- Model
Cost Breakdown - Cost breakdown by model
- Model
Pricing - Pricing table for LLM models (cost per 1M tokens)
- Timed
Span - A guard that measures elapsed time and records it when dropped
- Tool
Metrics - Per-session tool execution metrics collector
- Tool
Stats - Statistics for a single tool
Constants§
- ATTR_
CONTEXT_ ITEMS - ATTR_
CONTEXT_ PROVIDERS - ATTR_
CONTEXT_ TOKENS - ATTR_
LLM_ COMPLETION_ TOKENS - ATTR_
LLM_ MODEL - ATTR_
LLM_ PROMPT_ TOKENS - ATTR_
LLM_ PROVIDER - ATTR_
LLM_ STOP_ REASON - ATTR_
LLM_ STREAMING - ATTR_
LLM_ TOTAL_ TOKENS - ATTR_
MAX_ TURNS - ATTR_
SESSION_ ID - ATTR_
TOOL_ CALLS_ COUNT - ATTR_
TOOL_ DURATION_ MS - ATTR_
TOOL_ EXIT_ CODE - ATTR_
TOOL_ ID - ATTR_
TOOL_ NAME - ATTR_
TOOL_ PERMISSION - ATTR_
TOOL_ SUCCESS - ATTR_
TURN_ NUMBER - SERVICE_
NAME - Service name for telemetry
- SPAN_
AGENT_ EXECUTE - SPAN_
AGENT_ TURN - SPAN_
CONTEXT_ RESOLVE - SPAN_
LLM_ COMPLETION - SPAN_
TOOL_ EXECUTE
Functions§
- aggregate_
cost_ records - Aggregate cost records with optional filters
- default_
model_ pricing - Registry of known model pricing
- record_
llm_ metrics - Record LLM metrics via tracing events.
- record_
llm_ usage - Record LLM token usage on the current span
- record_
tool_ result - Record tool execution result on the current span