diff --git a/.chloggen/1924.yaml b/.chloggen/1924.yaml index aef1c47cdd..e44985fe29 100644 --- a/.chloggen/1924.yaml +++ b/.chloggen/1924.yaml @@ -10,11 +10,11 @@ change_type: bug_fix component: gen-ai # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Removed irrelevant attributes on GenAI create agent span. +note: Removed irrelevant response attributes on GenAI create agent span. # Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. # The values here must be integers. -issues: [1924] +issues: [1924, 2116] # (Optional) One or more lines of additional information to render under the primary note. # These lines will be padded with 2 spaces and then inserted directly into the document. diff --git a/.chloggen/2122.yaml b/.chloggen/2122.yaml new file mode 100644 index 0000000000..94b4d99dcc --- /dev/null +++ b/.chloggen/2122.yaml @@ -0,0 +1,4 @@ +change_type: enhancement +component: gen-ai +note: Separate inference and embeddings span definitions, remove irrelevant attributes from the create agent span. +issues: [1924, 2122] diff --git a/docs/gen-ai/README.md b/docs/gen-ai/README.md index eb3c63cbef..08b547fa4a 100644 --- a/docs/gen-ai/README.md +++ b/docs/gen-ai/README.md @@ -6,16 +6,17 @@ linkTitle: Generative AI **Status**: [Development][DocumentStatus] -**Warning**: -The semantic conventions for GenAI and LLM are currently in development. -We encourage instrumentation libraries and telemetry consumers developers to -use the conventions in limited non-critical workloads and share the feedback +> [!Warning] +> The semantic conventions for GenAI and LLM are currently in development. +> We encourage instrumentation libraries and telemetry consumers developers to +> use the conventions in limited non-critical workloads and share the feedback Semantic conventions for Generative AI operations are defined for the following signals: * [Events](gen-ai-events.md): Semantic Conventions for Generative AI inputs and outputs - *events*. * [Metrics](gen-ai-metrics.md): Semantic Conventions for Generative AI operations - *metrics*. -* [Spans](gen-ai-spans.md): Semantic Conventions for Generative AI requests - *spans*. +* [Model spans](gen-ai-spans.md): Semantic Conventions for Generative AI model operations - *spans*. +* [Agent spans](gen-ai-agent-spans.md): Semantic Conventions for Generative AI agent operations - *spans*. Technology specific semantic conventions are defined for the following GenAI system: diff --git a/docs/gen-ai/azure-ai-inference.md b/docs/gen-ai/azure-ai-inference.md index b36a1e04cd..552e7469a2 100644 --- a/docs/gen-ai/azure-ai-inference.md +++ b/docs/gen-ai/azure-ai-inference.md @@ -10,6 +10,8 @@ The Semantic Conventions for [Azure AI Inference](https://learn.microsoft.com/az ## Spans +### Inference + @@ -40,7 +42,6 @@ model name is available and `{gen_ai.operation.name}` otherwise. | [`gen_ai.request.seed`](/docs/attributes-registry/gen-ai.md) | int | Requests with same seed value more likely to return same result. | `100` | `Conditionally Required` if applicable and if the request includes a seed | ![Development](https://img.shields.io/badge/-development-blue) | | [`server.port`](/docs/attributes-registry/server.md) | int | GenAI server port. [6] | `80`; `8080`; `443` | `Conditionally Required` If not default (443). | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`az.namespace`](/docs/attributes-registry/azure.md) | string | [Azure Resource Provider Namespace](https://learn.microsoft.com/azure/azure-resource-manager/management/azure-services-resource-providers) as recognized by the client. [7] | `Microsoft.CognitiveServices` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.encoding_formats`](/docs/attributes-registry/gen-ai.md) | string[] | The encoding formats requested in an embeddings operation, if specified. [8] | `["base64"]`; `["float", "binary"]` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.frequency_penalty`](/docs/attributes-registry/gen-ai.md) | double | The frequency penalty setting for the GenAI request. | `0.1` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.max_tokens`](/docs/attributes-registry/gen-ai.md) | int | The maximum number of tokens the model generates for a request. | `100` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.presence_penalty`](/docs/attributes-registry/gen-ai.md) | double | The presence penalty setting for the GenAI request. | `0.1` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | @@ -49,10 +50,10 @@ model name is available and `{gen_ai.operation.name}` otherwise. | [`gen_ai.request.top_p`](/docs/attributes-registry/gen-ai.md) | double | The top_p sampling setting for the GenAI request. | `1.0` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.response.finish_reasons`](/docs/attributes-registry/gen-ai.md) | string[] | Array of reasons the model stopped generating tokens, corresponding to each generation received. | `["stop"]`; `["stop", "length"]` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.response.id`](/docs/attributes-registry/gen-ai.md) | string | The unique identifier for the completion. | `chatcmpl-123` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.response.model`](/docs/attributes-registry/gen-ai.md) | string | The name of the model that generated the response. [9] | `gpt-4-0613` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | +| [`gen_ai.response.model`](/docs/attributes-registry/gen-ai.md) | string | The name of the model that generated the response. [8] | `gpt-4-0613` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.usage.input_tokens`](/docs/attributes-registry/gen-ai.md) | int | The number of prompt tokens as reported in the usage prompt_tokens property of the response. | `100` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.usage.output_tokens`](/docs/attributes-registry/gen-ai.md) | int | The number of completion tokens as reported in the usage completion_tokens property of the response. | `180` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`server.address`](/docs/attributes-registry/server.md) | string | GenAI server address. [10] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](/docs/attributes-registry/server.md) | string | GenAI server address. [9] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1] `gen_ai.operation.name`:** If one of the predefined values applies, but specific system uses a different name it's RECOMMENDED to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries SHOULD use applicable predefined value. @@ -60,9 +61,18 @@ model name is available and `{gen_ai.operation.name}` otherwise. the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. -**[3] `gen_ai.output.type`:** This attribute SHOULD be set to the output type requested by the client: - `json` for structured outputs with defined or undefined schema - `image` for image output - `speech` for speech output - `text` for plain text output -The attribute specifies the output modality and not the actual output format. For example, if an image is requested, the actual output could be a URL pointing to an image file. -Additional output format details may be recorded in the future in the `gen_ai.output.{type}.*` attributes. +**[3] `gen_ai.output.type`:** This attribute SHOULD be set to the output type requested by the client: +- `json` for structured outputs with defined or undefined schema +- `image` for image output +- `speech` for speech output +- `text` for plain text output + +The attribute specifies the output modality and not the actual output format. +For example, if an image is requested, the actual output could be a +URL pointing to an image file. + +Additional output format details may be recorded in the future in the +`gen_ai.output.{type}.*` attributes. **[4] `gen_ai.output.type`:** when applicable and if the request includes an output format. @@ -72,11 +82,9 @@ Additional output format details may be recorded in the future in the `gen_ai.ou **[7] `az.namespace`:** When `az.namespace` attribute is populated, it MUST be set to `Microsoft.CognitiveServices` for all operations performed by Azure AI Inference clients. -**[8] `gen_ai.request.encoding_formats`:** In some GenAI systems the encoding formats are called embedding types. Also, some GenAI systems only accept a single format per request. +**[8] `gen_ai.response.model`:** If available. The name of the GenAI model that provided the response. If the model is supplied by a vendor, then the value must be the exact name of the model actually used. If the model is a fine-tuned custom model, the value should have a more specific name than the base model that's been fine-tuned. -**[9] `gen_ai.response.model`:** If available. The name of the GenAI model that provided the response. If the model is supplied by a vendor, then the value must be the exact name of the model actually used. If the model is a fine-tuned custom model, the value should have a more specific name than the base model that's been fine-tuned. - -**[10] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. +**[9] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. --- @@ -115,7 +123,11 @@ Additional output format details may be recorded in the future in the `gen_ai.ou -## Azure AI Inference metrics +### Embedding + +See [common embedding span definition](./gen-ai-spans.md#embeddings). + +## Metrics Azure AI Inference metrics follow generic [Generative AI metrics](gen-ai-metrics.md). diff --git a/docs/gen-ai/gen-ai-agent-spans.md b/docs/gen-ai/gen-ai-agent-spans.md index b20d3a0259..4c7cc5e678 100644 --- a/docs/gen-ai/gen-ai-agent-spans.md +++ b/docs/gen-ai/gen-ai-agent-spans.md @@ -1,5 +1,5 @@ # Semantic Conventions for GenAI agent and framework spans @@ -56,18 +56,9 @@ Semantic conventions for individual GenAI systems and frameworks MAY specify dif | [`gen_ai.agent.description`](/docs/attributes-registry/gen-ai.md) | string | Free-form description of the GenAI agent provided by the application. | `Helps with math problems`; `Generates fiction stories` | `Conditionally Required` If provided by the application. | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.agent.id`](/docs/attributes-registry/gen-ai.md) | string | The unique identifier of the GenAI agent. | `asst_5j66UpCpwteGg4YSxUnt7lPY` | `Conditionally Required` if applicable. | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.agent.name`](/docs/attributes-registry/gen-ai.md) | string | Human-readable name of the GenAI agent provided by the application. | `Math Tutor`; `Fiction Writer` | `Conditionally Required` If provided by the application. | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.choice.count`](/docs/attributes-registry/gen-ai.md) | int | The target number of candidate completions to return. | `3` | `Conditionally Required` if available, in the request, and !=1 | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.model`](/docs/attributes-registry/gen-ai.md) | string | The name of the GenAI model a request is being made to. [4] | `gpt-4` | `Conditionally Required` If available. | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.seed`](/docs/attributes-registry/gen-ai.md) | int | Requests with same seed value more likely to return same result. | `100` | `Conditionally Required` if applicable and if the request includes a seed | ![Development](https://img.shields.io/badge/-development-blue) | | [`server.port`](/docs/attributes-registry/server.md) | int | GenAI server port. [5] | `80`; `8080`; `443` | `Conditionally Required` If `server.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`gen_ai.request.encoding_formats`](/docs/attributes-registry/gen-ai.md) | string[] | The encoding formats requested in an embeddings operation, if specified. [6] | `["base64"]`; `["float", "binary"]` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.frequency_penalty`](/docs/attributes-registry/gen-ai.md) | double | The frequency penalty setting for the GenAI request. | `0.1` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.max_tokens`](/docs/attributes-registry/gen-ai.md) | int | The maximum number of tokens the model generates for a request. | `100` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.presence_penalty`](/docs/attributes-registry/gen-ai.md) | double | The presence penalty setting for the GenAI request. | `0.1` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.stop_sequences`](/docs/attributes-registry/gen-ai.md) | string[] | List of sequences that the model will use to stop generating further tokens. | `["forest", "lived"]` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.temperature`](/docs/attributes-registry/gen-ai.md) | double | The temperature setting for the GenAI request. | `0.0` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.top_p`](/docs/attributes-registry/gen-ai.md) | double | The top_p sampling setting for the GenAI request. | `1.0` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`server.address`](/docs/attributes-registry/server.md) | string | GenAI server address. [7] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](/docs/attributes-registry/server.md) | string | GenAI server address. [6] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1] `gen_ai.operation.name`:** If one of the predefined values applies, but specific system uses a different name it's RECOMMENDED to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries SHOULD use applicable predefined value. @@ -91,9 +82,7 @@ Instrumentations SHOULD document the list of errors they report. **[5] `server.port`:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[6] `gen_ai.request.encoding_formats`:** In some GenAI systems the encoding formats are called embedding types. Also, some GenAI systems only accept a single format per request. - -**[7] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. +**[6] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. --- @@ -128,9 +117,9 @@ Instrumentations SHOULD document the list of errors they report. | `az.ai.openai` | Azure OpenAI | ![Development](https://img.shields.io/badge/-development-blue) | | `cohere` | Cohere | ![Development](https://img.shields.io/badge/-development-blue) | | `deepseek` | DeepSeek | ![Development](https://img.shields.io/badge/-development-blue) | -| `gcp.gemini` | Gemini [8] | ![Development](https://img.shields.io/badge/-development-blue) | -| `gcp.gen_ai` | Any Google generative AI endpoint [9] | ![Development](https://img.shields.io/badge/-development-blue) | -| `gcp.vertex_ai` | Vertex AI [10] | ![Development](https://img.shields.io/badge/-development-blue) | +| `gcp.gemini` | Gemini [7] | ![Development](https://img.shields.io/badge/-development-blue) | +| `gcp.gen_ai` | Any Google generative AI endpoint [8] | ![Development](https://img.shields.io/badge/-development-blue) | +| `gcp.vertex_ai` | Vertex AI [9] | ![Development](https://img.shields.io/badge/-development-blue) | | `groq` | Groq | ![Development](https://img.shields.io/badge/-development-blue) | | `ibm.watsonx.ai` | IBM Watsonx AI | ![Development](https://img.shields.io/badge/-development-blue) | | `mistral_ai` | Mistral AI | ![Development](https://img.shields.io/badge/-development-blue) | @@ -138,11 +127,11 @@ Instrumentations SHOULD document the list of errors they report. | `perplexity` | Perplexity | ![Development](https://img.shields.io/badge/-development-blue) | | `xai` | xAI | ![Development](https://img.shields.io/badge/-development-blue) | -**[8]:** This refers to the 'generativelanguage.googleapis.com' endpoint. Also known as the AI Studio API. May use common attributes prefixed with 'gcp.gen_ai.'. +**[7]:** This refers to the 'generativelanguage.googleapis.com' endpoint. Also known as the AI Studio API. May use common attributes prefixed with 'gcp.gen_ai.'. -**[9]:** May be used when specific backend is unknown. May use common attributes prefixed with 'gcp.gen_ai.'. +**[8]:** May be used when specific backend is unknown. May use common attributes prefixed with 'gcp.gen_ai.'. -**[10]:** This refers to the 'aiplatform.googleapis.com' endpoint. May use common attributes prefixed with 'gcp.gen_ai.'. +**[9]:** This refers to the 'aiplatform.googleapis.com' endpoint. May use common attributes prefixed with 'gcp.gen_ai.'. diff --git a/docs/gen-ai/gen-ai-spans.md b/docs/gen-ai/gen-ai-spans.md index 8b3ae9d9fe..b0f18ea515 100644 --- a/docs/gen-ai/gen-ai-spans.md +++ b/docs/gen-ai/gen-ai-spans.md @@ -9,26 +9,18 @@ linkTitle: Spans - [Spans](#spans) - - [GenAI span](#genai-span) - - [Execute Tool Span](#execute-tool-span) + - [Inference](#inference) + - [Embeddings](#embeddings) + - [Execute tool span](#execute-tool-span) - [Capturing inputs and outputs](#capturing-inputs-and-outputs) -A request to an Generative AI is modeled as a span in a trace. - ## Spans -### GenAI span - -The span contains input data and metadata for a request to a GenAI model. -Each attribute represents a concept that is common to most Generative AI clients. -Many of these attributes only apply to specific GenAI operations. +### Inference -For example, GenAI embeddings requests don't use output tokens, -so `gen_ai.usage.output_tokens` does not apply to embeddings operations. - - + @@ -37,7 +29,7 @@ so `gen_ai.usage.output_tokens` does not apply to embeddings operations. **Status:** ![Development](https://img.shields.io/badge/-development-blue) -This span represents a client call to Generative AI model or service. +This span represents a client call to Generative AI model or service that generates a response or requests a tool call based on the input prompt. **Span name** SHOULD be `{gen_ai.operation.name} {gen_ai.request.model}`. Semantic conventions for individual GenAI systems and frameworks MAY specify different span name format @@ -60,7 +52,6 @@ client or when the GenAI call happens over instrumented protocol such as HTTP. | [`gen_ai.request.model`](/docs/attributes-registry/gen-ai.md) | string | The name of the GenAI model a request is being made to. [6] | `gpt-4` | `Conditionally Required` If available. | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.seed`](/docs/attributes-registry/gen-ai.md) | int | Requests with same seed value more likely to return same result. | `100` | `Conditionally Required` if applicable and if the request includes a seed | ![Development](https://img.shields.io/badge/-development-blue) | | [`server.port`](/docs/attributes-registry/server.md) | int | GenAI server port. [7] | `80`; `8080`; `443` | `Conditionally Required` If `server.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | -| [`gen_ai.request.encoding_formats`](/docs/attributes-registry/gen-ai.md) | string[] | The encoding formats requested in an embeddings operation, if specified. [8] | `["base64"]`; `["float", "binary"]` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.frequency_penalty`](/docs/attributes-registry/gen-ai.md) | double | The frequency penalty setting for the GenAI request. | `0.1` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.max_tokens`](/docs/attributes-registry/gen-ai.md) | int | The maximum number of tokens the model generates for a request. | `100` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.presence_penalty`](/docs/attributes-registry/gen-ai.md) | double | The presence penalty setting for the GenAI request. | `0.1` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | @@ -70,10 +61,10 @@ client or when the GenAI call happens over instrumented protocol such as HTTP. | [`gen_ai.request.top_p`](/docs/attributes-registry/gen-ai.md) | double | The top_p sampling setting for the GenAI request. | `1.0` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.response.finish_reasons`](/docs/attributes-registry/gen-ai.md) | string[] | Array of reasons the model stopped generating tokens, corresponding to each generation received. | `["stop"]`; `["stop", "length"]` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.response.id`](/docs/attributes-registry/gen-ai.md) | string | The unique identifier for the completion. | `chatcmpl-123` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.response.model`](/docs/attributes-registry/gen-ai.md) | string | The name of the model that generated the response. [9] | `gpt-4-0613` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | +| [`gen_ai.response.model`](/docs/attributes-registry/gen-ai.md) | string | The name of the model that generated the response. [8] | `gpt-4-0613` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.usage.input_tokens`](/docs/attributes-registry/gen-ai.md) | int | The number of tokens used in the GenAI input (prompt). | `100` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.usage.output_tokens`](/docs/attributes-registry/gen-ai.md) | int | The number of tokens used in the GenAI response (completion). | `180` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`server.address`](/docs/attributes-registry/server.md) | string | GenAI server address. [10] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](/docs/attributes-registry/server.md) | string | GenAI server address. [9] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1] `gen_ai.operation.name`:** If one of the predefined values applies, but specific system uses a different name it's RECOMMENDED to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries SHOULD use applicable predefined value. @@ -103,11 +94,9 @@ Additional output format details may be recorded in the future in the `gen_ai.ou **[7] `server.port`:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[8] `gen_ai.request.encoding_formats`:** In some GenAI systems the encoding formats are called embedding types. Also, some GenAI systems only accept a single format per request. - -**[9] `gen_ai.response.model`:** If available. The name of the GenAI model that provided the response. If the model is supplied by a vendor, then the value must be the exact name of the model actually used. If the model is a fine-tuned custom model, the value should have a more specific name than the base model that's been fine-tuned. +**[8] `gen_ai.response.model`:** If available. The name of the GenAI model that provided the response. If the model is supplied by a vendor, then the value must be the exact name of the model actually used. If the model is a fine-tuned custom model, the value should have a more specific name than the base model that's been fine-tuned. -**[10] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. +**[9] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. --- @@ -153,9 +142,9 @@ Additional output format details may be recorded in the future in the `gen_ai.ou | `az.ai.openai` | Azure OpenAI | ![Development](https://img.shields.io/badge/-development-blue) | | `cohere` | Cohere | ![Development](https://img.shields.io/badge/-development-blue) | | `deepseek` | DeepSeek | ![Development](https://img.shields.io/badge/-development-blue) | -| `gcp.gemini` | Gemini [11] | ![Development](https://img.shields.io/badge/-development-blue) | -| `gcp.gen_ai` | Any Google generative AI endpoint [12] | ![Development](https://img.shields.io/badge/-development-blue) | -| `gcp.vertex_ai` | Vertex AI [13] | ![Development](https://img.shields.io/badge/-development-blue) | +| `gcp.gemini` | Gemini [10] | ![Development](https://img.shields.io/badge/-development-blue) | +| `gcp.gen_ai` | Any Google generative AI endpoint [11] | ![Development](https://img.shields.io/badge/-development-blue) | +| `gcp.vertex_ai` | Vertex AI [12] | ![Development](https://img.shields.io/badge/-development-blue) | | `groq` | Groq | ![Development](https://img.shields.io/badge/-development-blue) | | `ibm.watsonx.ai` | IBM Watsonx AI | ![Development](https://img.shields.io/badge/-development-blue) | | `mistral_ai` | Mistral AI | ![Development](https://img.shields.io/badge/-development-blue) | @@ -163,18 +152,87 @@ Additional output format details may be recorded in the future in the `gen_ai.ou | `perplexity` | Perplexity | ![Development](https://img.shields.io/badge/-development-blue) | | `xai` | xAI | ![Development](https://img.shields.io/badge/-development-blue) | -**[11]:** This refers to the 'generativelanguage.googleapis.com' endpoint. Also known as the AI Studio API. May use common attributes prefixed with 'gcp.gen_ai.'. +**[10]:** This refers to the 'generativelanguage.googleapis.com' endpoint. Also known as the AI Studio API. May use common attributes prefixed with 'gcp.gen_ai.'. + +**[11]:** May be used when specific backend is unknown. May use common attributes prefixed with 'gcp.gen_ai.'. + +**[12]:** This refers to the 'aiplatform.googleapis.com' endpoint. May use common attributes prefixed with 'gcp.gen_ai.'. + + + + + + +### Embeddings + + + + + + + + +**Status:** ![Development](https://img.shields.io/badge/-development-blue) + +Describes GenAI embeddings span - a request to a Generative AI model or service that generates an embeddings based on the input. +The `gen_ai.operation.name` SHOULD be `embeddings`. +**Span name** SHOULD be `{gen_ai.operation.name} {gen_ai.request.model}`. + +**Span kind** SHOULD be `CLIENT`. + +**Span status** SHOULD follow the [Recording Errors](/docs/general/recording-errors.md) document. + +| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability | +|---|---|---|---|---|---| +| [`gen_ai.operation.name`](/docs/attributes-registry/gen-ai.md) | string | The name of the operation being performed. [1] | `chat`; `generate_content`; `text_completion` | `Required` | ![Development](https://img.shields.io/badge/-development-blue) | +| [`error.type`](/docs/attributes-registry/error.md) | string | Describes a class of error the operation ended with. [2] | `timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500` | `Conditionally Required` if the operation ended in an error | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`gen_ai.request.model`](/docs/attributes-registry/gen-ai.md) | string | The name of the GenAI model a request is being made to. [3] | `gpt-4` | `Conditionally Required` If available. | ![Development](https://img.shields.io/badge/-development-blue) | +| [`server.port`](/docs/attributes-registry/server.md) | int | GenAI server port. [4] | `80`; `8080`; `443` | `Conditionally Required` If `server.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`gen_ai.request.encoding_formats`](/docs/attributes-registry/gen-ai.md) | string[] | The encoding formats requested in an embeddings operation, if specified. [5] | `["base64"]`; `["float", "binary"]` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | +| [`gen_ai.usage.input_tokens`](/docs/attributes-registry/gen-ai.md) | int | The number of tokens used in the GenAI input (prompt). | `100` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | +| [`server.address`](/docs/attributes-registry/server.md) | string | GenAI server address. [6] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | + +**[1] `gen_ai.operation.name`:** If one of the predefined values applies, but specific system uses a different name it's RECOMMENDED to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries SHOULD use applicable predefined value. + +**[2] `error.type`:** The `error.type` SHOULD match the error code returned by the Generative AI provider or the client library, +the canonical name of exception that occurred, or another low-cardinality error identifier. +Instrumentations SHOULD document the list of errors they report. + +**[3] `gen_ai.request.model`:** The name of the GenAI model a request is being made to. If the model is supplied by a vendor, then the value must be the exact name of the model requested. If the model is a fine-tuned custom model, the value should have a more specific name than the base model that's been fine-tuned. + +**[4] `server.port`:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[12]:** May be used when specific backend is unknown. May use common attributes prefixed with 'gcp.gen_ai.'. +**[5] `gen_ai.request.encoding_formats`:** In some GenAI systems the encoding formats are called embedding types. Also, some GenAI systems only accept a single format per request. -**[13]:** This refers to the 'aiplatform.googleapis.com' endpoint. May use common attributes prefixed with 'gcp.gen_ai.'. +**[6] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. + +--- + +`error.type` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. + +| Value | Description | Stability | +|---|---|---| +| `_OTHER` | A fallback error value to be used when the instrumentation doesn't define a custom value. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | + +--- + +`gen_ai.operation.name` has the following list of well-known values. If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used. + +| Value | Description | Stability | +|---|---|---| +| `chat` | Chat completion operation such as [OpenAI Chat API](https://platform.openai.com/docs/api-reference/chat) | ![Development](https://img.shields.io/badge/-development-blue) | +| `create_agent` | Create GenAI agent | ![Development](https://img.shields.io/badge/-development-blue) | +| `embeddings` | Embeddings operation such as [OpenAI Create embeddings API](https://platform.openai.com/docs/api-reference/embeddings/create) | ![Development](https://img.shields.io/badge/-development-blue) | +| `execute_tool` | Execute a tool | ![Development](https://img.shields.io/badge/-development-blue) | +| `generate_content` | Multimodal content generation operation such as [Gemini Generate Content](https://ai.google.dev/api/generate-content) | ![Development](https://img.shields.io/badge/-development-blue) | +| `text_completion` | Text completions operation such as [OpenAI Completions API (Legacy)](https://platform.openai.com/docs/api-reference/completions) | ![Development](https://img.shields.io/badge/-development-blue) | -### Execute Tool Span +### Execute tool span diff --git a/docs/gen-ai/openai.md b/docs/gen-ai/openai.md index 48fc71790a..4330025fff 100644 --- a/docs/gen-ai/openai.md +++ b/docs/gen-ai/openai.md @@ -9,6 +9,8 @@ linkTitle: OpenAI - [Spans](#spans) + - [Inference](#inference) + - [Embeddings](#embeddings) - [Metrics](#metrics) - [Metric: `gen_ai.client.token.usage`](#metric-gen_aiclienttokenusage) - [Metric: `gen_ai.client.operation.duration`](#metric-gen_aiclientoperationduration) @@ -19,7 +21,9 @@ The Semantic Conventions for [OpenAI](https://openai.com/) extend and override t ## Spans - +### Inference + + @@ -50,7 +54,6 @@ Semantic Conventions for [OpenAI](https://openai.com/) client spans extend and o | [`gen_ai.request.seed`](/docs/attributes-registry/gen-ai.md) | int | Requests with same seed value more likely to return same result. | `100` | `Conditionally Required` if applicable and if the request includes a seed | ![Development](https://img.shields.io/badge/-development-blue) | | [`server.port`](/docs/attributes-registry/server.md) | int | GenAI server port. [8] | `80`; `8080`; `443` | `Conditionally Required` If `server.address` is set. | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | | [`gen_ai.openai.response.system_fingerprint`](/docs/attributes-registry/gen-ai.md) | string | A fingerprint to track any eventual change in the Generative AI environment. | `fp_44709d6fcb` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.request.encoding_formats`](/docs/attributes-registry/gen-ai.md) | string[] | The encoding formats requested in an embeddings operation, if specified. [9] | `["base64"]`; `["float", "binary"]` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.frequency_penalty`](/docs/attributes-registry/gen-ai.md) | double | The frequency penalty setting for the GenAI request. | `0.1` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.max_tokens`](/docs/attributes-registry/gen-ai.md) | int | The maximum number of tokens the model generates for a request. | `100` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.request.presence_penalty`](/docs/attributes-registry/gen-ai.md) | double | The presence penalty setting for the GenAI request. | `0.1` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | @@ -59,10 +62,10 @@ Semantic Conventions for [OpenAI](https://openai.com/) client spans extend and o | [`gen_ai.request.top_p`](/docs/attributes-registry/gen-ai.md) | double | The top_p sampling setting for the GenAI request. | `1.0` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.response.finish_reasons`](/docs/attributes-registry/gen-ai.md) | string[] | Array of reasons the model stopped generating tokens, corresponding to each generation received. | `["stop"]`; `["stop", "length"]` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.response.id`](/docs/attributes-registry/gen-ai.md) | string | The unique identifier for the completion. | `chatcmpl-123` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`gen_ai.response.model`](/docs/attributes-registry/gen-ai.md) | string | The name of the model that generated the response. [10] | `gpt-4-0613` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | +| [`gen_ai.response.model`](/docs/attributes-registry/gen-ai.md) | string | The name of the model that generated the response. [9] | `gpt-4-0613` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.usage.input_tokens`](/docs/attributes-registry/gen-ai.md) | int | The number of tokens used in the prompt sent to OpenAI. | `100` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`gen_ai.usage.output_tokens`](/docs/attributes-registry/gen-ai.md) | int | The number of tokens used in the completions from OpenAI. | `180` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | -| [`server.address`](/docs/attributes-registry/server.md) | string | GenAI server address. [11] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | +| [`server.address`](/docs/attributes-registry/server.md) | string | GenAI server address. [10] | `example.com`; `10.1.2.80`; `/tmp/my.sock` | `Recommended` | ![Stable](https://img.shields.io/badge/-stable-lightgreen) | **[1] `gen_ai.operation.name`:** If one of the predefined values applies, but specific system uses a different name it's RECOMMENDED to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries SHOULD use applicable predefined value. @@ -76,19 +79,26 @@ Instrumentations SHOULD document the list of errors they report. **[5] `gen_ai.openai.response.service_tier`:** if the response was received and includes a service_tier -**[6] `gen_ai.output.type`:** This attribute SHOULD be set to the output type requested by the client: - `json` for structured outputs with defined or undefined schema - `image` for image output - `speech` for speech output - `text` for plain text output -The attribute specifies the output modality and not the actual output format. For example, if an image is requested, the actual output could be a URL pointing to an image file. -Additional output format details may be recorded in the future in the `gen_ai.output.{type}.*` attributes. +**[6] `gen_ai.output.type`:** This attribute SHOULD be set to the output type requested by the client: +- `json` for structured outputs with defined or undefined schema +- `image` for image output +- `speech` for speech output +- `text` for plain text output + +The attribute specifies the output modality and not the actual output format. +For example, if an image is requested, the actual output could be a +URL pointing to an image file. + +Additional output format details may be recorded in the future in the +`gen_ai.output.{type}.*` attributes. **[7] `gen_ai.output.type`:** when applicable and if the request includes an output format. **[8] `server.port`:** When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. -**[9] `gen_ai.request.encoding_formats`:** In some GenAI systems the encoding formats are called embedding types. Also, some GenAI systems only accept a single format per request. +**[9] `gen_ai.response.model`:** If available. The name of the GenAI model that provided the response. If the model is supplied by a vendor, then the value must be the exact name of the model actually used. If the model is a fine-tuned custom model, the value should have a more specific name than the base model that's been fine-tuned. -**[10] `gen_ai.response.model`:** If available. The name of the GenAI model that provided the response. If the model is supplied by a vendor, then the value must be the exact name of the model actually used. If the model is a fine-tuned custom model, the value should have a more specific name than the base model that's been fine-tuned. - -**[11] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. +**[10] `server.address`:** When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. --- @@ -136,6 +146,10 @@ Additional output format details may be recorded in the future in the `gen_ai.ou +### Embeddings + +See [common embeddings span definition](./gen-ai-spans.md#embeddings). + ## Metrics OpenAI metrics follow [Generative AI metrics](gen-ai-metrics.md) with the noted additional attributes. diff --git a/model/gen-ai/spans.yaml b/model/gen-ai/spans.yaml index 4632692b3d..c2fe2ac9b0 100644 --- a/model/gen-ai/spans.yaml +++ b/model/gen-ai/spans.yaml @@ -1,9 +1,9 @@ groups: - - id: trace.gen_ai.client.common_request_attributes + - id: attributes.gen_ai.common.client type: attribute_group stability: development brief: > - Describes GenAI operation span. + Common attributes for all GenAI spans. attributes: - ref: gen_ai.request.model requirement_level: @@ -14,26 +14,6 @@ groups: custom model, the value should have a more specific name than the base model that's been fine-tuned. - ref: gen_ai.operation.name requirement_level: required - - ref: gen_ai.request.max_tokens - requirement_level: recommended - - ref: gen_ai.request.choice.count - requirement_level: - conditionally_required: if available, in the request, and !=1 - - ref: gen_ai.request.temperature - requirement_level: recommended - - ref: gen_ai.request.top_p - requirement_level: recommended - - ref: gen_ai.request.stop_sequences - requirement_level: recommended - - ref: gen_ai.request.frequency_penalty - requirement_level: recommended - - ref: gen_ai.request.presence_penalty - requirement_level: recommended - - ref: gen_ai.request.seed - requirement_level: - conditionally_required: if applicable and if the request includes a seed - - ref: gen_ai.request.encoding_formats - requirement_level: recommended - ref: server.address brief: GenAI server address. requirement_level: recommended @@ -48,13 +28,32 @@ groups: The `error.type` SHOULD match the error code returned by the Generative AI provider or the client library, the canonical name of exception that occurred, or another low-cardinality error identifier. Instrumentations SHOULD document the list of errors they report. - - id: trace.gen_ai.client.common_attributes + + - id: attributes.gen_ai.inference.client type: attribute_group stability: development brief: > - Describes GenAI operation span. - extends: trace.gen_ai.client.common_request_attributes + Describes GenAI inference attributes. + extends: attributes.gen_ai.common.client attributes: + - ref: gen_ai.request.max_tokens + requirement_level: recommended + - ref: gen_ai.request.choice.count + requirement_level: + conditionally_required: if available, in the request, and !=1 + - ref: gen_ai.request.temperature + requirement_level: recommended + - ref: gen_ai.request.top_p + requirement_level: recommended + - ref: gen_ai.request.stop_sequences + requirement_level: recommended + - ref: gen_ai.request.frequency_penalty + requirement_level: recommended + - ref: gen_ai.request.presence_penalty + requirement_level: recommended + - ref: gen_ai.request.seed + requirement_level: + conditionally_required: if applicable and if the request includes a seed - ref: gen_ai.output.type requirement_level: conditionally_required: when applicable and if the request includes an output format. @@ -72,12 +71,14 @@ groups: requirement_level: recommended - ref: gen_ai.usage.output_tokens requirement_level: recommended - - id: span.gen_ai.client + + - id: span.gen_ai.inference.client type: span stability: development span_kind: client brief: > - This span represents a client call to Generative AI model or service. + This span represents a client call to Generative AI model or service that generates + a response or requests a tool call based on the input prompt. note: | **Span name** SHOULD be `{gen_ai.operation.name} {gen_ai.request.model}`. Semantic conventions for individual GenAI systems and frameworks MAY specify different span name format @@ -87,26 +88,23 @@ groups: call to models running in the same process. It's RECOMMENDED to use `CLIENT` kind when the GenAI system being instrumented usually runs in a different process than its client or when the GenAI call happens over instrumented protocol such as HTTP. - extends: trace.gen_ai.client.common_attributes + extends: attributes.gen_ai.inference.client attributes: - ref: gen_ai.system - # TODO: Not adding to trace.gen_ai.client.common_attributes because of https://github.com/open-telemetry/build-tools/issues/192 + # TODO: Not adding to common attributes because of https://github.com/open-telemetry/build-tools/issues/192 requirement_level: required - ref: gen_ai.request.top_k requirement_level: recommended - events: - - gen_ai.content.prompt - - gen_ai.content.completion - - id: attributes.gen_ai.openai_based - extends: trace.gen_ai.client.common_attributes + - id: attributes.gen_ai.inference.openai_based + extends: attributes.gen_ai.inference.client type: attribute_group stability: development brief: > Describes attributes that are common to OpenAI-based Generative AI services. attributes: - ref: gen_ai.output.type - note: > + note: | This attribute SHOULD be set to the output type requested by the client: - `json` for structured outputs with defined or undefined schema - `image` for image output @@ -119,8 +117,9 @@ groups: Additional output format details may be recorded in the future in the `gen_ai.output.{type}.*` attributes. - - id: span.gen_ai.openai.client - extends: attributes.gen_ai.openai_based + + - id: span.gen_ai.openai.inference.client + extends: attributes.gen_ai.inference.openai_based stability: development span_kind: client type: span @@ -147,9 +146,8 @@ groups: - ref: gen_ai.usage.output_tokens brief: The number of tokens used in the completions from OpenAI. - - id: span.gen_ai.az.ai.inference.client - extends: attributes.gen_ai.openai_based + extends: attributes.gen_ai.inference.openai_based stability: development type: span span_kind: client @@ -177,6 +175,24 @@ groups: requirement_level: conditionally_required: If not default (443). + - id: span.gen_ai.embeddings.client + type: span + span_kind: client + stability: development + brief: > + Describes GenAI embeddings span - a request to a Generative AI model or service + that generates an embeddings based on the input. + + The `gen_ai.operation.name` SHOULD be `embeddings`. + + **Span name** SHOULD be `{gen_ai.operation.name} {gen_ai.request.model}`. + extends: attributes.gen_ai.common.client + attributes: + - ref: gen_ai.request.encoding_formats + requirement_level: recommended + - ref: gen_ai.usage.input_tokens + requirement_level: recommended + - id: span.gen_ai.create_agent.client type: span stability: development @@ -189,7 +205,7 @@ groups: **Span name** SHOULD be `create_agent {gen_ai.agent.name}`. Semantic conventions for individual GenAI systems and frameworks MAY specify different span name format. - extends: trace.gen_ai.client.common_request_attributes + extends: attributes.gen_ai.common.client attributes: - ref: gen_ai.system requirement_level: required