BuildImplementation guide6 min read

LLM Observability Implementation Guide

By Nicolas Narbais

Trace model calls, retrieval, tools, cost signals, and policy-safe prompt visibility without losing the customer request that explains them.

Last updated on

Make production LLM workflows explainable in Tsuga across seven progressive levels. Connect every generated answer back to its user request, model, retrieval, tool calls, token volume, latency, and errors.

LevelGoalWhat it proves
1Choose & normalize instrumentationProvider, model, operation, tokens mapped cleanly
2Trace customer request → model callRequest span parents model call + streaming wait
3Lock bounded identity & token metricsGroupable by provider, model, operation, workflow
4Add policy-safe content visibilityApproved capture policy + passing negative PII test
5Trace RAG retrievalEmpty, slow, and failed retrieval separated from LLM
6Trace agent tool executionTool spans, failures, and async links attributable
7Operationalize cost & monitorsOwned alerts, runbooks, and labeled cost estimates
flowchart LR REQ["User request span"] --> RAG["Retrieval span"] RAG --> LLM["Model call span"] LLM --> TOOL["Tool execution spans"] TOOL --> RES["Response"] REQ -.->|"Correlated logs & span metrics"| TS["Tsuga: LLM Explorer, Traces, Logs, Metrics"] LLM -.-> TS

LLM Observability is trace-first. Confirm LLM Explorer feature-flag availability before committing UI views to a customer, and make sure the service already exports traces with stable service.name, service.version, span metrics, and trace-correlated logs before starting.

Warning

Evolving GenAI conventions: OpenTelemetry GenAI, OpenLLMetry, and OpenInference emit different field variants. Pin instrumentation versions, preserve source attributes, and normalize deliberately instead of chasing convention drafts with ad-hoc renames.

Before starting

  • Scope: agree on the application, customer journey, model providers, environments, and owners.
  • Data policy first: prompts, completions, retrieved docs, and tool payloads can carry PII, secrets, or regulated data. Lock capture rules before enabling content.
  • Resource identity: keep service.name, service.version, and deployment.environment.name consistent across traces, logs, and metrics alongside K8s/host/cloud context.
  • Workflow shape: classify each flow (direct chat, RAG, tool-using agent, or async batch) and note which library emits its telemetry.

Level 1 - Choose instrumentation and normalize deliberately

Prefer supported provider or framework instrumentation (OpenTelemetry GenAI, OpenLLMetry, or OpenInference) over hand-written model spans. Verify one benign sample trace carries the normalized fields Tsuga expects:

  • Provider & model: gen_ai.provider.name, gen_ai.request.model, and gen_ai.response.model (when returned).
  • Operation & tokens: gen_ai.operation.name, gen_ai.usage.input_tokens, and gen_ai.usage.output_tokens.
  • Errors: span status ERROR plus low-cardinality error.type.
  • Permitted content only: gen_ai.system_instructions, gen_ai.input.messages, and gen_ai.output.messages only when policy approves.

If normalizing OpenLLMetry or OpenInference in the Collector (for example evaluating genainormalizerprocessor), keep original source attributes intact and verify Collector version support before rollout.

Exit criteria: One representative trace renders as an LLM workflow in Tsuga with provider, model, operation, and token fields populated, mapping documented, and source attributes preserved.

Level 2 - Trace the customer request and model call

Keep the user-facing application request span as the parent of every model-provider client span so route, auth, and downstream calls stay connected. Avoid adding duplicate manual spans when an integration already emits the provider span.

For streamed responses, measure time to first token/chunk separately from total completion duration, and keep cancellations, timeouts, and hidden retries visible.

Exit criteria: Opening one user request trace shows its route/workflow, child model call(s), duration, streaming wait where applicable, and actionable provider error/timeout signals.

Level 3 - Capture bounded model identity and token usage

Use spans for single-request inspection and metrics for aggregate latency, errors, requests, tokens, and estimated cost. Restrict metric dimensions to provider, model, operation, environment, and a small fixed workflow vocabulary (support_answer, document_summary, product_search). Never put user IDs, conversation IDs, free-form assistant names, prompt templates, or trace IDs on metric attributes.

Exit criteria: Model calls group cleanly by provider, requested/served model, operation, and fixed workflow; input/output tokens appear on success and failure paths; and zero unbounded IDs exist on metrics.

Level 4 - Add policy-safe prompt and response visibility

