Skip to main content

Module telemetry

Module telemetry 

Source
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_notify

Structs§

CostSummary
Aggregated cost summary
DayCostBreakdown
Cost breakdown by day
LlmCostRecord
Cost record for a single LLM call
ModelCostBreakdown
Cost breakdown by model
ModelPricing
Pricing table for LLM models (cost per 1M tokens)
TimedSpan
A guard that measures elapsed time and records it when dropped
ToolMetrics
Per-session tool execution metrics collector
ToolStats
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