LinkMesh

Search docs, blog and changelog

ENDE
LinkMeshObservability Data Collection Management
OpenTelemetryCompliance

LLM Prompts in Telemetry

Switch content capture off at the source. Enforce it at the collector.

linkmesh.io
Philippe BraxmeierPhilippe Braxmeier← Back to blog
8 min read

An LLM feature goes live, and the platform team is asked for “LLM observability”: which model was called, how long it took, how many tokens it used. A few weeks later the trace backend also holds what users typed into the assistant. Names, account numbers, a diagnosis, a paragraph from a contract. Nobody decided that. A library default did.

This is the same problem as personal data in logs, with three differences that change the solution. The text sits in span attributes and events, not in log bodies. It is often a structured value, not a string. And it is free text, so a pattern for email addresses does not make it safe. This post shows where prompt text ends up, how to switch it off at the source, and how to enforce that decision at the OpenTelemetry Collector.

Who this guide is for

Platform and observability teams that run OpenTelemetry Collectors and have to onboard an application that calls a language model. Prerequisite: a collector sits between that application and your backend.

Where prompt text ends up

The OpenTelemetry GenAI semantic conventions describe how a model call becomes a span: the operation, the model, the token usage, the finish reason. None of that is user text. The conventions now live in their own repository. Its first release, v0.1.0, is dated 21 November 2026, and every part is still marked as in development, so names can change.

User text can be recorded in three places:

  • Span attributes. gen_ai.input.messages, gen_ai.output.messages and gen_ai.system_instructions hold the conversation. gen_ai.tool.call.arguments and gen_ai.tool.call.result hold what went into a tool and what came back. Retrieval queries, prompt template variables and memory records have attributes of their own.
  • Events. The same content can be written to the event gen_ai.client.inference.operation.details. An event travels through the collector as a log record, so it takes the logs pipeline, not the traces pipeline.
  • Attributes outside the conventions. Libraries that are older than the conventions use their own names and their own defaults. OpenLLMetry, for example, writes prompts, completions and embeddings to span attributes unless you switch that off, according to its privacy documentation.

A model call produces prompt text in three places: span attributes such as gen_ai.input.messages, events that travel as log records, and library-specific attributes. Two controls stop it: the capture switch in the application, which is off by default in the conventions, and an OpenTelemetry Collector that drops content attributes, masks patterns in string values or routes content to a restricted store inside the network. Only spans without content cross the network boundary to the shared backend.

Figure 1. One model call, three places for user text, two places to stop it.

Which of the three you have depends on the library and its version. Look at one real span and one real log record before you write a rule.

First control: do not capture what you do not need

The conventions make content capture opt-in. An instrumentation that follows them records no prompts and no answers until you set a switch. The switch has four values, so you also choose where the content goes:

Instrumentation Switch Without the switch
Follows the current conventions OTEL_INSTRUMENTATION_GENAI_CAPTURE_CONTENT set to NO_CONTENT, SPAN_ONLY, EVENT_ONLY or SPAN_AND_EVENT No content
Older OpenTelemetry packages, such as the Python OpenAI instrumentation OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT No content
OpenLLMetry TRACELOOP_TRACE_CONTENT=false Content is captured

The first two rows look alike and are not. The variable name changed between versions of the conventions, and a package reads the name it was written for. Check the README of the package version you deploy.

Without content you still get the model, the token counts, the duration, the finish reason and the error type. That answers most operational questions: cost per team, latency per model, error rate per provider. Content is what you need to debug a wrong answer or to run evaluations. For production, the conventions recommend a third pattern: store the content somewhere else and put only a reference on the span, in attributes such as gen_ai.input.messages_ref.

Second control: enforce it at the collector

An environment variable on every service is a convention. One team forgets it, one library ignores it, one debugging session turns content on and nobody turns it off. The collector is the point where a decision holds for everything that passes through, whatever the application did. There are three moves.

1. Drop the content attributes. If the shared backend must never hold prompts, delete the attributes on spans and on log records:

