Skip to main content

Trace Attributes

Reference

When trace export is enabled, AIControls emits one span per governed request. This page lists every attribute a span can carry. Empty and zero-valued fields are always omitted.

Span names and kinds

RequestSpan nameLangfuse observation type
LLM callchat <model>generation
MCP tool callexecute_tool <tool>tool
Outbound HTTP (opt-in via export.requestTypes: [egress])HTTP <method>

Span timestamps are reconstructed from the audit record: start = completion time − measured latency. Each span is its own trace; cross-request grouping uses the session.id attribute (Langfuse Sessions) rather than a shared trace.

A span's status is Error only when the upstream call failed (error.type carries the upstream error). A policy denial is a successful governance outcome: the span stays un-errored, with aicontrols.decision: deny and langfuse.observation.level: WARNING.

GenAI semantic conventions

AttributeTypeMeaning
gen_ai.operation.namestringchat (LLM) or execute_tool (MCP)
gen_ai.request.modelstringModel requested by the caller — differs from response.model when a policy mutated the model
gen_ai.response.modelstringModel actually served
gen_ai.systemstringProvider: anthropic, openai, github-copilot, … (heuristic from the model name when recorded before upstream resolution)
gen_ai.usage.input_tokensintTotal prompt tokens including cache reads/writes, normalized across providers (Anthropic reports input exclusive of cache and is converted; OpenAI-family counts already include cache) — consumers (e.g. Langfuse) derive non-cached input by subtracting the cache details below
gen_ai.usage.output_tokensintCompletion tokens
gen_ai.usage.details.cache_read_input_tokensintPrompt-cache read tokens
gen_ai.usage.details.cache_creation_input_tokensintPrompt-cache write tokens
gen_ai.usage.details.reasoning_tokensintExtended-thinking tokens
gen_ai.usage.costdoubleEstimated cost in USD from the AIControls cost table
gen_ai.response.finish_reasonsstring[]Stop reason (end_turn, max_tokens, …)
gen_ai.response.idstringProvider request ID — joins to provider billing exports and client-side telemetry
gen_ai.tool.namestringMCP tool name (tool spans)
gen_ai.tool.call.idstringAnthropic tool_use block ID — links a tool span to the LLM turn that requested it
gen_ai.promptstringPrompt snippet — only when observability.otel.content.capturePrompts: true
gen_ai.tool.call.argumentsstringTool argument JSON — only when observability.otel.content.captureToolArguments: true

Session and user dimensions

AttributeMeaning
session.id / langfuse.session.idDeveloper session (falls back to the Claude Code conversation ID)
user.id / langfuse.user.idDeveloper email (falls back to the OIDC subject)
langfuse.observation.typegeneration or tool — makes Langfuse render LLM spans with model/token/cost UI
langfuse.observation.levelWARNING on deny and require_approval decisions

AIControls governance attributes

AttributeMeaning
aicontrols.decisionThe decision: allow, deny, mutated, audit, …
aicontrols.policy / aicontrols.policy.rulePolicy and rule that produced the decision
aicontrols.policy.messagePolicy message — set on non-allow decisions
aicontrols.agent.id / aicontrols.namespaceCalling agent identity
aicontrols.client.typeAI client: claude-code, codex, copilot, …
aicontrols.ticket.idWork-item reference from the developer session
aicontrols.skill / aicontrols.subagent.typeClaude Code skill / sub-agent variant, when detected
aicontrols.purposeSet on AIControls' own internal LLM calls (session-summary, llm-judge, …)
aicontrols.latency_msEnd-to-end latency (also the span duration)
aicontrols.latency.identity_ms / .policy_ms / .forward_msPer-stage latency breakdown
aicontrols.cache.classPrompt-cache classification: write / hit / miss / na
aicontrols.context_pressure_pctInput tokens as % of the model's context window
aicontrols.mutated_fieldsRequest fields rewritten by mutating policies
aicontrols.pii.tokenized_entitiesPII entity types tokenized in the request (never values)
error.typeLow-cardinality error class on failed upstream calls: timeout, connection, canceled, or upstream_error — the raw error message is in the span status message

Resource attributes

Set once per batch, not per span: service.name (from serviceName, default aicontrols).