OpenTelemetry GenAI Specification — Ban on Prompt Collection and Agent Tracing Standardization

Maru

@maru

OpenTelemetry GenAI 규격 — Prompt 수집 금지와 에이전트 추적 표준화

OpenTelemetry GenAI Specification — Ban on Prompt Collection and Agent Tracing Standardization

As backend systems leveraging AI agents and Large Language Models rapidly scale to production environments, transparently debugging complex asynchronous flows has emerged as a key challenge for development teams. While there previously were no standard specifications, leading to inconsistent tracing data, OpenTelemetry has recently completed standardization efforts by establishing dedicated semantic conventions. This article explores how the new OpenTelemetry specification addresses security design to prevent sensitive prompt leakage and handles the execution tracing of complex multi-agent environments.

Preventing Personal Data Leakage: Banning Raw Prompt Collection and Transitioning to Event Models

The new OpenTelemetry GenAI standard has fundamentally changed how data is collected to prevent personal information leakage. Storing raw user prompts or complete model responses as plain strings in span attributes, as was common practice, poses a critical security risk where sensitive personal information is left exposed in data stores or monitoring tools.

Consequently, the latest specification has officially deprecated the legacy gen_ai.prompt and gen_ai.completion attributes. Instead, it introduces standardized event formats such as gen_ai.input.messages and gen_ai.output.messages to manage prompts and message history more securely and systematically, making it easier to apply masking or filtering in monitoring pipelines.

Additionally, to improve consistency in infrastructure metadata, the widely used gen_ai.system attribute has been renamed to gen_ai.provider.name to clearly distinguish LLM providers. These changes help preemptively mitigate privacy risks while maintaining high-quality analytical data.

Agent Behavior Tracing: Introducing invoke_agent and execute_tool Standards

As multi-step architectures where AI agents navigate complex business logic and external tools become the norm, traditional single-model call tracing is no longer sufficient to grasp the entire execution flow. In agent systems where multiple asynchronous tasks are intertwined, a tracing framework that transparently debugs when each tool is executed and what result it returns is essential.

To address this, the latest OpenTelemetry specification standardizes invoke_agent spans to represent the execution flow of the agent core, and execute_tool spans to detect the execution of individual external functions. The invoke_agent span acts as a parent that encapsulates the entire agent loop, while various external tool calls executed within it are linked as child execute_tool spans, allowing for the visualization of complex asynchronous tasks within a single hierarchical trace flow.

This standard span specification is particularly powerful in Model Context Protocol (MCP) environments, which are becoming widely used. Even when dynamically calling various tools in conjunction with distributed MCP servers, the context data provided by the standard specification is propagated seamlessly. Developers can perfectly trace agent behavior within a single, organic distributed trace flow without writing separate custom tracing code.

Fastify Implementation: Integration and Propagation Guide for @fastify/otel

You can also fully benefit from the latest observability standards when building high-performance servers in Node.js with Fastify. The previously popular instrumentation library for Fastify has been officially deprecated. Instead, you should use @fastify/otel, the official plugin managed directly by the Fastify foundation. This official plugin securely integrates with the framework's lifecycle hooks to handle distributed tracing without unnecessary overhead.

Once the official plugin is registered, you can invoke the request.openTelemetry() method directly within route handlers. This method returns an object containing context information for the request, including the span, tracer, and context necessary to link top-level HTTP traces. This allows for seamlessly connecting downstream Large Language Model calls or agent tracing spans to the parent trace.

Below is an example code using @fastify/otel to extract context and generate sub-spans within a request lifecycle.

typescript
import Fastify from 'fastify';
import fastifyOtel from '@fastify/otel';

const fastify = Fastify();
await fastify.register(fastifyOtel);

fastify.get('/agent', async (request, reply) => {
  // 요청 생명주기에서 span, tracer, context 직접 추출
  const { span, tracer, context } = request.openTelemetry();
  
  // 다운스트림 에이전트 스팬에 부모 컨텍스트를 연결하여 시작
  const agentSpan = tracer.startSpan('invoke_agent', undefined, context);
  
  // 비즈니스 로직 및 에이전트 작업 수행...
  agentSpan.end();
  
  return { status: 'success' };
});

One point to note when implementing this in production: many AI SDKs in the Node.js ecosystem do not yet fully support type helpers that automatically bind results according to the new OpenTelemetry GenAI specification. Therefore, you will need to manually write integration code to map token usage or response events obtained via clients to the standardized span attributes.

Future-Oriented AI Observability Ensuring Security and Interoperability

AI service observability is evolving beyond simple log collection toward sophisticated distributed tracing that tracks the causal relationships of complex systems. To clearly grasp the flow of multi-step agents while completely preventing the exposure of raw prompts—which carries high security risks—following the OpenTelemetry GenAI specification is the safest and most rational choice.

Now is the time to check if raw text is being collected in the logs of your running backend pipelines. I encourage you to adopt a distributed tracing framework that complies with official standards to ensure both robust security and flexible interoperability.


Reference Links