processors:
  transform/drop-genai-content:
    error_mode: ignore
    trace_statements:
      - context: span
        statements:
          - delete_matching_keys(attributes, "^gen_ai\\.(input|output)\\.messages$")
          - delete_matching_keys(attributes, "^gen_ai\\.tool\\.call\\.(arguments|result)$")
          - delete_key(attributes, "gen_ai.system_instructions")
    log_statements:
      - context: log
        statements:
          - delete_matching_keys(attributes, "^gen_ai\\.(input|output)\\.messages$")
          - delete_matching_keys(attributes, "^gen_ai\\.tool\\.call\\.(arguments|result)$")
          - delete_key(attributes, "gen_ai.system_instructions")

Add the names your library really uses. That is the reason to look at a real span first.

2. Mask patterns inside the text. This keeps the prompt and removes identifiers from it. It has a catch that is easy to miss. The conventions require the message attributes to be recorded as structured values: a list of messages, each with parts. The OTTL functions replace_pattern and replace_all_patterns change strings. Given a list, they do nothing. No error is raised and nothing is masked.

The redaction processor behaves the same way by default. With redact_all_types: true it also checks the text form of values that are not strings:

processors:
  redaction/genai:
    allow_all_keys: true
    redact_all_types: true
    blocked_values:
      - "[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*\\.[A-Za-z]{2,}"
      - "\\b[A-Z]{2}[0-9]{2}( ?[A-Z0-9]{4}){2,7}( ?[A-Z0-9]{1,3})?\\b"
    summary: info

Two things to know before you rely on it. A value the processor masks is written back as a string, so a backend that renders the message list may show it differently. And in contrib v0.165.0 the processor is rated beta for traces and alpha for logs.

3. Keep the content, and keep it inside. If developers need prompts to debug, capture them as events with EVENT_ONLY. Events are log records, so you can route them by attribute to a store inside your network with short retention and narrow access. The spans, now without content, go to the shared backend. The application does not change.

Validated collector configs for the general patterns are in the snippet library: drop attributes and a redaction allowlist.

What pattern masking cannot do

A detector finds what has a shape: an email address, a card number, an IBAN. A prompt is prose. A sentence about a relative’s illness or a client’s financing contains no pattern, and it is exactly what must not leave. For free text, the two reliable controls are the first and the third: do not capture it, or keep it inside. Masking is for the identifiers that slip into otherwise harmless prompts.

The same limit applies to client-identifying data in general. We describe it in PII vs CID: the detection gap.

Check the result, not the configuration

A rule that matches nothing looks the same as a rule that works. The pipeline is configured, the processor is in the chain, and nothing reports that it changed nothing. So test with data:

  1. Send a prompt that contains a marker you can search for, through the real application path.
  2. Search the backend for the marker, in traces and in logs.
  3. Make one call fail and search again. The conventions allow exception events to carry attributes copied from the span.
  4. Repeat after every upgrade of the instrumentation library. The conventions are in development, and attribute names have changed before.

Doing this across a fleet

One collector is one YAML file. An organisation that puts an assistant into several products has dozens of collectors, and the rule has to be on every one of them, in the same version, with a record that shows it.

LinkMesh is a self-hosted control plane for OpenTelemetry Collectors. You define the pipeline once and roll it out to collector groups over OpAMP. Three parts matter for this job:

  • The Transform (custom) processor takes the OTTL statements above as they are.
  • PII masking rules come from a maintained detector library and apply to log bodies and log attributes. Test them against a captured event before you rely on them for structured message attributes. See Mask PII.
  • The dry-run preview shows what a processor chain does to a sample before it reaches a collector. See preview a pipeline before you ship.

LinkMesh keeps a versioned record of the configuration each collector applied. It shows which collectors run the rule, and since when. Telemetry never flows through LinkMesh. Prompts go from your collectors to your backends and nowhere else.

Onboarding an LLM application?

LinkMesh is a self-hosted control plane for OpenTelemetry Collectors: build the pipeline once, preview what it does to real records and roll it out over OpAMP, with a versioned record of what each collector runs. Telemetry never flows through LinkMesh. See the features, or set one up in a few minutes.