Documentation Index
Fetch the complete documentation index at: https://docs.tracectrl.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheTraceCtrlSpanProcessor is an OpenTelemetry SpanProcessor that runs on every span. It reads framework-set attributes and adds TraceCtrl security context — agent identity, tool risk classification, session correlation, and prompt integrity hashing.
Enrichment Pipeline
For each span, the processor runs these enrichment steps:Session ID (on span start)
On span start, attaches the current
tracectrl.session_id from the in-process context var. This ensures every span in a session is correlated. On span end, falls back to Agno’s session.id if no explicit session was set.Ingress detection (on span start)
If the span has no valid parent span context, it is marked with
tracectrl.ingress = true and tracectrl.trigger_type is inferred from the span name (email, upload, webhook, scheduled, manual).Agent Identity
For
AGENT spans, derives tracectrl.agent.id and tracectrl.agent.name from framework-specific attributes (Agno’s agno.agent.id / agno.team.id, OpenInference’s agent.name). If only a name exists, the ID is derived as name.lower().replace(' ', '-'). The framework is inferred from span naming conventions: invoke_agent … → strands, openclaw.… → openclaw, Agno IDs → agno, otherwise unknown.Tool Category and Direction
For spans with a
tool.name attribute, classifies the tool into one of 8 risk categories and sets tracectrl.tool.category. Also stamps tracectrl.tool.direction (input, output, or internal).System Prompt Hash
For spans with
llm.system (the system prompt), computes a SHA-256 hash (truncated to 16 hex chars / 64 bits) and stores it as tracectrl.system_prompt_hash. A change in this hash between observations indicates prompt drift or tampering.Span Sequence
Sets
tracectrl.span_sequence to a monotonic counter (stored as a string), reflecting the chronological order of span creation. This enables reconstructing the exact execution order even when timestamps have insufficient resolution.Memory Operation
For
RETRIEVER spans the operation is set to read; for spans whose inferred tool category is memory_write the operation is set to write.Input Source
Sets
tracectrl.input.source based on provenance:"external"— tool category isexternal_apioremail"memory"— tool category ismemory_reador span is aRETRIEVER"agent"—tracectrl.caller.agent_idis present"user"— default (direct human input)
Installation
UnlikeSystemPromptStamper (which is auto-installed by configure()), TraceCtrlSpanProcessor must be added to your TracerProvider explicitly:
tracectrl.configure(...), the provider it creates is set as the global tracer provider; add TraceCtrlSpanProcessor to that global provider after configuration:
System Prompt Stamping
System prompts are surfaced into spans through a complementary flow:- The user calls
tag_agent(agent, system_prompt=...)(ortag_agents(...)) once per agent. This registers the prompt in an in-process registry keyed by agent name. configure()auto-installs aSystemPromptStamperspan processor on the globalTracerProvider.- On every span, the stamper looks up the agent name and writes
llm.systemonto the span. TheTraceCtrlSpanProcessorthen hashes that value intotracectrl.system_prompt_hash.
tag_agent after configure() is enough for prompt hashes to start appearing on spans.
Prompt Drift Detection
Thetracectrl.system_prompt_hash attribute enables detecting when an agent’s system prompt changes unexpectedly:

