forked from open-telemetry/semantic-conventions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspans.yaml
More file actions
518 lines (480 loc) · 21.6 KB
/
spans.yaml
File metadata and controls
518 lines (480 loc) · 21.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
groups:
- id: attributes.gen_ai.common.client
type: attribute_group
stability: development
brief: >
Common attributes for all GenAI spans.
attributes:
- ref: gen_ai.request.model
requirement_level:
conditionally_required: If available.
note: >
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.
- ref: gen_ai.operation.name
requirement_level: required
- ref: server.address
brief: GenAI server address.
requirement_level: recommended
- ref: server.port
brief: GenAI server port.
requirement_level:
conditionally_required: If `server.address` is set.
- ref: error.type
requirement_level:
conditionally_required: "if the operation ended in an error"
note: |
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: attributes.gen_ai.inference.client
type: attribute_group
stability: development
brief: >
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.
- ref: gen_ai.response.id
requirement_level: recommended
- ref: gen_ai.response.model
requirement_level: recommended
note: >
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.
- ref: gen_ai.response.finish_reasons
requirement_level: recommended
- ref: gen_ai.usage.input_tokens
requirement_level: recommended
- ref: gen_ai.usage.cache_read.input_tokens
requirement_level: recommended
- ref: gen_ai.usage.cache_creation.input_tokens
requirement_level: recommended
- ref: gen_ai.usage.output_tokens
requirement_level: recommended
- ref: gen_ai.conversation.id
requirement_level:
conditionally_required: when available
note: |
Instrumentations SHOULD populate conversation id when they have it readily available
for a given operation, for example:
- when client framework being instrumented manages conversation history
(see [LlamaIndex chat store](https://docs.llamaindex.ai/en/stable/module_guides/storing/chat_stores/))
- when instrumenting GenAI client libraries that maintain conversation on the backend side
(see [AWS Bedrock agent sessions](https://docs.aws.amazon.com/bedrock/latest/userguide/agents-session-state.html),
[OpenAI Assistant threads](https://platform.openai.com/docs/api-reference/threads))
Application developers that manage conversation history MAY add conversation id to GenAI and other
spans or logs using custom span or log record processors or hooks provided by instrumentation
libraries.
- ref: gen_ai.system_instructions
requirement_level: opt_in
- ref: gen_ai.input.messages
requirement_level: opt_in
- ref: gen_ai.output.messages
requirement_level: opt_in
- ref: gen_ai.tool.definitions
requirement_level: opt_in
- 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 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
and MUST follow the overall [guidelines for span names](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.55.0/specification/trace/api.md#span).
**Span kind** SHOULD be `CLIENT` and MAY be set to `INTERNAL` on spans representing
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: attributes.gen_ai.inference.client
attributes:
- ref: gen_ai.provider.name
# TODO: Not adding to common attributes because of https://github.com/open-telemetry/weaver/issues/479
requirement_level: required
sampling_relevant: true
- ref: gen_ai.operation.name
sampling_relevant: true
- ref: server.address
sampling_relevant: true
- ref: server.port
sampling_relevant: true
- ref: gen_ai.request.model
sampling_relevant: true
- ref: gen_ai.request.top_k
requirement_level: recommended
- 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: |
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.
- ref: server.address
sampling_relevant: true
- ref: server.port
sampling_relevant: true
- ref: gen_ai.request.model
sampling_relevant: true
- ref: gen_ai.operation.name
sampling_relevant: true
- id: span.openai.inference.client
extends: attributes.gen_ai.inference.openai_based
stability: development
span_kind: client
type: span
brief: >
Semantic Conventions for [OpenAI](https://openai.com/) client spans extend
and override the semantic conventions for [Gen AI Spans](gen-ai-spans.md).
note: |
`gen_ai.provider.name` MUST be set to `"openai"` and SHOULD be provided **at span creation time**.
**Span name** SHOULD be `{gen_ai.operation.name} {gen_ai.request.model}`.
attributes:
- ref: gen_ai.request.model
requirement_level: required
- ref: gen_ai.usage.input_tokens
note: >
The total input token count is returned by `usage.input_tokens` or a similar property in the model response.
- ref: gen_ai.usage.cache_read.input_tokens
note: >
Corresponds to `usage.input_tokens_details.cached_tokens` or a similar property in the model response.
- ref: openai.request.service_tier
requirement_level:
conditionally_required: if the request includes a service_tier and the value is not 'auto'
- ref: openai.response.service_tier
requirement_level:
conditionally_required: if the response was received and includes a service_tier
- ref: openai.response.system_fingerprint
requirement_level: recommended
- ref: openai.api.type
requirement_level: recommended
- id: span.azure.ai.inference.client
extends: attributes.gen_ai.inference.openai_based
stability: development
type: span
span_kind: client
brief: >
Semantic Conventions for [Azure AI Inference](https://learn.microsoft.com/rest/api/aifoundry/modelinference/)
client spans extend and override the semantic conventions for [Gen AI Spans](gen-ai-spans.md).
note: |
`gen_ai.provider.name` MUST be set to `"azure.ai.inference"` and SHOULD be provided **at span creation time**.
**Span name** SHOULD be `{gen_ai.operation.name} {gen_ai.request.model}` when the
model name is available and `{gen_ai.operation.name}` otherwise.
attributes:
- ref: azure.resource_provider.namespace
note: >
When `azure.resource_provider.namespace` attribute is populated, it MUST
be set to `Microsoft.CognitiveServices` for all operations performed by Azure AI Inference clients.
examples: ["Microsoft.CognitiveServices"]
- ref: gen_ai.usage.input_tokens
brief: >
The number of prompt tokens as reported in the usage prompt_tokens property of the response.
- ref: gen_ai.usage.output_tokens
brief: >
The number of completion tokens as reported in the usage completion_tokens property of the response.
- ref: server.port
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.provider.name
requirement_level: required
sampling_relevant: true
- ref: gen_ai.operation.name
sampling_relevant: true
- ref: server.address
sampling_relevant: true
- ref: server.port
sampling_relevant: true
- ref: gen_ai.request.model
sampling_relevant: true
- ref: gen_ai.request.encoding_formats
requirement_level: recommended
- ref: gen_ai.usage.input_tokens
requirement_level: recommended
- ref: gen_ai.embeddings.dimension.count
requirement_level: recommended
- ref: gen_ai.response.model
requirement_level: recommended
- id: span.gen_ai.retrieval.client
type: span
span_kind: client
stability: development
brief: >
Describes GenAI retrieval span - a request to a Generative AI service or framework
that retrieves relevant information or context from a vector database or search system.
The `gen_ai.operation.name` SHOULD be `retrieval`.
**Span name** SHOULD be `{gen_ai.operation.name} {gen_ai.data_source.id}`. Semantic conventions
for individual GenAI providers and retrievers MAY specify different span name format.
extends: attributes.gen_ai.common.client
attributes:
- ref: gen_ai.operation.name
requirement_level: required
- ref: gen_ai.retrieval.query.text
requirement_level: opt_in
- ref: gen_ai.request.top_k
requirement_level: recommended
- ref: gen_ai.retrieval.documents
requirement_level: opt_in
- ref: gen_ai.provider.name
requirement_level:
conditionally_required: when applicable
- ref: gen_ai.data_source.id
requirement_level:
conditionally_required: when applicable
- ref: error.type
requirement_level:
conditionally_required: "if the operation ended in an error"
- id: span.gen_ai.create_agent.client
type: span
stability: development
span_kind: client
brief: >
Describes GenAI agent creation and is usually applicable when working
with remote agent services.
note: |
The `gen_ai.operation.name` SHOULD be `create_agent`.
**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: attributes.gen_ai.common.client
attributes:
- ref: gen_ai.provider.name
requirement_level: required
sampling_relevant: true
- ref: gen_ai.operation.name
sampling_relevant: true
- ref: server.address
sampling_relevant: true
- ref: server.port
sampling_relevant: true
- ref: gen_ai.request.model
sampling_relevant: true
- ref: gen_ai.agent.id
requirement_level:
conditionally_required: if applicable.
- ref: gen_ai.agent.name
requirement_level:
conditionally_required: If provided by the application.
- ref: gen_ai.agent.description
requirement_level:
conditionally_required: If provided by the application.
- ref: gen_ai.agent.version
requirement_level:
conditionally_required: If provided by the application.
- ref: gen_ai.system_instructions
requirement_level: opt_in
note: "" # note is not needed here
- id: span.gen_ai.invoke_agent.client
type: span
stability: development
span_kind: client
brief: >
Describes GenAI agent invocation.
note: |
The `gen_ai.operation.name` SHOULD be `invoke_agent`.
**Span name** SHOULD be `invoke_agent {gen_ai.agent.name}` if `gen_ai.agent.name` is readily available.
When `gen_ai.agent.name` is not available, it SHOULD be `invoke_agent`.
Semantic conventions for individual GenAI systems and frameworks MAY specify different span name format.
**Span kind** SHOULD be `CLIENT` and MAY be set to `INTERNAL` on spans representing
invocation of agents running in the same process.
It's RECOMMENDED to use `CLIENT` kind when the agent being instrumented usually runs
in a different process than its caller or when the agent invocation happens over
instrumented protocol such as HTTP.
Examples of span kinds for different agent scenarios:
- `CLIENT`: Remote agent services (e.g., OpenAI Assistants API, AWS Bedrock Agents)
- `INTERNAL`: In-process agents (e.g., LangChain agents, CrewAI agents)
extends: attributes.gen_ai.inference.client
attributes:
- ref: gen_ai.provider.name
requirement_level: required
sampling_relevant: true
- ref: gen_ai.operation.name
sampling_relevant: true
- ref: gen_ai.request.model
sampling_relevant: true
- ref: gen_ai.agent.id
requirement_level:
conditionally_required: if applicable.
- ref: gen_ai.agent.name
requirement_level:
conditionally_required: when available
- ref: gen_ai.agent.description
requirement_level:
conditionally_required: when available
- ref: gen_ai.agent.version
requirement_level:
conditionally_required: when available
- ref: gen_ai.data_source.id
requirement_level:
conditionally_required: if applicable.
- ref: server.address
requirement_level:
recommended: when span kind is `CLIENT`.
sampling_relevant: true
- ref: server.port
sampling_relevant: true
- ref: gen_ai.system_instructions
requirement_level: opt_in
- ref: gen_ai.input.messages
requirement_level: opt_in
- ref: gen_ai.output.messages
requirement_level: opt_in
- id: span.gen_ai.execute_tool.internal
type: span
stability: development
span_kind: internal
brief: Describes tool execution span.
note: |
`gen_ai.operation.name` SHOULD be `execute_tool`.
**Span name** SHOULD be `execute_tool {gen_ai.tool.name}`.
GenAI instrumentations that can instrument tool execution calls SHOULD do so,
unless another instrumentation can reliably cover all supported tool types.
MCP tool executions may also be traced by the
[corresponding MCP instrumentation](/docs/gen-ai/mcp.md#client).
Tools are often executed directly by application code. Application developers
are encouraged to follow this semantic convention for tools invoked by their
own code and to manually instrument any tool calls that automatic
instrumentations do not cover.
attributes:
- ref: gen_ai.operation.name
requirement_level: required
sampling_relevant: true
- ref: gen_ai.tool.name
requirement_level: recommended
- ref: gen_ai.tool.call.id
requirement_level:
recommended: if available
- ref: gen_ai.tool.description
requirement_level:
recommended: if available
- ref: gen_ai.tool.type
requirement_level:
recommended: if available
- ref: gen_ai.tool.call.arguments
requirement_level: opt_in
- ref: gen_ai.tool.call.result
requirement_level: opt_in
- ref: error.type
requirement_level:
conditionally_required: "if the operation ended in an error"
note: |
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: span.aws.bedrock.client
extends: span.gen_ai.inference.client
stability: development
span_kind: client
type: span
brief: >
Describes an AWS Bedrock operation span.
attributes:
- ref: aws.bedrock.guardrail.id
requirement_level: required
- ref: aws.bedrock.knowledge_base.id
requirement_level: recommended
- id: span.anthropic.inference.client
extends: attributes.gen_ai.inference.client
stability: development
span_kind: client
type: span
brief: >
Semantic Conventions for [Anthropic](https://www.anthropic.com/) client spans extend
and override the semantic conventions for [Gen AI Spans](gen-ai-spans.md).
note: |
`gen_ai.provider.name` MUST be set to `"anthropic"` and SHOULD be provided **at span creation time**.
**Span name** SHOULD be `{gen_ai.operation.name} {gen_ai.request.model}`.
attributes:
- ref: gen_ai.usage.input_tokens
note: >
Anthropic `input_tokens` excludes cached tokens. Compute:
`gen_ai.usage.input_tokens = input_tokens + cache_read_input_tokens + cache_creation_input_tokens`
- ref: gen_ai.usage.cache_read.input_tokens
note: >
Anthropic reports this separately from `input_tokens`.
This value MUST be added to the Anthropic `input_tokens` to compute `gen_ai.usage.input_tokens`.
- ref: gen_ai.usage.cache_creation.input_tokens
note: >
Anthropic reports this separately from `input_tokens`.
This value MUST be added to the Anthropic `input_tokens` to compute `gen_ai.usage.input_tokens`.
- id: span.gen_ai.invoke_workflow.internal
type: span
span_kind: internal
stability: development
brief: >
Represents an operation that executes a coordinated process composed of multiple agents
or other operations involving generative AI.
note: |
The `gen_ai.operation.name` SHOULD be `invoke_workflow`.
**Span name** SHOULD be `invoke_workflow {gen_ai.workflow.name}`.
This span SHOULD be reported by the instrumentations when they can
reliably determine that invocation is a workflow (i.e. groups several agent
invocations) and SHOULD NOT be reported by instrumentations that
can't distinguish it `invoke_workflow` from `invoke_agent`.
eg: Some frameworks like ADK have workflow agents that orchestrate other agents
and report `invoke_agent` spans, so `invoke_workflow` SHOULD NOT be reported by such instrumentations.
Conversely, frameworks like CrewAI have a distinct concept of crew (similar to workflow)
that is separate from individual agents, so they SHOULD report `invoke_workflow` spans.
attributes:
- ref: gen_ai.operation.name
requirement_level: required
sampling_relevant: true
- ref: error.type
requirement_level:
conditionally_required: "if the operation ended in an error"
note: |
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.
- ref: gen_ai.workflow.name
requirement_level:
conditionally_required: when available
- ref: gen_ai.input.messages
requirement_level: opt_in
- ref: gen_ai.output.messages
requirement_level: opt_in