You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add gen_ai.agent.invocation.duration and gen_ai.tool.execution.duration metrics
Adds two new GenAI semantic convention metrics for agent and tool latency,
modeled on the recently-added gen_ai.workflow.duration metric:
* gen_ai.agent.invocation.duration (histogram, seconds): end-to-end
duration of a single agent invocation, aligned with the existing
gen_ai.invoke_agent.{client,internal} spans.
* gen_ai.tool.execution.duration (histogram, seconds): duration of a
single tool execution, aligned with the existing
gen_ai.execute_tool.internal span.
Also adds the gen_ai.tool.version attribute, used as a dimension on
gen_ai.tool.execution.duration (mirrors the existing gen_ai.agent.version).
NOTE: docs/registry/ and schema-snapshot/ regeneration via 'make
generate-all' has NOT been run in this commit (no Docker available in
the authoring environment). Run it locally before pushing for review.
**[1]:** This metric measures the end-to-end duration of a single agent invocation, from the moment the agent is invoked to the moment it produces its final response (or terminates with an error).
948
+
When this metric is reported alongside a `gen_ai.invoke_agent` span, the metric value SHOULD be the same as the span duration.
949
+
950
+
**Attributes:**
951
+
952
+
| Key | Stability |[Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/)| Value Type | Description | Example Values |
953
+
| --- | --- | --- | --- | --- | --- |
954
+
|[`error.type`](https://github.com/open-telemetry/semantic-conventions/blob/v1.41.0/docs/registry/attributes/error.md)||`Conditionally Required` if the operation ended in an error | string | Describes a class of error the operation ended with. [1]|`timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500`|
955
+
|[`gen_ai.agent.name`](/docs/registry/attributes/gen-ai.md)||`Conditionally Required` when available | string | Human-readable name of the GenAI agent provided by the application. |`Math Tutor`; `Fiction Writer`|
956
+
|[`gen_ai.agent.version`](/docs/registry/attributes/gen-ai.md)||`Conditionally Required` when available | string | The version of the GenAI agent. |`1.0.0`; `2025-05-01`|
957
+
958
+
**[1]`error.type`:** The `error.type` SHOULD match the error code returned by the Generative AI provider or the client library,
959
+
the canonical name of exception that occurred, or another low-cardinality error identifier.
960
+
Instrumentations SHOULD document the list of errors they report.
961
+
962
+
---
963
+
964
+
`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.
965
+
966
+
| Value | Description | Stability |
967
+
| --- | --- | --- |
968
+
|`_OTHER`| A fallback error value to be used when the instrumentation doesn't define a custom value. ||
969
+
970
+
<!-- prettier-ignore-end -->
971
+
<!-- END AUTOGENERATED TEXT -->
972
+
<!-- endweaver -->
973
+
974
+
## Generative AI tool metrics
975
+
976
+
Individual systems may include additional system-specific attributes.
977
+
It is recommended to check system-specific documentation, if available.
978
+
979
+
`gen_ai.tool.execution.duration` represents the duration of a single tool
980
+
execution performed by or on behalf of a GenAI agent. It is intended for
981
+
instrumentations of agent frameworks (or of application code that executes
982
+
tools on behalf of an agent) that can reliably bound a single tool call.
983
+
984
+
### Metric: `gen_ai.tool.execution.duration`
985
+
986
+
This metric is [recommended][MetricRecommended] for instrumentations that can
987
+
observe tool executions performed by or on behalf of a GenAI agent.
988
+
989
+
When this metric is reported alongside a `gen_ai.execute_tool` span, the
990
+
metric value SHOULD be the same as the span duration.
991
+
992
+
This metric SHOULD be specified with [ExplicitBucketBoundaries] of
**[1]:** This metric measures the duration of a single tool execution performed by or on behalf of a GenAI agent.
1005
+
When this metric is reported alongside a `gen_ai.execute_tool` span, the metric value SHOULD be the same as the span duration.
1006
+
1007
+
**Attributes:**
1008
+
1009
+
| Key | Stability |[Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/)| Value Type | Description | Example Values |
1010
+
| --- | --- | --- | --- | --- | --- |
1011
+
|[`gen_ai.tool.name`](/docs/registry/attributes/gen-ai.md)||`Required`| string | Name of the tool utilized by the agent. |`Flights`|
1012
+
|[`error.type`](https://github.com/open-telemetry/semantic-conventions/blob/v1.41.0/docs/registry/attributes/error.md)||`Conditionally Required` if the operation ended in an error | string | Describes a class of error the operation ended with. [1]|`timeout`; `java.net.UnknownHostException`; `server_certificate_invalid`; `500`|
1013
+
|[`gen_ai.agent.name`](/docs/registry/attributes/gen-ai.md)||`Conditionally Required` when available | string | Human-readable name of the GenAI agent provided by the application. |`Math Tutor`; `Fiction Writer`|
1014
+
|[`gen_ai.agent.version`](/docs/registry/attributes/gen-ai.md)||`Conditionally Required` when available | string | The version of the GenAI agent. |`1.0.0`; `2025-05-01`|
1015
+
|[`gen_ai.tool.version`](/docs/registry/attributes/gen-ai.md)||`Conditionally Required` when available | string | The version of the tool utilized by the agent. [2]|`1.0.0`; `2025-05-01`|
1016
+
1017
+
**[1]`error.type`:** The `error.type` SHOULD match the error code returned by the Generative AI provider or the client library,
1018
+
the canonical name of exception that occurred, or another low-cardinality error identifier.
1019
+
Instrumentations SHOULD document the list of errors they report.
1020
+
1021
+
**[2]`gen_ai.tool.version`:** The tool version is usually provided by the application that defines the
1022
+
tool. It is typically a static value (for example, a release tag of the
1023
+
tool's package) and is expected to have low cardinality.
1024
+
1025
+
`gen_ai.tool.version` MUST have low cardinality.
1026
+
1027
+
---
1028
+
1029
+
`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.
1030
+
1031
+
| Value | Description | Stability |
1032
+
| --- | --- | --- |
1033
+
|`_OTHER`| A fallback error value to be used when the instrumentation doesn't define a custom value. ||
Copy file name to clipboardExpand all lines: docs/registry/attributes/gen-ai.md
+23-16Lines changed: 23 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,12 +51,13 @@
51
51
| <aid="gen-ai-tool-description"href="#gen-ai-tool-description">`gen_ai.tool.description`</a> || string | The tool description. |`Multiply two numbers`|
52
52
| <aid="gen-ai-tool-name"href="#gen-ai-tool-name">`gen_ai.tool.name`</a> || string | Name of the tool utilized by the agent. |`Flights`|
53
53
| <aid="gen-ai-tool-type"href="#gen-ai-tool-type">`gen_ai.tool.type`</a> || string | Type of the tool utilized by the agent [15]|`function`; `extension`; `datastore`|
54
-
| <aid="gen-ai-usage-cache-creation-input-tokens"href="#gen-ai-usage-cache-creation-input-tokens">`gen_ai.usage.cache_creation.input_tokens`</a> || int | The number of input tokens written to a provider-managed cache. [16]|`25`|
55
-
| <aid="gen-ai-usage-cache-read-input-tokens"href="#gen-ai-usage-cache-read-input-tokens">`gen_ai.usage.cache_read.input_tokens`</a> || int | The number of input tokens served from a provider-managed cache. [17]|`50`|
56
-
| <aid="gen-ai-usage-input-tokens"href="#gen-ai-usage-input-tokens">`gen_ai.usage.input_tokens`</a> || int | The number of tokens used in the GenAI input (prompt). [18]|`100`|
54
+
| <aid="gen-ai-tool-version"href="#gen-ai-tool-version">`gen_ai.tool.version`</a> || string | The version of the tool utilized by the agent. [16]|`1.0.0`; `2025-05-01`|
55
+
| <aid="gen-ai-usage-cache-creation-input-tokens"href="#gen-ai-usage-cache-creation-input-tokens">`gen_ai.usage.cache_creation.input_tokens`</a> || int | The number of input tokens written to a provider-managed cache. [17]|`25`|
56
+
| <aid="gen-ai-usage-cache-read-input-tokens"href="#gen-ai-usage-cache-read-input-tokens">`gen_ai.usage.cache_read.input_tokens`</a> || int | The number of input tokens served from a provider-managed cache. [18]|`50`|
57
+
| <aid="gen-ai-usage-input-tokens"href="#gen-ai-usage-input-tokens">`gen_ai.usage.input_tokens`</a> || int | The number of tokens used in the GenAI input (prompt). [19]|`100`|
57
58
| <aid="gen-ai-usage-output-tokens"href="#gen-ai-usage-output-tokens">`gen_ai.usage.output_tokens`</a> || int | The number of tokens used in the GenAI response (completion). |`180`|
58
-
| <aid="gen-ai-usage-reasoning-output-tokens"href="#gen-ai-usage-reasoning-output-tokens">`gen_ai.usage.reasoning.output_tokens`</a> || int | The number of output tokens used for reasoning (e.g. chain-of-thought, extended thinking). [19]|`50`|
59
-
| <aid="gen-ai-workflow-name"href="#gen-ai-workflow-name">`gen_ai.workflow.name`</a> || string | Human-readable name of the GenAI workflow provided by the application. [20]|`multi_agent_rag`; `customer_support_pipeline`|
59
+
| <aid="gen-ai-usage-reasoning-output-tokens"href="#gen-ai-usage-reasoning-output-tokens">`gen_ai.usage.reasoning.output_tokens`</a> || int | The number of output tokens used for reasoning (e.g. chain-of-thought, extended thinking). [20]|`50`|
60
+
| <aid="gen-ai-workflow-name"href="#gen-ai-workflow-name">`gen_ai.workflow.name`</a> || string | Human-readable name of the GenAI workflow provided by the application. [21]|`multi_agent_rag`; `customer_support_pipeline`|
60
61
61
62
62
63
**[1]`gen_ai.data_source.id`:** Data sources are used by AI agents and RAG applications to store grounding data. A data source may be an external database, object store, document collection, website, or any other storage system used by the GenAI agent or application. The `gen_ai.data_source.id` SHOULD match the identifier used by the GenAI system rather than a name specific to the external storage, such as a database or object store. Semantic conventions referencing `gen_ai.data_source.id` MAY also leverage additional attributes, such as `db.*`, to further identify and describe the data source.
@@ -193,18 +194,24 @@ Function: A tool executed on the client-side, where the agent generates paramete
193
194
Client-side operations are actions taken on the user's end or within the client application.
194
195
Datastore: A tool used by the agent to access and query structured or unstructured external data for retrieval-augmented tasks or knowledge updates.
195
196
196
-
**[16]`gen_ai.usage.cache_creation.input_tokens`:** The value SHOULD be included in `gen_ai.usage.input_tokens`.
197
+
**[16]`gen_ai.tool.version`:** The tool version is usually provided by the application that defines the
198
+
tool. It is typically a static value (for example, a release tag of the
199
+
tool's package) and is expected to have low cardinality.
197
200
198
-
**[17]`gen_ai.usage.cache_read.input_tokens`:** The value SHOULD be included in `gen_ai.usage.input_tokens`.
201
+
`gen_ai.tool.version` MUST have low cardinality.
199
202
200
-
**[18]`gen_ai.usage.input_tokens`:** This value SHOULD include all types of input tokens, including cached tokens.
203
+
**[17]`gen_ai.usage.cache_creation.input_tokens`:** The value SHOULD be included in `gen_ai.usage.input_tokens`.
204
+
205
+
**[18]`gen_ai.usage.cache_read.input_tokens`:** The value SHOULD be included in `gen_ai.usage.input_tokens`.
206
+
207
+
**[19]`gen_ai.usage.input_tokens`:** This value SHOULD include all types of input tokens, including cached tokens.
201
208
Instrumentations SHOULD make a best effort to populate this value, using a total
202
209
provided by the provider when available or, depending on the provider API,
203
210
by summing different token types parsed from the provider output.
204
211
205
-
**[19]`gen_ai.usage.reasoning.output_tokens`:** The value SHOULD be included in `gen_ai.usage.output_tokens`.
212
+
**[20]`gen_ai.usage.reasoning.output_tokens`:** The value SHOULD be included in `gen_ai.usage.output_tokens`.
206
213
207
-
**[20]`gen_ai.workflow.name`:** This attribute can be populated in different frameworks; for example, as the name of the first chain in LangChain or the name of the crew in CrewAI.
214
+
**[21]`gen_ai.workflow.name`:** This attribute can be populated in different frameworks; for example, as the name of the first chain in LangChain or the name of the crew in CrewAI.
208
215
The workflow name is usually provided by the application in a way that is specific to the generative AI framework or library that orchestrates the workflow.
209
216
It is usually a static name that is expected to be unique within an application.
210
217
@@ -252,21 +259,21 @@ If there is no low-cardinality workflow name available for a given framework, th
0 commit comments