Skip to content

Commit 90ed42f

Browse files
committed
Adding span for invoke agent
Signed-off-by: Guangya Liu <gyliu@ibm.com>
1 parent 87bd2c1 commit 90ed42f

File tree

3 files changed

+158
-25
lines changed

3 files changed

+158
-25
lines changed

.chloggen/1842.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Use this changelog template to create an entry for release notes.
2+
#
3+
# If your change doesn't affect end users you should instead start
4+
# your pull request title with [chore] or use the "Skip Changelog" label.
5+
6+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
7+
change_type: enhancement
8+
9+
# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db)
10+
component: gen-ai
11+
12+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
13+
note: Adding span for invoke agent
14+
15+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
16+
# The values here must be integers.
17+
issues: [1842]
18+
19+
# (Optional) One or more lines of additional information to render under the primary note.
20+
# These lines will be padded with 2 spaces and then inserted directly into the document.
21+
# Use pipe (|) for multiline entries.
22+
subtext:

docs/gen-ai/gen-ai-agent-spans.md

+101-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ linkTitle: Generative AI traces
1212

1313
- [Spans](#spans)
1414
- [Create Agent Span](#create-agent-span)
15-
- [Agent Execute Tool Span](#agent-execute-tool-span)
15+
- [Invoke Agent Span](#invoke-agent-span)
16+
- [Agent Execute Tool Span](#agent-execute-tool-span)
1617

1718
<!-- tocstop -->
1819

@@ -43,6 +44,101 @@ Semantic conventions for individual GenAI systems and frameworks MAY specify dif
4344
<!-- markdownlint-capture -->
4445
<!-- markdownlint-disable -->
4546

47+
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
48+
|---|---|---|---|---|---|
49+
| [`gen_ai.operation.name`](/docs/attributes-registry/gen-ai.md) | string | The name of the operation being performed. [1] | `chat`; `text_completion`; `embeddings` | `Required` | ![Development](https://img.shields.io/badge/-development-blue) |
50+
| [`gen_ai.system`](/docs/attributes-registry/gen-ai.md) | string | The Generative AI product as identified by the client or server instrumentation. [2] | `openai` | `Required` | ![Development](https://img.shields.io/badge/-development-blue) |
51+
| [`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) |
52+
| [`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) |
53+
| [`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) |
54+
| [`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) |
55+
| [`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) |
56+
| [`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) |
57+
| [`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) |
58+
| [`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) |
59+
| [`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) |
60+
| [`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) |
61+
| [`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) |
62+
| [`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) |
63+
| [`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) |
64+
65+
**[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.
66+
67+
**[2] `gen_ai.system`:** The `gen_ai.system` describes a family of GenAI models with specific model identified
68+
by `gen_ai.request.model` and `gen_ai.response.model` attributes.
69+
70+
The actual GenAI product may differ from the one identified by the client.
71+
Multiple systems, including Azure OpenAI and Gemini, are accessible by OpenAI client
72+
libraries. In such cases, the `gen_ai.system` is set to `openai` based on the
73+
instrumentation's best knowledge, instead of the actual system. The `server.address`
74+
attribute may help identify the actual system in use for `openai`.
75+
76+
For custom model, a custom friendly name SHOULD be used.
77+
If none of these options apply, the `gen_ai.system` SHOULD be set to `_OTHER`.
78+
79+
**[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.
80+
81+
**[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.
82+
83+
**[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.
84+
85+
**[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.
86+
87+
---
88+
89+
`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.
90+
91+
| Value | Description | Stability |
92+
|---|---|---|
93+
| `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) |
94+
| `create_agent` | Create GenAI agent | ![Development](https://img.shields.io/badge/-development-blue) |
95+
| `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) |
96+
| `execute_tool` | Execute a tool | ![Development](https://img.shields.io/badge/-development-blue) |
97+
| `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) |
98+
99+
---
100+
101+
`gen_ai.system` 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.
102+
103+
| Value | Description | Stability |
104+
|---|---|---|
105+
| `anthropic` | Anthropic | ![Development](https://img.shields.io/badge/-development-blue) |
106+
| `aws.bedrock` | AWS Bedrock | ![Development](https://img.shields.io/badge/-development-blue) |
107+
| `az.ai.inference` | Azure AI Inference | ![Development](https://img.shields.io/badge/-development-blue) |
108+
| `az.ai.openai` | Azure OpenAI | ![Development](https://img.shields.io/badge/-development-blue) |
109+
| `cohere` | Cohere | ![Development](https://img.shields.io/badge/-development-blue) |
110+
| `deepseek` | DeepSeek | ![Development](https://img.shields.io/badge/-development-blue) |
111+
| `gemini` | Gemini | ![Development](https://img.shields.io/badge/-development-blue) |
112+
| `groq` | Groq | ![Development](https://img.shields.io/badge/-development-blue) |
113+
| `ibm.watsonx.ai` | IBM Watsonx AI | ![Development](https://img.shields.io/badge/-development-blue) |
114+
| `mistral_ai` | Mistral AI | ![Development](https://img.shields.io/badge/-development-blue) |
115+
| `openai` | OpenAI | ![Development](https://img.shields.io/badge/-development-blue) |
116+
| `perplexity` | Perplexity | ![Development](https://img.shields.io/badge/-development-blue) |
117+
| `vertex_ai` | Vertex AI | ![Development](https://img.shields.io/badge/-development-blue) |
118+
| `xai` | xAI | ![Development](https://img.shields.io/badge/-development-blue) |
119+
120+
<!-- markdownlint-restore -->
121+
<!-- prettier-ignore-end -->
122+
<!-- END AUTOGENERATED TEXT -->
123+
<!-- endsemconv -->
124+
125+
### Invoke Agent Span
126+
127+
Describes GenAI agent invoke and is usually applicable when working with remote agent
128+
services.
129+
130+
The `gen_ai.operation.name` SHOULD be `invoke_agent`.
131+
132+
The **span name** SHOULD be `invoke_agent {gen_ai.agent.name}`.
133+
Semantic conventions for individual GenAI systems and frameworks MAY specify different span name format.
134+
135+
<!-- semconv span.gen_ai.client.invoke_agent -->
136+
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
137+
<!-- see templates/registry/markdown/snippet.md.j2 -->
138+
<!-- prettier-ignore-start -->
139+
<!-- markdownlint-capture -->
140+
<!-- markdownlint-disable -->
141+
46142
| Attribute | Type | Description | Examples | [Requirement Level](https://opentelemetry.io/docs/specs/semconv/general/attribute-requirement-level/) | Stability |
47143
|---|---|---|---|---|---|
48144
| [`gen_ai.operation.name`](/docs/attributes-registry/gen-ai.md) | string | The name of the operation being performed. [1] | `chat`; `text_completion`; `embeddings` | `Required` | ![Development](https://img.shields.io/badge/-development-blue) |
@@ -52,16 +148,16 @@ Semantic conventions for individual GenAI systems and frameworks MAY specify dif
52148
| [`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) |
53149
| [`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) |
54150
| [`gen_ai.output.type`](/docs/attributes-registry/gen-ai.md) | string | Represents the content type requested by the client. [4] | `text`; `json`; `image` | `Conditionally Required` [5] | ![Development](https://img.shields.io/badge/-development-blue) |
55-
| [`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 provided by the application. | ![Development](https://img.shields.io/badge/-development-blue) |
151+
| [`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) |
56152
| [`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) |
57-
| [`gen_ai.request.temperature`](/docs/attributes-registry/gen-ai.md) | double | The temperature setting for the GenAI request. | `0.0` | `Conditionally Required` If provided by the application. | ![Development](https://img.shields.io/badge/-development-blue) |
58-
| [`gen_ai.request.top_p`](/docs/attributes-registry/gen-ai.md) | double | The top_p sampling setting for the GenAI request. | `1.0` | `Conditionally Required` If provided by the application. | ![Development](https://img.shields.io/badge/-development-blue) |
59153
| [`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) |
60154
| [`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) |
61155
| [`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) |
62156
| [`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) |
63157
| [`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) |
64158
| [`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) |
159+
| [`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) |
160+
| [`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) |
65161
| [`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) |
66162
| [`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) |
67163
| [`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) |
@@ -160,7 +256,7 @@ Additional output format details may be recorded in the future in the `gen_ai.ou
160256
<!-- END AUTOGENERATED TEXT -->
161257
<!-- endsemconv -->
162258

163-
## Agent Execute Tool Span
259+
### Agent Execute Tool Span
164260

165261
If you are using some tools in your agent, refer to [Execute Tool Span](./gen-ai-spans.md#execute-tool-span).
166262

model/gen-ai/spans.yaml

+35-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
groups:
2-
- id: trace.gen_ai.client.common_attributes
2+
- id: trace.gen_ai.client.common_request_attributes
33
type: attribute_group
44
stability: development
55
brief: >
@@ -31,6 +31,20 @@ groups:
3131
conditionally_required: if applicable and if the request includes a seed
3232
- ref: gen_ai.request.encoding_formats
3333
requirement_level: recommended
34+
- ref: server.address
35+
brief: GenAI server address.
36+
requirement_level: recommended
37+
- ref: server.port
38+
brief: GenAI server port.
39+
requirement_level:
40+
conditionally_required: If `server.address` is set.
41+
- id: trace.gen_ai.client.common_attributes
42+
type: attribute_group
43+
stability: development
44+
brief: >
45+
Describes GenAI operation span.
46+
extends: trace.gen_ai.client.common_request_attributes
47+
attributes:
3448
- ref: gen_ai.output.type
3549
requirement_level:
3650
conditionally_required: when applicable and if the request includes an output format.
@@ -48,13 +62,6 @@ groups:
4862
requirement_level: recommended
4963
- ref: gen_ai.usage.output_tokens
5064
requirement_level: recommended
51-
- ref: server.address
52-
brief: GenAI server address.
53-
requirement_level: recommended
54-
- ref: server.port
55-
brief: GenAI server port.
56-
requirement_level:
57-
conditionally_required: If `server.address` is set.
5865
- ref: error.type
5966
requirement_level:
6067
conditionally_required: "if the operation ended in an error"
@@ -157,30 +164,38 @@ groups:
157164
The `gen_ai.operation.name` SHOULD be `create_agent`.
158165
The **span name** SHOULD be `create_agent {gen_ai.agent.name}`.
159166
Semantic conventions for individual GenAI systems and frameworks MAY specify different span name format.
160-
extends: trace.gen_ai.client.common_attributes
167+
extends: trace.gen_ai.client.common_request_attributes
161168
attributes:
162169
- ref: gen_ai.system
163170
requirement_level: required
164-
- ref: gen_ai.agent.id
165-
requirement_level:
166-
conditionally_required: if applicable.
167171
- ref: gen_ai.agent.name
168172
requirement_level:
169173
conditionally_required: If provided by the application.
170174
- ref: gen_ai.agent.description
171175
requirement_level:
172176
conditionally_required: If provided by the application.
173-
- ref: gen_ai.request.model
177+
178+
- id: span.gen_ai.client.invoke_agent
179+
type: span
180+
stability: experimental
181+
brief: >
182+
Describes GenAI agent invocation and is usually applicable when working
183+
with remote agent services.
184+
note: |
185+
The `gen_ai.operation.name` SHOULD be `invoke_agent`.
186+
The **span name** SHOULD be `invoke_agent {gen_ai.agent.name}`.
187+
Semantic conventions for individual GenAI systems and frameworks MAY specify different span name format.
188+
extends: trace.gen_ai.client.common_attributes
189+
attributes:
190+
- ref: gen_ai.system
191+
requirement_level: required
192+
- ref: gen_ai.agent.id
174193
requirement_level:
175-
conditionally_required: If provided by the application.
176-
note: >
177-
The name of the GenAI model a request is being made to. If the model is supplied by a vendor,
178-
then the value must be the exact name of the model requested. If the model is a fine-tuned
179-
custom model, the value should have a more specific name than the base model that's been fine-tuned.
180-
- ref: gen_ai.request.temperature
194+
conditionally_required: if applicable.
195+
- ref: gen_ai.agent.name
181196
requirement_level:
182197
conditionally_required: If provided by the application.
183-
- ref: gen_ai.request.top_p
198+
- ref: gen_ai.agent.description
184199
requirement_level:
185200
conditionally_required: If provided by the application.
186201

0 commit comments

Comments
 (0)