Enable prompt, completion, system-instruction, or tool content only after written agreement on allowed fields, retention, and reader access. Default to the safest option that solves the investigation need:

  • Metadata only: no content captured; keep model, tokens, status, and workflow.
  • Template/policy IDs: log immutable prompt-template or policy versions instead of raw text.
  • Allowlisted redacted capture: redacted/truncated content only on non-sensitive environments or approved workflows.
  • Defense in depth: hash or strip secrets at the application source first, then backstop with Collector redaction or Tsuga’s Sensitive Data Scanner.

Exit criteria: Documented capture policy with retention owner, plus a passing test showing benign context arrives while a deliberately sensitive test token is absent from spans, logs, and metrics.

Level 5 - Instrument retrieval-augmented generation (RAG)

Place retrieval spans between the request and consuming model call (covering query preparation, vector/search store call, optional reranking, and selected-document count) so bad retrieval is never blamed on the model.

Record only a bounded source collection or approved collection ID on metrics; keep raw queries, documents, tenant IDs, and unique document IDs off metric dimensions. Track retrieval latency, errors, empty-result rate, and result-count distribution.

Exit criteria: Traces connect retrieval directly to its downstream model call, empty/failed/slow retrievals are distinguishable, and document/query text obeys the capture policy.

Level 6 - Trace agent decisions and tool execution

Represent tool workflows as request → model decision → tool execution span → optional follow-up model call → response, using spans for duration-bearing tool calls and structured logs or span events for point-in-time decisions.

Tag spans with stable tool names and bounded categories, keep arguments/results governed by the capture policy and off metric dimensions, and propagate trace context across queues and workers while keeping queue wait separate from execution duration.

Exit criteria: Every material tool call links to its model workflow, tool failures and timeouts pinpoint the failing tool rather than only the final model error, and async causality stays intact.

Level 7 - Operationalize quality, cost, and response

Monitor five core signals (using span-derived metrics where traces cover the operation): request success/latency, model errors/duration, token volume by provider/model/workflow, RAG empty-result/error rate, and tool failure rate.

Treat dollar cost as a labeled estimate unless fed by provider billing data: join token volume against a versioned external price table and update it whenever models or rates change. Alert only on actionable conditions (sustained provider errors, UX-breaking latency, empty-retrieval spikes, blocking tool failures, or sudden workflow token jumps), each paired with an owner, runbook, and tested notification route.

Exit criteria: On-call can separate model, retrieval, tool, and app failures, explain token-spend shifts without exposing prohibited content, and act on owned alerts from traces, logs, and infra views.

Troubleshooting path

Start from one known customer request:

SymptomCheck firstFix
Spans exist, missing from LLM Explorergen_ai.provider.name and field schema variantFinish Level 1 normalization without dropping source fields
Model call detached from user requestParent span context propagationEnsure app request span wraps provider SDK call
High metric cardinality / cost spikeMetric attribute keysRemove user, conversation, prompt, or dynamic assistant IDs
Sensitive test token appears in logs/spansSource capture config before Collector rulesSuppress at application source first, then re-run negative test
Async tool/worker spans disconnectedQueue/worker W3C context propagationPropagate and restore trace context across worker boundaries

Completion criterion and CLI validation

From one customer request in Tsuga, an investigator reads the serving provider/model, token usage, outcome, retrieval calls, tool calls, and exact failure point, with zero prohibited content in spans, logs, or metric attributes.

# 1. Confirm normalized model-call spans arrived
tsuga traces search \
  --query "context.service.name:<service> gen_ai.provider.name:<provider>" \
  --from -15m \
  --to now \
  --max-results 10

# 2. Negative test: must return zero rows for a known sensitive token
tsuga logs search \
  --query "context.service.name:<service> <known-sensitive-test-value>" \
  --from -15m \
  --to now \
  --max-results 10

If command 1 returns nothing while service traces exist, the SDK is emitting a different GenAI convention variant and Level 1 normalization is incomplete. If command 2 returns any row, suppress the sensitive value at the source and re-test before calling Level 4 complete.

References

Written by

Nicolas Narbais

Nicolas Narbais builds, breaks, debugs, and scales observability systems using OpenTelemetry and modern telemetry pipelines. He shares practical, opinionated lessons to help engineers get better signal with less noise.

Olatuak Editorial Philosophy

Better signal, not more telemetry.

Olatuak helps platform engineers, SREs, and observability teams turn noisy telemetry into clear operational decisions without blindly collecting more data.

Scroll to zoom · Drag to pan · Double-click to reset