Skip to content

Commit 0b1f798

Browse files
authored
Merge pull request #681 from open-telemetry/main
[SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.40.0 (open-telemetry#3881)
2 parents e288252 + c8dfead commit 0b1f798

28 files changed

Lines changed: 832 additions & 86 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Increment the:
1818
* [BUILD] Avoid break caused by max() macro on windows
1919
[#3863](https://github.com/open-telemetry/opentelemetry-cpp/pull/3863)
2020

21+
* [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.40.0
22+
[#3881](https://github.com/open-telemetry/opentelemetry-cpp/pull/3881)
23+
2124
## [1.25 2026-02-07]
2225

2326
* [RELEASE] Bump main branch to 1.25.0-dev (#3759)

api/include/opentelemetry/semconv/db_attributes.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ static constexpr const char *kDbOperationName = "db.operation.name";
8585
instrumentation hooks or other means. If it is not available, instrumentations
8686
that support query parsing SHOULD generate a summary following
8787
<a href="/docs/db/database-spans.md#generating-a-summary-of-the-query">Generating query
88-
summary</a> section.
88+
summary</a> section. <p> For batch operations, if the individual operations are known to have the
89+
same query summary then that query summary SHOULD be used prepended by @code BATCH @endcode,
90+
otherwise @code db.query.summary @endcode SHOULD be @code BATCH @endcode or some other database
91+
system specific term if more applicable.
8992
*/
9093
static constexpr const char *kDbQuerySummary = "db.query.summary";
9194

api/include/opentelemetry/semconv/exception_attributes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kExceptionEscaped = "excep
3030

3131
/**
3232
The exception message.
33+
<blockquote>
34+
[!WARNING]
35+
<p>
36+
This attribute may contain sensitive information.</blockquote>
3337
*/
3438
static constexpr const char *kExceptionMessage = "exception.message";
3539

api/include/opentelemetry/semconv/http_attributes.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,21 @@ static constexpr const char *kHttpRequestHeader = "http.request.header";
5353
could end up converting valid HTTP request methods to @code _OTHER @endcode, then it MUST provide
5454
a way to override the list of known HTTP methods. If this override is done via environment
5555
variable, then the environment variable MUST be named OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and
56-
support a comma-separated list of case-sensitive known HTTP methods (this list MUST be a full
57-
override of the default known method, it is not a list of known methods in addition to the
58-
defaults). <p> HTTP method names are case-sensitive and @code http.request.method @endcode
59-
attribute value MUST match a known HTTP method name exactly. Instrumentations for specific web
60-
frameworks that consider HTTP methods to be case insensitive, SHOULD populate a canonical
61-
equivalent. Tracing instrumentations that do so, MUST also set @code http.request.method_original
62-
@endcode to the original value.
56+
support a comma-separated list of case-sensitive known HTTP methods. <p>
57+
58+
If this override is done via declarative configuration, then the list MUST be configurable via the
59+
@code known_methods @endcode property (an array of case-sensitive strings with minimum items 0)
60+
under @code .instrumentation/development.general.http.client @endcode and/or
61+
@code .instrumentation/development.general.http.server @endcode.
62+
<p>
63+
In either case, this list MUST be a full override of the default known methods,
64+
it is not a list of known methods in addition to the defaults.
65+
<p>
66+
HTTP method names are case-sensitive and @code http.request.method @endcode attribute value MUST
67+
match a known HTTP method name exactly. Instrumentations for specific web frameworks that consider
68+
HTTP methods to be case insensitive, SHOULD populate a canonical equivalent. Tracing
69+
instrumentations that do so, MUST also set @code http.request.method_original @endcode to the
70+
original value.
6371
*/
6472
static constexpr const char *kHttpRequestMethod = "http.request.method";
6573

api/include/opentelemetry/semconv/incubating/db_attributes.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,10 @@ static constexpr const char *kDbQueryParameter = "db.query.parameter";
417417
instrumentation hooks or other means. If it is not available, instrumentations
418418
that support query parsing SHOULD generate a summary following
419419
<a href="/docs/db/database-spans.md#generating-a-summary-of-the-query">Generating query
420-
summary</a> section.
420+
summary</a> section. <p> For batch operations, if the individual operations are known to have the
421+
same query summary then that query summary SHOULD be used prepended by @code BATCH @endcode,
422+
otherwise @code db.query.summary @endcode SHOULD be @code BATCH @endcode or some other database
423+
system specific term if more applicable.
421424
*/
422425
static constexpr const char *kDbQuerySummary = "db.query.summary";
423426

api/include/opentelemetry/semconv/incubating/error_attributes.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ namespace error
2121

2222
/**
2323
A message providing more detail about an error in human-readable form.
24-
<p>
24+
25+
@deprecated
26+
{"note": "Use domain-specific error message attribute. For example, use @code
27+
feature_flag.error.message @endcode for feature flag errors.", "reason": "obsoleted"} <p>
2528
@code error.message @endcode should provide additional context and detail about an error.
2629
It is NOT RECOMMENDED to duplicate the value of @code error.type @endcode in @code error.message
2730
@endcode. It is also NOT RECOMMENDED to duplicate the value of @code exception.message @endcode in
2831
@code error.message @endcode. <p>
2932
@code error.message @endcode is NOT RECOMMENDED for metrics or spans due to its unbounded
3033
cardinality and overlap with span status.
3134
*/
32-
static constexpr const char *kErrorMessage = "error.message";
35+
OPENTELEMETRY_DEPRECATED static constexpr const char *kErrorMessage = "error.message";
3336

3437
/**
3538
Describes a class of error the operation ended with.

api/include/opentelemetry/semconv/incubating/exception_attributes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kExceptionEscaped = "excep
3030

3131
/**
3232
The exception message.
33+
<blockquote>
34+
[!WARNING]
35+
<p>
36+
This attribute may contain sensitive information.</blockquote>
3337
*/
3438
static constexpr const char *kExceptionMessage = "exception.message";
3539

api/include/opentelemetry/semconv/incubating/feature_flag_attributes.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ namespace feature_flag
2525
static constexpr const char *kFeatureFlagContextId = "feature_flag.context.id";
2626

2727
/**
28-
Deprecated, use @code error.message @endcode instead.
28+
A message providing more detail about an error that occurred during feature flag evaluation in
29+
human-readable form.
30+
*/
31+
static constexpr const char *kFeatureFlagErrorMessage = "feature_flag.error.message";
32+
33+
/**
34+
Deprecated, use @code feature_flag.error.message @endcode instead.
2935
3036
@deprecated
31-
{"note": "Replaced by @code error.message @endcode.", "reason": "renamed", "renamed_to":
32-
"error.message"}
37+
{"note": "Replaced by @code feature_flag.error.message @endcode.", "reason": "renamed",
38+
"renamed_to": "feature_flag.error.message"}
3339
*/
3440
OPENTELEMETRY_DEPRECATED static constexpr const char *kFeatureFlagEvaluationErrorMessage =
3541
"feature_flag.evaluation.error.message";

api/include/opentelemetry/semconv/incubating/gcp_attributes.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,26 @@ static constexpr const char *kGcpGceInstanceHostname = "gcp.gce.instance.hostnam
180180
*/
181181
static constexpr const char *kGcpGceInstanceName = "gcp.gce.instance.name";
182182

183+
/**
184+
The name of the Instance Group Manager (IGM) that manages this VM, if any.
185+
*/
186+
static constexpr const char *kGcpGceInstanceGroupManagerName =
187+
"gcp.gce.instance_group_manager.name";
188+
189+
/**
190+
The region of a <strong>regional</strong> Instance Group Manager (e.g., @code us-central1
191+
@endcode). Set this <strong>only</strong> when the IGM is regional.
192+
*/
193+
static constexpr const char *kGcpGceInstanceGroupManagerRegion =
194+
"gcp.gce.instance_group_manager.region";
195+
196+
/**
197+
The zone of a <strong>zonal</strong> Instance Group Manager (e.g., @code us-central1-a @endcode).
198+
Set this <strong>only</strong> when the IGM is zonal.
199+
*/
200+
static constexpr const char *kGcpGceInstanceGroupManagerZone =
201+
"gcp.gce.instance_group_manager.zone";
202+
183203
namespace GcpApphubServiceCriticalityTypeValues
184204
{
185205
/**

api/include/opentelemetry/semconv/incubating/gen_ai_attributes.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ static constexpr const char *kGenAiAgentId = "gen_ai.agent.id";
3434
*/
3535
static constexpr const char *kGenAiAgentName = "gen_ai.agent.name";
3636

37+
/**
38+
The version of the GenAI agent.
39+
*/
40+
static constexpr const char *kGenAiAgentVersion = "gen_ai.agent.version";
41+
3742
/**
3843
Deprecated, use Event API to report completions contents.
3944
@@ -311,6 +316,27 @@ static constexpr const char *kGenAiResponseId = "gen_ai.response.id";
311316
*/
312317
static constexpr const char *kGenAiResponseModel = "gen_ai.response.model";
313318

319+
/**
320+
The documents retrieved.
321+
<p>
322+
Instrumentations MUST follow <a href="/docs/gen-ai/gen-ai-retrieval-documents.json">Retrieval
323+
documents JSON schema</a>. When the attribute is recorded on events, it MUST be recorded in
324+
structured form. When recorded on spans, it MAY be recorded as a JSON string if structured format
325+
is not supported and SHOULD be recorded in structured form otherwise. <p> Each document object
326+
SHOULD contain at least the following properties:
327+
@code id @endcode (string): A unique identifier for the document, @code score @endcode (double):
328+
The relevance score of the document
329+
*/
330+
static constexpr const char *kGenAiRetrievalDocuments = "gen_ai.retrieval.documents";
331+
332+
/**
333+
The query text used for retrieval.
334+
<blockquote>
335+
[!Warning]
336+
This attribute may contain sensitive information.</blockquote>
337+
*/
338+
static constexpr const char *kGenAiRetrievalQueryText = "gen_ai.retrieval.query.text";
339+
314340
/**
315341
Deprecated, use @code gen_ai.provider.name @endcode instead.
316342
@@ -418,6 +444,22 @@ static constexpr const char *kGenAiToolName = "gen_ai.tool.name";
418444
*/
419445
static constexpr const char *kGenAiToolType = "gen_ai.tool.type";
420446

447+
/**
448+
The number of input tokens written to a provider-managed cache.
449+
<p>
450+
The value SHOULD be included in @code gen_ai.usage.input_tokens @endcode.
451+
*/
452+
static constexpr const char *kGenAiUsageCacheCreationInputTokens =
453+
"gen_ai.usage.cache_creation.input_tokens";
454+
455+
/**
456+
The number of input tokens served from a provider-managed cache.
457+
<p>
458+
The value SHOULD be included in @code gen_ai.usage.input_tokens @endcode.
459+
*/
460+
static constexpr const char *kGenAiUsageCacheReadInputTokens =
461+
"gen_ai.usage.cache_read.input_tokens";
462+
421463
/**
422464
Deprecated, use @code gen_ai.usage.output_tokens @endcode instead.
423465
@@ -430,6 +472,11 @@ OPENTELEMETRY_DEPRECATED static constexpr const char *kGenAiUsageCompletionToken
430472

431473
/**
432474
The number of tokens used in the GenAI input (prompt).
475+
<p>
476+
This value SHOULD include all types of input tokens, including cached tokens.
477+
Instrumentations SHOULD make a best effort to populate this value, using a total
478+
provided by the provider when available or, depending on the provider API,
479+
by summing different token types parsed from the provider output.
433480
*/
434481
static constexpr const char *kGenAiUsageInputTokens = "gen_ai.usage.input_tokens";
435482

@@ -509,6 +556,13 @@ static constexpr const char *kTextCompletion = "text_completion";
509556
*/
510557
static constexpr const char *kEmbeddings = "embeddings";
511558

559+
/**
560+
Retrieval operation such as <a
561+
href="https://platform.openai.com/docs/api-reference/vector-stores/search">OpenAI Search Vector
562+
Store API</a>
563+
*/
564+
static constexpr const char *kRetrieval = "retrieval";
565+
512566
/**
513567
Create GenAI agent
514568
*/

0 commit comments

Comments
 (0)