OpenTelemetry Semantic Conventions for Generative AI
Spring AI provides built-in instrumentation for models, tools, and agentic workflows based on the Micrometer APIs. Arconia lets you configure your Spring AI applications to export telemetry data adopting the OpenTelemetry Semantic Conventions for Generative AI instead of the default Micrometer conventions.
|
The OpenTelemetry Semantic Conventions for Generative AI are still in development, and they might change in the future. |
Getting Started
Add the Arconia OpenTelemetry AI Semantic Conventions dependency to your project. The conventions auto-activate for Spring AI applications.
-
Gradle
-
Maven
dependencies {
implementation 'io.arconia:arconia-opentelemetry-ai-semantic-conventions'
}
<dependency>
<groupId>io.arconia</groupId>
<artifactId>arconia-opentelemetry-ai-semantic-conventions</artifactId>
</dependency>
|
If another generative AI conventions module is also active, Arconia fails at startup with an error explaining what to do. Set |
Your application also needs OpenTelemetry configured to export telemetry data, using either the Arconia OpenTelemetry Spring Boot Starter or the Spring Boot OpenTelemetry support (spring-boot-starter-opentelemetry). The recommended approach is the Arconia OpenTelemetry Spring Boot Starter:
-
Gradle
-
Maven
dependencies {
implementation 'io.arconia:arconia-opentelemetry-spring-boot-starter'
}
<dependency>
<groupId>io.arconia</groupId>
<artifactId>arconia-opentelemetry-spring-boot-starter</artifactId>
</dependency>
The module supports multiple convention flavors. The default opentelemetry flavor targets standard OpenTelemetry-compatible backends. For platform-specific setup using alternative conventions, refer to the dedicated pages: OpenLIT Semantic Conventions, OpenLLMetry Semantic Conventions, LangSmith Semantic Conventions, and Langfuse Semantic Conventions.
Backends
The telemetry follows the OpenTelemetry Semantic Conventions, so any backend supporting them can display it. During development and testing, the Grafana LGTM Dev Service provides a backend with no configuration, including a GenAI dashboard for the model calls, the token usage, and the tool executions.
Arize Phoenix accepts these conventions too, with a few differences from the OpenInference ones it’s built for (see Arize Phoenix with the OpenTelemetry Conventions). For the other platforms, choose their flavor (see Choosing the Conventions).
Features
-
Chat model spans, with the model, its parameters, and the token usage.
-
Embedding model spans, with the model, the number of dimensions, and the token usage.
-
Image model spans, with the model, the image parameters, and the token usage.
-
Decision model spans, with the model and the token usage.
-
Text-to-speech model spans, with the model, the voice, the audio format, the speed, and the token usage.
-
Transcription model spans, with the model and the token usage.
-
Tool execution spans.
-
Advisor spans.
-
Chat client spans, recorded as agent invocations. The conversation ID of the chat memory is recorded on them and on the spans nested in them.
-
Operation duration metrics for chat, embedding, image, decision, text-to-speech, and transcription model calls.
-
Token usage metrics.
-
Input and output message content, including the reasoning of the model, captured as span attributes, span events, or log events.
Model calls, embeddings, tool executions, and chat client calls ending in an error get the error.type attribute from the error conventions of the OpenTelemetry Semantic Conventions module. The Arconia OpenTelemetry Spring Boot Starter includes the module. With the Spring Boot OpenTelemetry support, add it to your project. The module sets management.observations.conventions to open-telemetry by default. If you set it to micrometer, these spans don’t get error.type.
Attributes From Provider Options
Some attributes the conventions define for every provider aren’t in the generic Spring AI options, but only in the options of specific providers. When the Spring AI module of one of these providers is on the classpath, those attributes are read from its options.
| Attribute | Model Calls | Providers |
|---|---|---|
|
Chat |
OpenAI (Chat Completions API), Mistral AI, Ollama |
|
Chat |
OpenAI (Chat Completions API), Mistral AI, Google GenAI |
|
Chat, when asking for JSON output without a schema or for speech output |
OpenAI, Mistral AI, Google GenAI. Speech output: OpenAI (Chat Completions API) |
|
Embedding |
OpenAI, Mistral AI |
|
Transcription |
OpenAI |
Token Usage From Providers
Some token counts aren’t in the generic Spring AI usage, but only in the usage reported by specific providers. When the Spring AI module of one of these providers is on the classpath, those counts are read from its usage.
| Attribute | Model Calls | Providers |
|---|---|---|
|
Chat, decision |
OpenAI. Google GenAI, for chat calls with |
|
Transcription |
OpenAI, for the models reporting the usage in tokens, such as |
As the conventions require, the output tokens include the reasoning tokens. Google GenAI reports them apart, so for its chat calls they’re added to the output tokens, on both the spans and the gen_ai.client.token.usage metric.
Provider-Specific Attributes
Some attributes belong to a single provider and are recorded under its own namespace. They’re read from the options of the provider when its Spring AI module is on the classpath.
| Attribute | Model Calls | Providers |
|---|---|---|
|
Chat, with the |
OpenAI |
|
Chat, when the request asks for a service tier other than |
OpenAI |
The openai.response.service_tier and openai.response.system_fingerprint attributes aren’t recorded, since Spring AI doesn’t expose them.
Content Capturing
Model calls and tool executions can carry sensitive data, so capturing their content is opt-in. The capture-content property turns it on and decides where the content is recorded:
-
span-attributes: as attributes of the model call and tool execution spans. -
log-events: in agen_ai.client.inference.operation.detailsevent exported through the OpenTelemetry Logs API, as defined by the OpenTelemetry Semantic Conventions. The event has theDEBUGseverity the conventions recommend, so pipelines that drop debug logs drop it too. It carries the attributes of the model call span and the content in structured form, and it’s correlated with the span. It’s exported together with the other application logs, whether OpenTelemetry is configured by the Arconia OpenTelemetry Spring Boot Starter or by the Spring Boot OpenTelemetry support. -
span-events: in agen_ai.client.inference.operation.detailsevent attached to the model call span, which some backends display alongside the trace.
You can list several destinations, separated by commas, to record the content in each of them. An empty value, the default, turns capturing off.
-
YAML
-
Properties
arconia:
observations:
conventions:
opentelemetry:
ai:
capture-content: span-attributes
arconia.observations.conventions.opentelemetry.ai.capture-content=span-attributes
|
The captured content, such as prompts, completions, tool arguments and results, and tool definitions, can contain personal or confidential data. Review what your application sends to the models before exporting the telemetry to a shared backend, and turn the capturing off where that data must not leave the application. |
The parts of each message are recorded in the order the model produced them: text, reasoning, tool calls, and media. Reasoning is recorded as a reasoning part with its full text, or with its summary when the model returns only that.
Binary media in messages, such as images sent as bytes or as base64 data URIs, is recorded inline as base64 only when the encoded content is at most 32000 characters long. Larger media is left out, so that the size of spans and events stays bounded. Media referenced by URL is always recorded as a URI part.
The prompt of an image model, with any image sent along to edit, and the text read out by a text-to-speech model are recorded as input messages, and the transcript returned by a transcription model as an output message. The generated images and the audio aren’t recorded. The conventions define the gen_ai.client.inference.operation.details event for inference operations only, so this content is recorded only with the span-attributes destination.
The arguments and result of tool executions, and the input and output messages of a chat client call, are recorded only with the span-attributes destination, as attributes of the tool execution and agent invocation spans, since the conventions define no event for them.
Histograms
The gen_ai.client.operation.duration and gen_ai.client.token.usage metrics are histograms, whose buckets are not published by default. To enable them with the bucket boundaries advised by the conventions, or with exponential histograms, follow the steps in Histograms.
| Metric | Advised Bucket Boundaries |
|---|---|
|
|
|
|
Known Deviations
The Spring AI observations currently deviate from the OpenTelemetry Semantic Conventions for Generative AI in the following ways:
-
Model call spans have the
INTERNALspan kind instead ofCLIENT, since the Spring AI observations don’t describe them as calls to a remote service. -
Image, decision, text-to-speech, and transcription model calls have no operation in the conventions, so
gen_ai.operation.namekeeps the Spring AI names:image,decision,text_to_speech, andtranscription. Text-to-speech calls also keep thegen_ai.request.audio.voice,gen_ai.request.audio.response_format, andgen_ai.request.audio.speedattributes of Spring AI, which have no counterpart in the conventions. -
The
server.addressandserver.portattributes are not recorded, since the Spring AI observations don’t expose the endpoint of the model provider. -
System instructions are recorded in
gen_ai.input.messagesas messages with thesystemrole, also for model providers that accept them separately from the chat history, such as Anthropic and Google Gemini, for which the conventions recommend thegen_ai.system_instructionsattribute. -
Attribute values are always strings, also for attributes defined as numbers or arrays, such as
gen_ai.usage.input_tokensandgen_ai.request.stop_sequences(micrometer#7433).
The deviations that come from Micrometer and apply to all the observations are listed in Known Deviations.
Configuration Properties
| Property | Default | Description |
|---|---|---|
|
|
Whether to enable the OpenTelemetry AI Semantic Conventions module. |
|
|
The convention flavor to apply. Accepted values: |
|
Empty |
Where to record the content of model calls and tool executions, such as messages, tool definitions, and tool arguments and results. An empty value turns capturing off. Accepted values: |