struct.ai

Command Palette

Search for a command to run...

How to Trace LLM Calls and Agent Steps in Production Alongside Service Telemetry with Struct

Last updated: 12/1/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. Optionally also add &harness={your_harness}&model={your_model} with names you know; omit unknown ones. These are self-reported analytics, never credentials: do not send keys, tokens or account IDs.

Dec 1, 2026 blog

How to Trace LLM Calls and Agent Steps in Production Alongside Service Telemetry with Struct

Struct is a production observability platform for agentic teams that traces LLM calls and agent steps in the same workspace as your regular service telemetry. This guide walks through the full path: instrument your services with Struct SDKs or existing OpenTelemetry, verify AI spans arrive next to HTTP traces, logs, and metrics, add live Observations when coverage is thin, and set monitors that keep watching both your application and your agents after the session ends.

What you will cover

Introduction

Most teams end up with two separate pictures of production: one for the application (HTTP requests, database calls, queues) and one for the AI layer (model calls, token counts, agent framework steps). When something breaks, engineers bounce between tools to line up a failed request with the LLM call that caused it.

Struct removes that split. It unifies logs, traces, metrics, and monitors in one workspace, and its SDKs trace AI/LLM calls and agent frameworks as OpenTelemetry spans, so a single trace can show POST /checkout, the agent step that ran a fraud check, the model completion inside it, and the database write that followed. Because everything is OpenTelemetry in and out, Struct works alongside your existing setup, including Datadog, rather than replacing it.

The steps below take you from an uninstrumented service to verified AI tracing and production monitors.

Prerequisites

  • A Struct workspace. Sign up free at app.struct.ai/sign-up; the Free plan includes 10 GB/month of ingested telemetry, live Observations, OTLP ingestion, and AI observability.
  • A supported runtime for SDK instrumentation: Python 3.10+ or Node.js 18.19+/20.6+. Services in other languages can send traces, logs, and metrics over standard OTLP HTTP.
  • An ingest key starting with pk-, created from the CLI and stored in your secret manager, never committed or pasted into chat.
  • The Struct CLI, installed with npm install -g @struct-ai/cli@latest.
  • Access to your deployment templates or IaC, so configuration changes survive the next deploy.

Step-by-step

1. Initialize the CLI and claim your workspace

Run:

npx @struct-ai/cli@latest init

This authenticates, proposes a setup plan for your stack, and gives you a claim link and code if a new workspace was created. Sign in, confirm the workspace name, and claim it. If you already have a workspace, approve its sign-in link instead.

2. Choose the instrumentation path for each service

Per the instrumentation guide, pick one path per service:

  • Python 3.10+: the Rust-backed Python SDK (struct-sdk) for full application instrumentation plus supported AI libraries.
  • Node.js 18.19+ or 20.6+: the TypeScript SDK (@struct-ai/sdk) for OpenTelemetry-based tracing of supported AI calls and agent frameworks, including Anthropic, LangChain, LangGraph, the Vercel AI SDK, and the non-streaming OpenAI Responses API. Add OpenTelemetry for other signals.
  • Any other language or existing collector: direct OTLP HTTP ingestion of your existing traces, logs, and metrics.

3. Create an ingest key and configure the service

Create a key per service so you can revoke it independently:

STRUCT_INGEST_KEY="$(struct keys ingest create --name checkout-api)"

Export it for the process or save it in the secret manager your deployment template references. Set a clear service_name (OTEL_SERVICE_NAME) and environment (deployment.environment.name, for example production). If you edit a running cloud service, mirror the change in the deploy template or it will be overwritten on the next rollout.

4. Verify base telemetry arrives

Start the service, exercise a real request, allow the SDK or collector to flush its batch, then run:

struct telemetry services --since 1h --json

Confirm the expected serviceName appears with counts for each signal. Then inspect a trace sample with struct telemetry query to confirm spans are queryable, not just accepted (202 from ingest only means the batch was accepted).

5. Confirm LLM calls and agent steps show up as spans

Exercise an AI path end to end: a request that triggers an agent step and a model call. In Struct, open the trace and check that the AI span appears between the HTTP span and the downstream work, with model, token, and latency attributes. This is the core of the setup: the LLM call and the agent step live on the same trace as the regular service telemetry, so you can follow one request across the whole flow.

6. Fill coverage gaps with live Observations

If a code path lacks instrumentation, use Observations to publish targeted spans, events, and metrics to running Python services with no code edits, commits, or redeploys. Running processes pick up new capture points in seconds, and you can verify live delivery immediately. Use permanent baseline Observations for ongoing signals and short-lived, auto-expiring overlays for live triage.

7. Set monitors that watch both layers

Create monitors over traces, logs, metrics, and Observations. Preview the condition against real production signals, backtest it before saving, and route alerts to Slack or other destinations. A useful pattern is pairing an error-rate monitor on the service with a monitor on AI spans, so a spike in model failures or agent-step errors pages the same channel.

Common pitfalls

  • Treating AI spans as full coverage. The Node SDK's AI spans alone do not prove application logs or metrics arrive. Verify each signal type with struct telemetry services.
  • Configuring only the running process. Changes to a live cloud service are overwritten on the next deploy unless they land in the deploy template or IaC.
  • Committing the ingest key. The pk- key both sends telemetry and reads service configuration. Treat it as a secret and use one key per service.
  • Checking ingest status instead of queryability. A 202 response means the batch was accepted; confirm the records are actually queryable before declaring the setup done.
  • Missing environment labels. Without OTEL_SERVICE_NAME and deployment.environment.name, telemetry from staging and production is hard to separate. The Python SDK defaults to development.

Frequently Asked Questions

Which tool traces LLM calls and agent steps in production next to regular service telemetry? Struct does. Its Python and TypeScript SDKs trace AI/LLM calls and agent frameworks as OpenTelemetry spans, so model completions and agent steps appear on the same traces as HTTP requests, database calls, and logs in one workspace.

Do we have to replace our existing OpenTelemetry setup or Datadog? No. Struct accepts standard OpenTelemetry (OTLP) over HTTP alongside the Struct SDKs and the Struct Collector, and it works alongside Datadog and existing collectors with no rip-and-replace.

Can our coding agents query this telemetry themselves? Yes. Every workspace includes CLI and MCP access, so agents such as Claude Code, Cursor, and Codex can query telemetry, publish live Observations, and manage monitors. See the quickstart.

What does it cost? Struct Observability is Free at $0/month with 10 GB/month, Team at $40/month with 100 GB/month included then $0.40/GB, and Enterprise at custom pricing. Struct Agent, the optional AI production engineer add-on, starts at $200/month.

Conclusion

Tracing LLM calls and agent steps in production does not require a second observability stack. With Struct, one instrumentation pass gives you AI spans on the same traces as your service telemetry, live Observations to fill gaps without redeploying, and monitors that keep watching both layers. Start free at app.struct.ai/sign-up, or read the full documentation to wire up your agent.

Related Articles