October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Correlate LLM Calls, Tool Invocations, and Agent Spans in OpenTelemetry

Keep an agent turn’s causally related work in one OpenTelemetry trace, with distinct spans for orchestration, model inference, and tool execution.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep causally related work for one request or agent turn in the same OpenTelemetry trace, propagate its context across boundaries, and represent orchestration, model inference, and tool execution as distinct spans. Use parent-child relationships for work that fits the operation’s actual nesting; use span links when important causal relationships do not fit a single-parent tree.

Start with the trace boundary

A trace is the record of work for one logical operation, such as handling an application request or running an agent turn. Its spans have individual SpanIds and share a TraceId. A span with a parent records that parent relationship and shares the parent’s TraceId. The root span should represent the real orchestration boundary—not simply whichever library happens to make the first model call.

As an Amazon Associate I earn from qualifying purchases.

For an agent workflow, that boundary is often the application’s invocation of the agent. For a simpler application with no agent orchestration, it may be the request handler or another operation that owns the model call. Instrument the actual boundaries in your application rather than imposing an identical tree on every framework.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Represent orchestration, inference, and tools separately

Each span should describe one operation. An agent span describes orchestration; an inference span describes the model request; and a tool span describes the tool’s execution. Keeping those operations distinct makes it possible to see whether time and errors belong to planning, a model request, dispatch, or tool work.

Agent invocation

The OpenTelemetry GenAI agent convention recommends invoke_agent for agent invocation. It recommends an INTERNAL span kind for same-process agent work and a CLIENT kind for a remote invocation. These are evolving GenAI conventions, not universal behavior guaranteed by every SDK or framework.

The convention describes a plan span for planning work. If an LLM call generates the plan, that inference span is a child of the plan span. Tool or task operations arising from the plan are typically sibling operations under the agent invocation. Use this as a semantic guide: the recorded nesting should reflect the work your application actually performs.

Model inference

Record a model request as its own GenAI inference span. The GenAI client convention describes the logical operation as lasting until the response is fully received, or until the operation ends through error or cancellation; automatic retries belong to that logical operation. Give the span a useful operation name and include relevant GenAI attributes that the instrumentation actually provides.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not assume that a particular instrumentation library emits every GenAI attribute, or that a convention’s current names and requirements are stable. The official GenAI client and agent conventions are marked Development, so check the current convention and the documentation for your chosen SDK or framework before relying on specific fields.

Tool execution

A model request that asks for a tool and the tool’s actual execution are different operations. The GenAI client convention uses execute_tool for the tool operation and encourages application developers to manually instrument tool calls that automatic instrumentation does not cover.

Place execution under the active agent workflow or tool-dispatch operation when that matches the real call path. A subsequent model request is a later operation within the relevant agent invocation, not part of the tool’s execution span. If existing MCP instrumentation already represents a tool execution, avoid adding a second span for the same operation. Do not invent a tool-call identifier attribute; use one only when the current convention or framework documents it.

Propagate context across asynchronous and service boundaries

OpenTelemetry Context carries execution-scoped values across API boundaries and between logically associated units of work. In practice, the active trace context must follow work as it moves through the application; otherwise, an asynchronous task or downstream service may start a disconnected trace instead of appearing as part of the original request.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Establish context at the boundary. Ensure the incoming request or logical agent turn has an active trace context and a span representing the operation that owns the work.
  2. Carry or activate it across in-process work. Pass or activate context when execution crosses library, callback, or asynchronous boundaries, using the mechanisms supported by the language SDK and framework.
  3. Inject and extract at service boundaries. Configure OpenTelemetry propagators to carry context with outgoing calls and recover it in the receiving service. The W3C Trace Context propagator validates and carries supported traceparent and tracestate values.
  4. Check the resulting relationship. When propagation and instrumentation work together, the downstream operation appears in the same trace with the outgoing operation as its remote parent.

SpanContext is the identifying context used for span propagation; it includes the TraceId and SpanId and conforms to W3C Trace Context. Propagation preserves trace relationships across supported boundaries, but it does not by itself create useful spans for uninstrumented work.

Choose parent-child relationships or links based on causality

Parent-child nesting expresses a coherent operation with sub-operations. It is the natural choice when a model call, tool dispatch, or other unit of work is performed as part of an active operation and the tree reflects that execution.

Rank #4
Sale
The Bass Player's Handbook
  • Pages: 155
  • Instrumentation: Bass

A span has one parent, so a tree cannot always express every meaningful causal relationship. OpenTelemetry span links can point to related spans in the same or different traces. Use a link when an operation has causal predecessors that cannot be accurately represented by making one of them its parent. Do not use links as a substitute for ordinary nesting when the operation really is a child in the active workflow.

Keep conversation identity separate from trace identity

A conversation or session can outlive a single trace. The GenAI agent convention says to set gen_ai.conversation.id only when the instrumented library has the value readily available or the application supplies it through OpenTelemetry Context or a library-specific mechanism. Treat it as supplementary correlation where appropriate; it does not replace propagation of trace context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check instrumentation and backend coverage

Instrumentation coverage is not universal. Before adopting a library or trace backend, check which model providers and agent frameworks it instruments, whether application-owned tools need manual spans, and whether context survives the asynchronous and service boundaries in your architecture. Confirm that emitted names and attributes match the current conventions where that matters.

Best Value
The Pipers' Handbook
  • Used Book in Good Condition

Also verify that the backend lets you inspect parent-child and linked-span relationships, and decide how prompt, response, and tool data will be handled under your data-governance requirements. Do not assume every instrumentation captures message content or that capturing it is appropriate.

Amazon OpenSearch Service is one documented example of an AI observability backend built on OpenTelemetry and GenAI conventions; AWS describes hierarchical traces across orchestration, LLM calls, tool invocations, and retrieval. It is an optional backend example, not a requirement for instrumenting OpenTelemetry.

A practical shape for one agent turn

A trace might be organized conceptually like this, with nesting chosen to match the application’s actual execution:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Agent invocation (invoke_agent)
    • Plan operation
      • Inference operation that generates the plan
    • Tool dispatch or task operation
      • Tool execution (execute_tool)
    • Later inference operation, such as a model request after tool output

This is a guide to the meaning of spans, not a required tree for every agent implementation. If real execution differs, instrument that execution; if causal work cannot be represented correctly by the tree’s parent relationships, add links where appropriate.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.