ExAgent. Telemetry
(ExAgent v3.0.0)
View Source
Telemetry event helpers.
Stability — Stable.
The framework emits the standard Elixir :telemetry events so any host app
can observe agent runs through the usual OTel / Telemetry.Metrics /
LiveDashboard pipeline.
Events
:system_time is the VM's Unix time in native units. :duration is
monotonic elapsed time in native units. Metadata never carries prompts,
messages, tool arguments or results: content reaches traces only through
the opt-in redactor of ExAgent.Observability.OpenTelemetry.
The run and model-request events carry :telemetry_span_context in their
metadata. Match this opaque string by equality to pair a start with its stop
or exception. Resuming a paused run creates a fresh context.
Run and logical model request events also carry :namespace from the host
runtime or continuation Store. Absent or overlong namespaces appear as
nil. Namespace strings are limited to 512 UTF-8 bytes in metadata and
are excluded from the built-in metric tags.
Every [:exagent, :run, *] event carries the lineage :run_id,
:root_run_id (equal to :run_id for a root run), :parent_run_id (nil
for a root run) and the :attempt_id of this execution attempt.
[:exagent, :mcp, :catalogue, :drift](candidate) — a pinned client completed a comparison with differences. Measurements count:added,:removedand:changeddeclaration names. Metadata carries:revisionand:on_drift.[:exagent, :run, :start]— measurements:%{system_time}, metadata:%{agent}plus lineage[:exagent, :run, :stop]— measurements:%{duration}, metadata:%{agent, status, usage, steps}plus lineage. A confirmed approval pause reports:pausedand success reports:succeeded. Duration covers this attempt. Usage and steps include earlier attempts of the run. Usage retains qualified accounting.usage.detailsholds known numeric counters under string keys such as"cached_tokens". A missing key is unknown.[:exagent, :run, :exception]— measurements:%{duration}, metadata:%{agent, reason}plus lineage.reasonis the bounded diagnostic (%{type: ...}, plusproviderandstatusfor a request error), never the run error's own strings. Both run terminal events include usage and cost coverage from their result.[:exagent, :model, :request, :start | :stop | :exception]— one start and one stop or exception per admitted model request, output retries included. Metadata:%{agent, run_id, root_run_id, model_request_id, step, model, provider, stream, fixture}; stop and exception addusage_status,usage_quality,cost_status(cost_centsfor a full estimate orcost_subtotal_centsfor a known portion). Stop addsfinish_reasonand exception adds a boundedreasondiagnostic. A provider's incomplete terminal ({:incomplete_response, finish}, such as:length) is a stop with thatfinish_reasonand its reported tokens, whichever the model. Stop measurements are%{duration}plus:input_tokens,:output_tokens,:cache_read_tokens,:cache_write_tokensand:reasoning_tokensonly for the dimensions the provider reported: an unreported dimension is absent, never zero.ExAgent.Models.ReqLLMcounts a dimension only with evidence (see its "Usage" section).[:exagent, :model, :reasoning_prefix, :reset](candidate) — input reasoning retired when projecting a request, selecting a portable ReqLLM leaf or processing a reported Responses prefix mismatch. Measurements:%{dropped_blocks}. Metadata:%{model, provider, reasons}and, in a run,run_idandmodel_request_id. The reasons are bounded atoms. The event carries no history, fingerprints, signature bytes, or provider item IDs.[:exagent, :model, :attempt, :start | :stop]emits one pair per model adapter dispatch in a run, including Fallback leaves and their retries. Start measuressystem_time. Both events carryagent, run_id, root_run_id, model_request_id, step, model, provider, operation, conversation_compacted, stream, source, fixture, telemetry_span_context. The opaque span context matches the span'sexagent.attempt.id. Group by the logical request ID. The candidate GenAI fields areoperation("chat") andconversation_compacted.conversation_compactedistruewhen the effective projection is known to be compacted andnilotherwise. Model and GenAI provider labels come from the selected adapter. Invalid labels map to"other". Source is:testforExAgent.Models.Testand:adapterfor other callbacks.fixtureis:recordduring cassette recording andnilotherwise. Replay bypasses dispatch and appears on the logical request withfixture: :replay. Stop measuresdurationand any known token dimensions listed above. It addsoutcome(:succeeded,:failed,:incompleteor:cancelled),finish_reason,http_statusand the same coverage and price fields as logical requests. The price is the adapter's estimate when supplied. The finish, HTTP status and usage quality arenilwhen unavailable.[:exagent, :embeddings, :request, :start | :stop](candidate) — one pair per admitted embeddings or rerank dispatch. Metadata includesoperation("embeddings"or"rerank"),provider,model,input_items,run_id,call_refandtelemetry_span_context. The latter matches the span'sexagent.request_id. Start measuressystem_time. Stop carriesoutcome,reason,http_statusand qualified usage and cost metadata. Stop measuresduration, available token counts and any observedrerank_search_units. Unavailable measurements are omitted.[:exagent, :media, :request, :start | :stop](candidate) — admitted transcription, speech, image generation and OCR requests. Metadata includesoperation,provider,model,run_id,call_refandtelemetry_span_context. On return, stop adds the outcome, HTTP status when available, qualifiedusage_unitsand cost metadata. Measurements include duration and available token counts or media units. Media input, output and provider error bodies are excluded.[:exagent, :tool, :stop]—:durationis in native time units. Metadata includes:agent,:run_id, the declared:tool_name(or"unknown_tool"), the invocation's opaque:call_ref, the tool return's:status,:success(status == :succeeded) and:duration_measured. When the worker returns its elapsed time,:duration_measuredis true. If it exits without reporting a duration, the value covers the whole tool batch, including other calls, and:duration_measuredis false. For a nested candidateTool.CodeModestep, metadata also includes:program_call_ref, the one-based:program_stepand:effect.[:exagent, :guardrail, :tripped]counts a policy decision with%{count: 1}and metadataname, stage, run_id, root_run_id, attempt_id.[:exagent, :output, :partial]counts structured stream previews with%{count: 1}and metadata%{mode: :tool | :native | :prompted}.[:exagent, :model, :retry]— emitted byExAgent.Models.Fallbackbefore a retry or fallback; measurements:%{attempt, delay_ms}, metadata:%{model, status, fallback}[:exagent, :rate_limiter, :wait | :reject | :cooldown]— queued attempt, refused attempt or received provider cooldown. Measurements includecount: 1andwait_mswhen known. Metadata contains the configured quota:key.[:exagent, :rate_limiter, :settlement_retry]— background retry of a shared permit's terminal report. Measurements are%{count: 1, delay_ms: delay}and metadata contains the configured quota:key. A single late report uses a delay of zero.[:exagent, :usage_limits, :budget, :settlement](candidate) describes a terminal spend observation or an acknowledged host reconciliation. Measurements includecount: 1, the runtime'sreservation_centswhen available, and eithercharged_centsfor a confirmed full charge orsubtotal_centsfor partial evidence. Unknown amounts are absent. Metadata containsreservation_id, boundedlabelsandsource(:runtimeor:reconciliation). Values ofcoverageare:available,:partialor:unavailable, withoutcome:priced,:unusedor:held. A repeated reconciliation can report the same reservation ID. Runtime charges are based on qualified estimates.[:exagent, :usage_limits, :budget, :threshold](candidate) reports a reached spend threshold. Measurements includecount: 1,charged_centsandlimit_cents. Metadata containswindow_start(Unix milliseconds),threshold(whole percent) andaccount(the local ETS account name or the lowercase hexadecimal PostgreSQL scope digest). Delivery is best effort. An account claims a threshold at most once per window.[:exagent, :usage_limits, :budget, :settlement, :unconfirmed](candidate) counts a settlement whose retry could not be confirmed. Measurements are%{count: 1}and metadata is empty.[:exagent, :conversations, :activation]counts cold activation activity with%{count: 1}. Metadata contains only:status, one of:waiting,:queue_full,:capacity,:wait_timeout,:factory_timeout,:start_unconfirmedor:reconciled. Reconciliation releases a reservation when its start settles or its supervising partition exits.[:exagent, :job, :start]and[:exagent, :job, :stop]—ExAgent.Jobs; measurements:%{system_time}/%{duration}, metadata:%{job_id, name}(andstatuson stop)[:exagent, :store, :postgres, :maintenance_failed](candidate) counts a failed cleanup for one table with%{count: 1}and metadata%{repo, table, error}. The error is a diagnostic map with a string:typeand excludes SQL, row data and exception messages.[:exagent, :chat, :checkpoint_wait_expired](candidate) counts a generated chat resume job cancelled after waiting for a pending checkpoint. Measurements are%{count: 1}and metadata is%{job_id}.[:exagent, :judge, :verdict]—ExAgent.Judge; measurements:%{count: 1}, metadata:%{kind, verdict}[:exagent, :eval, :online, :result]— measurements:%{count: 1, duration, system_time}.durationcovers grading, including the wait for a durable grade. Both times use native units. Metadata includesprojection_version: 1,event_name,id,scope,run_id,run_status,source,evaluator,evaluator_version,response_id,trace,tools,tools_complete,score,label,errorandgrading. The optional trace contains IDs and sampling flags. Grading usage is qualified and tools use safe identities.[:exagent, :eval, :online, :delivery]— measurements:%{count: 1}. Metadata shares the result'sprojection_version,id,scope,run_id,source,evaluatorandevaluator_version.statusis:dispatchedwhen the OTLP callback returned:okand any durable marker was confirmed, or:delivery_unconfirmedotherwise. Queues without an OTLP callback emit only the result.[:exagent, :eval, :online, :discard]— measurements:%{count: 1}. Metadata includesprojection_version: 1,scope,run_id,source,evaluator,evaluator_versionandreason. It reports an admitted sample that yielded no published grade, for example when a C7 receipt could not be verified or a durable export claim was unconfirmed.[:exagent, :memory, :command]—ExAgent.Memory.tool/2and the preload ofExAgent.Memory.capability/2(command: :preload); measurements:%{count: 1}, metadata:%{command, status}(no scope or content)[:exagent, :compaction, :stop]—ExAgent.Compaction.capability/2, once per model request; measurements:%{duration, input_messages, output_messages}, metadata:%{agent, run_id, step, compactor, status, error}.statusis:compacted,:no_changeor:error; on:errorthe request keeps its incoming projection anderroris a bounded diagnostic (no content).
Summary
Functions
@spec metrics() :: [Telemetry.Metrics.t()]
Metric definitions for LiveDashboard and Telemetry.Metrics reporters.
Available when compiled with the optional :telemetry_metrics dependency.
Durations are milliseconds. Request and attempt token sums retain their
usage quality and coverage tags. Attempts can include known subtotals.
Correlation IDs, provider and model are available to event handlers.
The built-in series use fixed tags.
Error counters tag known diagnostic types. Custom types share "other".