Skip to content

Commit d5b253a

Browse files
lmolkovaxrmx
authored andcommitted
bump semconv to v1.40.0 (open-telemetry#4941)
* update semconv to v1.40.0 * changelog * changelog * Apply suggestion from @lmolkova * rufF --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
1 parent 5a5ceb9 commit d5b253a

24 files changed

Lines changed: 534 additions & 82 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
## Unreleased
1414

15+
- bump semantic-conventions to v1.40.0
16+
([#4941](https://github.com/open-telemetry/opentelemetry-python/pull/4941))
1517
- Add stale PR GitHub Action
1618
([#4926](https://github.com/open-telemetry/opentelemetry-python/pull/4926))
1719
- `opentelemetry-sdk`: Drop unused Jaeger exporter environment variables (exporter removed in 1.22.0)

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/error_attributes.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@
1919

2020
ERROR_MESSAGE: Final = "error.message"
2121
"""
22-
A message providing more detail about an error in human-readable form.
23-
Note: `error.message` should provide additional context and detail about an error.
24-
It is NOT RECOMMENDED to duplicate the value of `error.type` in `error.message`.
25-
It is also NOT RECOMMENDED to duplicate the value of `exception.message` in `error.message`.
26-
27-
`error.message` is NOT RECOMMENDED for metrics or spans due to its unbounded cardinality and overlap with span status.
22+
Deprecated: Use domain-specific error message attribute. For example, use `feature_flag.error.message` for feature flag errors.
2823
"""
2924

3025
ERROR_TYPE: Final = "error.type"

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/feature_flag_attributes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@
2222
The unique identifier for the flag evaluation context. For example, the targeting key.
2323
"""
2424

25+
FEATURE_FLAG_ERROR_MESSAGE: Final = "feature_flag.error.message"
26+
"""
27+
A message providing more detail about an error that occurred during feature flag evaluation in human-readable form.
28+
"""
29+
2530
FEATURE_FLAG_EVALUATION_ERROR_MESSAGE: Final = (
2631
"feature_flag.evaluation.error.message"
2732
)
2833
"""
29-
Deprecated: Replaced by `error.message`.
34+
Deprecated: Replaced by `feature_flag.error.message`.
3035
"""
3136

3237
FEATURE_FLAG_EVALUATION_REASON: Final = "feature_flag.evaluation.reason"

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/gcp_attributes.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,27 @@
159159
The instance name of a GCE instance. This is the value provided by `host.name`, the visible name of the instance in the Cloud Console UI, and the prefix for the default hostname of the instance as defined by the [default internal DNS name](https://cloud.google.com/compute/docs/internal-dns#instance-fully-qualified-domain-names).
160160
"""
161161

162+
GCP_GCE_INSTANCE_GROUP_MANAGER_NAME: Final = (
163+
"gcp.gce.instance_group_manager.name"
164+
)
165+
"""
166+
The name of the Instance Group Manager (IGM) that manages this VM, if any.
167+
"""
168+
169+
GCP_GCE_INSTANCE_GROUP_MANAGER_REGION: Final = (
170+
"gcp.gce.instance_group_manager.region"
171+
)
172+
"""
173+
The region of a **regional** Instance Group Manager (e.g., `us-central1`). Set this **only** when the IGM is regional.
174+
"""
175+
176+
GCP_GCE_INSTANCE_GROUP_MANAGER_ZONE: Final = (
177+
"gcp.gce.instance_group_manager.zone"
178+
)
179+
"""
180+
The zone of a **zonal** Instance Group Manager (e.g., `us-central1-a`). Set this **only** when the IGM is zonal.
181+
"""
182+
162183

163184
class GcpApphubServiceCriticalityTypeValues(Enum):
164185
MISSION_CRITICAL = "MISSION_CRITICAL"

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/gen_ai_attributes.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
Human-readable name of the GenAI agent provided by the application.
3333
"""
3434

35+
GEN_AI_AGENT_VERSION: Final = "gen_ai.agent.version"
36+
"""
37+
The version of the GenAI agent.
38+
"""
39+
3540
GEN_AI_COMPLETION: Final = "gen_ai.completion"
3641
"""
3742
Deprecated: Removed, no replacement at this time.
@@ -268,6 +273,25 @@
268273
The name of the model that generated the response.
269274
"""
270275

276+
GEN_AI_RETRIEVAL_DOCUMENTS: Final = "gen_ai.retrieval.documents"
277+
"""
278+
The documents retrieved.
279+
Note: Instrumentations MUST follow [Retrieval documents JSON schema](/docs/gen-ai/gen-ai-retrieval-documents.json).
280+
When the attribute is recorded on events, it MUST be recorded in structured
281+
form. When recorded on spans, it MAY be recorded as a JSON string if structured
282+
format is not supported and SHOULD be recorded in structured form otherwise.
283+
284+
Each document object SHOULD contain at least the following properties:
285+
`id` (string): A unique identifier for the document, `score` (double): The relevance score of the document.
286+
"""
287+
288+
GEN_AI_RETRIEVAL_QUERY_TEXT: Final = "gen_ai.retrieval.query.text"
289+
"""
290+
The query text used for retrieval.
291+
Note: > [!Warning]
292+
> This attribute may contain sensitive information.
293+
"""
294+
271295
GEN_AI_SYSTEM: Final = "gen_ai.system"
272296
"""
273297
Deprecated: Replaced by `gen_ai.provider.name`.
@@ -364,6 +388,22 @@
364388
Datastore: A tool used by the agent to access and query structured or unstructured external data for retrieval-augmented tasks or knowledge updates.
365389
"""
366390

391+
GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS: Final = (
392+
"gen_ai.usage.cache_creation.input_tokens"
393+
)
394+
"""
395+
The number of input tokens written to a provider-managed cache.
396+
Note: The value SHOULD be included in `gen_ai.usage.input_tokens`.
397+
"""
398+
399+
GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS: Final = (
400+
"gen_ai.usage.cache_read.input_tokens"
401+
)
402+
"""
403+
The number of input tokens served from a provider-managed cache.
404+
Note: The value SHOULD be included in `gen_ai.usage.input_tokens`.
405+
"""
406+
367407
GEN_AI_USAGE_COMPLETION_TOKENS: Final = "gen_ai.usage.completion_tokens"
368408
"""
369409
Deprecated: Replaced by `gen_ai.usage.output_tokens`.
@@ -372,6 +412,10 @@
372412
GEN_AI_USAGE_INPUT_TOKENS: Final = "gen_ai.usage.input_tokens"
373413
"""
374414
The number of tokens used in the GenAI input (prompt).
415+
Note: This value SHOULD include all types of input tokens, including cached tokens.
416+
Instrumentations SHOULD make a best effort to populate this value, using a total
417+
provided by the provider when available or, depending on the provider API,
418+
by summing different token types parsed from the provider output.
375419
"""
376420

377421
GEN_AI_USAGE_OUTPUT_TOKENS: Final = "gen_ai.usage.output_tokens"
@@ -416,6 +460,8 @@ class GenAiOperationNameValues(Enum):
416460
"""Text completions operation such as [OpenAI Completions API (Legacy)](https://platform.openai.com/docs/api-reference/completions)."""
417461
EMBEDDINGS = "embeddings"
418462
"""Embeddings operation such as [OpenAI Create embeddings API](https://platform.openai.com/docs/api-reference/embeddings/create)."""
463+
RETRIEVAL = "retrieval"
464+
"""Retrieval operation such as [OpenAI Search Vector Store API](https://platform.openai.com/docs/api-reference/vector-stores/search)."""
419465
CREATE_AGENT = "create_agent"
420466
"""Create GenAI agent."""
421467
INVOKE_AGENT = "invoke_agent"

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/k8s_attributes.py

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,113 @@
468468
The UID of the resource quota.
469469
"""
470470

471+
K8S_SERVICE_ANNOTATION_TEMPLATE: Final = "k8s.service.annotation"
472+
"""
473+
The annotation placed on the Service, the `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
474+
Note: Examples:
475+
476+
- An annotation `prometheus.io/scrape` with value `true` SHOULD be recorded as
477+
the `k8s.service.annotation.prometheus.io/scrape` attribute with value `"true"`.
478+
- An annotation `data` with empty string value SHOULD be recorded as
479+
the `k8s.service.annotation.data` attribute with value `""`.
480+
"""
481+
482+
K8S_SERVICE_ENDPOINT_ADDRESS_TYPE: Final = "k8s.service.endpoint.address_type"
483+
"""
484+
The address type of the service endpoint.
485+
Note: The network address family or type of the endpoint.
486+
This attribute aligns with the `addressType` field of the
487+
[K8s EndpointSlice](https://kubernetes.io/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/).
488+
It is used to differentiate metrics when a Service is backed by multiple address types
489+
(e.g., in dual-stack clusters).
490+
"""
491+
492+
K8S_SERVICE_ENDPOINT_CONDITION: Final = "k8s.service.endpoint.condition"
493+
"""
494+
The condition of the service endpoint.
495+
Note: The current operational condition of the service endpoint.
496+
An endpoint can have multiple conditions set at once (e.g., both `serving` and `terminating` during rollout).
497+
This attribute aligns with the condition fields in the [K8s EndpointSlice](https://kubernetes.io/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/).
498+
"""
499+
500+
K8S_SERVICE_ENDPOINT_ZONE: Final = "k8s.service.endpoint.zone"
501+
"""
502+
The zone of the service endpoint.
503+
Note: The zone where the endpoint is located, typically corresponding to a failure domain.
504+
This attribute aligns with the `zone` field of endpoints in the
505+
[K8s EndpointSlice](https://kubernetes.io/docs/reference/kubernetes-api/service-resources/endpoint-slice-v1/).
506+
It enables zone-aware monitoring of service endpoint distribution and supports
507+
features like [Topology Aware Routing](https://kubernetes.io/docs/concepts/services-networking/topology-aware-routing/).
508+
509+
If the zone is not populated (e.g., nodes without the `topology.kubernetes.io/zone` label),
510+
the attribute value will be an empty string.
511+
"""
512+
513+
K8S_SERVICE_LABEL_TEMPLATE: Final = "k8s.service.label"
514+
"""
515+
The label placed on the Service, the `<key>` being the label name, the value being the label value, even if the value is empty.
516+
Note: Examples:
517+
518+
- A label `app` with value `my-service` SHOULD be recorded as
519+
the `k8s.service.label.app` attribute with value `"my-service"`.
520+
- A label `data` with empty string value SHOULD be recorded as
521+
the `k8s.service.label.data` attribute with value `""`.
522+
"""
523+
524+
K8S_SERVICE_NAME: Final = "k8s.service.name"
525+
"""
526+
The name of the Service.
527+
"""
528+
529+
K8S_SERVICE_PUBLISH_NOT_READY_ADDRESSES: Final = (
530+
"k8s.service.publish_not_ready_addresses"
531+
)
532+
"""
533+
Whether the Service publishes not-ready endpoints.
534+
Note: Whether the Service is configured to publish endpoints before the pods are ready.
535+
This attribute is typically used to indicate that a Service (such as a headless
536+
Service for a StatefulSet) allows peer discovery before pods pass their readiness probes.
537+
It aligns with the `publishNotReadyAddresses` field of the
538+
[K8s ServiceSpec](https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/#ServiceSpec).
539+
"""
540+
541+
K8S_SERVICE_SELECTOR_TEMPLATE: Final = "k8s.service.selector"
542+
"""
543+
The selector key-value pair placed on the Service, the `<key>` being the selector key, the value being the selector value.
544+
Note: These selectors are used to correlate with pod labels. Each selector key-value pair becomes a separate attribute.
545+
546+
Examples:
547+
548+
- A selector `app=my-app` SHOULD be recorded as
549+
the `k8s.service.selector.app` attribute with value `"my-app"`.
550+
- A selector `version=v1` SHOULD be recorded as
551+
the `k8s.service.selector.version` attribute with value `"v1"`.
552+
"""
553+
554+
K8S_SERVICE_TRAFFIC_DISTRIBUTION: Final = "k8s.service.traffic_distribution"
555+
"""
556+
The traffic distribution policy for the Service.
557+
Note: Specifies how traffic is distributed to endpoints for this Service.
558+
This attribute aligns with the `trafficDistribution` field of the
559+
[K8s ServiceSpec](https://kubernetes.io/docs/reference/networking/virtual-ips/#traffic-distribution).
560+
Known values include `PreferSameZone` (prefer endpoints in the same zone as the client) and
561+
`PreferSameNode` (prefer endpoints on the same node, fallback to same zone, then cluster-wide).
562+
If this field is not set on the Service, the attribute SHOULD NOT be emitted.
563+
When not set, Kubernetes distributes traffic evenly across all endpoints cluster-wide.
564+
"""
565+
566+
K8S_SERVICE_TYPE: Final = "k8s.service.type"
567+
"""
568+
The type of the Kubernetes Service.
569+
Note: This attribute aligns with the `type` field of the
570+
[K8s ServiceSpec](https://kubernetes.io/docs/reference/kubernetes-api/service-resources/service-v1/#ServiceSpec).
571+
"""
572+
573+
K8S_SERVICE_UID: Final = "k8s.service.uid"
574+
"""
575+
The UID of the Service.
576+
"""
577+
471578
K8S_STATEFULSET_ANNOTATION_TEMPLATE: Final = "k8s.statefulset.annotation"
472579
"""
473580
The annotation placed on the StatefulSet, the `<key>` being the annotation name, the value being the annotation value, even if the value is empty.
@@ -601,6 +708,35 @@ class K8sPodStatusReasonValues(Enum):
601708
"""The pod was rejected admission to the node because of an error during admission that could not be categorized."""
602709

603710

711+
class K8sServiceEndpointAddressTypeValues(Enum):
712+
IPV4 = "IPv4"
713+
"""IPv4 address type."""
714+
IPV6 = "IPv6"
715+
"""IPv6 address type."""
716+
FQDN = "FQDN"
717+
"""FQDN address type."""
718+
719+
720+
class K8sServiceEndpointConditionValues(Enum):
721+
READY = "ready"
722+
"""The endpoint is ready to receive new connections."""
723+
SERVING = "serving"
724+
"""The endpoint is currently handling traffic."""
725+
TERMINATING = "terminating"
726+
"""The endpoint is in the process of shutting down."""
727+
728+
729+
class K8sServiceTypeValues(Enum):
730+
CLUSTER_IP = "ClusterIP"
731+
"""ClusterIP service type."""
732+
NODE_PORT = "NodePort"
733+
"""NodePort service type."""
734+
LOAD_BALANCER = "LoadBalancer"
735+
"""LoadBalancer service type."""
736+
EXTERNAL_NAME = "ExternalName"
737+
"""ExternalName service type."""
738+
739+
604740
class K8sVolumeTypeValues(Enum):
605741
PERSISTENT_VOLUME_CLAIM = "persistentVolumeClaim"
606742
"""A [persistentVolumeClaim](https://v1-30.docs.kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim) volume."""

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/message_attributes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@
1919

2020
MESSAGE_COMPRESSED_SIZE: Final = "message.compressed_size"
2121
"""
22-
Deprecated: Replaced by `rpc.message.compressed_size`.
22+
Deprecated: Deprecated, no replacement at this time.
2323
"""
2424

2525
MESSAGE_ID: Final = "message.id"
2626
"""
27-
Deprecated: Replaced by `rpc.message.id`.
27+
Deprecated: Deprecated, no replacement at this time.
2828
"""
2929

3030
MESSAGE_TYPE: Final = "message.type"
3131
"""
32-
Deprecated: Replaced by `rpc.message.type`.
32+
Deprecated: Deprecated, no replacement at this time.
3333
"""
3434

3535
MESSAGE_UNCOMPRESSED_SIZE: Final = "message.uncompressed_size"
3636
"""
37-
Deprecated: Replaced by `rpc.message.uncompressed_size`.
37+
Deprecated: Deprecated, no replacement at this time.
3838
"""
3939

4040

4141
@deprecated(
42-
"The attribute message.type is deprecated - Replaced by `rpc.message.type`"
42+
"The attribute message.type is deprecated - Deprecated, no replacement at this time"
4343
)
4444
class MessageTypeValues(Enum):
4545
SENT = "SENT"

opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/openai_attributes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
from enum import Enum
1616
from typing import Final
1717

18+
OPENAI_API_TYPE: Final = "openai.api.type"
19+
"""
20+
The type of OpenAI API being used.
21+
"""
22+
1823
OPENAI_REQUEST_SERVICE_TIER: Final = "openai.request.service_tier"
1924
"""
2025
The service tier requested. May be a specific tier, default, or auto.
@@ -33,6 +38,13 @@
3338
"""
3439

3540

41+
class OpenaiApiTypeValues(Enum):
42+
CHAT_COMPLETIONS = "chat_completions"
43+
"""The OpenAI [Chat Completions API](https://developers.openai.com/api/reference/chat-completions/overview)."""
44+
RESPONSES = "responses"
45+
"""The OpenAI [Responses API](https://developers.openai.com/api/reference/responses/overview)."""
46+
47+
3648
class OpenaiRequestServiceTierValues(Enum):
3749
AUTO = "auto"
3850
"""The system will utilize scale tier credits until they are exhausted."""

0 commit comments

Comments
 (0)