From 8559e5fb51c488ce48a1bf43b312f68af1c55b19 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Tue, 11 Jun 2024 10:02:06 +0200 Subject: [PATCH 1/2] opentelemetry-semantic-conventions: bump to v1.26.0 We need to add the deprecated messaging.client_id to the EXCLUDED_ATTRIBUTES in order to avoid a name clash with messaging.client.id. --- CHANGELOG.md | 4 +- .../attributes/container_attributes.py | 2 +- .../_incubating/attributes/db_attributes.py | 82 +++++-- .../attributes/event_attributes.py | 2 +- .../attributes/gen_ai_attributes.py | 84 +++++++ .../_incubating/attributes/http_attributes.py | 29 +++ .../_incubating/attributes/k8s_attributes.py | 7 + .../attributes/message_attributes.py | 12 +- .../attributes/messaging_attributes.py | 45 +++- .../_incubating/attributes/net_attributes.py | 10 + .../attributes/other_attributes.py | 5 +- .../_incubating/attributes/pool_attributes.py | 2 +- .../attributes/process_attributes.py | 68 +++++- .../_incubating/attributes/rpc_attributes.py | 28 +++ .../attributes/system_attributes.py | 2 +- .../_incubating/attributes/url_attributes.py | 5 + .../semconv/_incubating/metrics/db_metrics.py | 228 +++++++++++++++--- .../_incubating/metrics/system_metrics.py | 19 ++ .../semconv/attributes/error_attributes.py | 6 +- .../attributes/exception_attributes.py | 2 +- .../semconv/attributes/service_attributes.py | 2 +- .../src/opentelemetry/semconv/schemas.py | 5 + scripts/semconv/generate.sh | 4 +- 23 files changed, 578 insertions(+), 75 deletions(-) create mode 100644 opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/gen_ai_attributes.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ca39671a02..020ffcc8a06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased + - Log a warning when a `LogRecord` in `sdk/log` has dropped attributes due to reaching limits ([#3946](https://github.com/open-telemetry/opentelemetry-python/pull/3946)) - - Fix RandomIdGenerator can generate invalid Span/Trace Ids ([#3949](https://github.com/open-telemetry/opentelemetry-python/pull/3949)) - Add Python 3.12 to tox @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - add `Final` decorator to constants to prevent collisions - enable mypy and fix detected issues - allow to drop specific attributes in preparation for Semantic Conventions v1.26.0 + ([#3973](https://github.com/open-telemetry/opentelemetry-python/pull/3966)) +- Update semantic conventions to version 1.26.0. ([#3964](https://github.com/open-telemetry/opentelemetry-python/pull/3964)) ## Version 1.25.0/0.46b0 (2024-05-30) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/container_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/container_attributes.py index 8cf281b408c..fbb74a1b144 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/container_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/container_attributes.py @@ -46,7 +46,7 @@ Runtime specific image identifier. Usually a hash algorithm followed by a UUID. Note: Docker defines a sha256 of the image id; `container.image.id` corresponds to the `Image` field from the Docker container inspect [API](https://docs.docker.com/engine/api/v1.43/#tag/Container/operation/ContainerInspect) endpoint. K8s defines a link to the container registry repository with digest `"imageID": "registry.azurecr.io /namespace/service/dockerfile@sha256:bdeabd40c3a8a492eaf9e8e44d0ebbb84bac7ee25ac0cf8a7159d25f62555625"`. - The ID is assinged by the container runtime and can vary in different environments. Consider using `oci.manifest.digest` if it is important to identify the same image in different environments/runtimes. + The ID is assigned by the container runtime and can vary in different environments. Consider using `oci.manifest.digest` if it is important to identify the same image in different environments/runtimes. """ CONTAINER_IMAGE_NAME: Final = "container.image.name" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/db_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/db_attributes.py index 45aa580ade5..86db338a3e7 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/db_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/db_attributes.py @@ -49,8 +49,24 @@ DB_CASSANDRA_TABLE: Final = "db.cassandra.table" """ -The name of the primary Cassandra table that the operation is acting upon, including the keyspace name (if applicable). -Note: This mirrors the db.sql.table attribute but references cassandra rather than sql. It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set. +Deprecated: Replaced by `db.collection.name`. +""" + +DB_CLIENT_CONNECTIONS_POOL_NAME: Final = "db.client.connections.pool.name" +""" +The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. +""" + +DB_CLIENT_CONNECTIONS_STATE: Final = "db.client.connections.state" +""" +The state of a connection in the pool. +""" + +DB_COLLECTION_NAME: Final = "db.collection.name" +""" +The name of a collection (table, container) within the database. +Note: If the collection name is parsed from the query, it SHOULD match the value provided in the query and may be qualified with the schema and database name. + It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. """ DB_CONNECTION_STRING: Final = "db.connection_string" @@ -70,7 +86,7 @@ DB_COSMOSDB_CONTAINER: Final = "db.cosmosdb.container" """ -Cosmos DB container name. +Deprecated: Replaced by `db.collection.name`. """ DB_COSMOSDB_OPERATION_TYPE: Final = "db.cosmosdb.operation_type" @@ -107,7 +123,7 @@ DB_ELASTICSEARCH_NODE_NAME: Final = "db.elasticsearch.node.name" """ -Deprecated: Replaced by `db.instance.id`. +Represents the human-readable identifier of the node/instance to which a request was routed. """ DB_ELASTICSEARCH_PATH_PARTS_TEMPLATE: Final = "db.elasticsearch.path_parts" @@ -118,7 +134,7 @@ DB_INSTANCE_ID: Final = "db.instance.id" """ -An identifier (address, unique name, or any other identifier) of the database instance that is executing queries or mutations on the current connection. This is useful in cases where the database is running in a clustered environment and the instrumentation is able to record the node executing the query. The client may obtain this value in databases like MySQL using queries like `select @@hostname`. +Deprecated: Deprecated, no general replacement at this time. For Elasticsearch, use `db.elasticsearch.node.name` instead. """ DB_JDBC_DRIVER_CLASSNAME: Final = "db.jdbc.driver_classname" @@ -128,51 +144,74 @@ DB_MONGODB_COLLECTION: Final = "db.mongodb.collection" """ -The MongoDB collection being accessed within the database stated in `db.name`. +Deprecated: Replaced by `db.collection.name`. """ DB_MSSQL_INSTANCE_NAME: Final = "db.mssql.instance_name" """ -The Microsoft SQL Server [instance name](https://docs.microsoft.com/sql/connect/jdbc/building-the-connection-url?view=sql-server-ver15) connecting to. This name is used to determine the port of a named instance. -Note: If setting a `db.mssql.instance_name`, `server.port` is no longer required (but still recommended if non-standard). +Deprecated: Deprecated, no replacement at this time. """ DB_NAME: Final = "db.name" """ -This attribute is used to report the name of the database being accessed. For commands that switch the database, this should be set to the target database (even if the command fails). -Note: In some SQL databases, the database name to be used is called "schema name". In case there are multiple layers that could be considered for database name (e.g. Oracle instance name and schema name), the database name to be used is the more specific layer (e.g. Oracle schema name). +Deprecated: Replaced by `db.namespace`. +""" + +DB_NAMESPACE: Final = "db.namespace" +""" +The name of the database, fully qualified within the server address and port. +Note: If a database system has multiple namespace components, they SHOULD be concatenated (potentially using database system specific conventions) from most general to most specific namespace component, and more specific namespaces SHOULD NOT be captured without the more general namespaces, to ensure that "startswith" queries for the more general namespaces will be valid. + Semantic conventions for individual database systems SHOULD document what `db.namespace` means in the context of that system. + It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. """ DB_OPERATION: Final = "db.operation" """ -The name of the operation being executed, e.g. the [MongoDB command name](https://docs.mongodb.com/manual/reference/command/#database-operations) such as `findAndModify`, or the SQL keyword. -Note: When setting this to an SQL keyword, it is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if the operation name is provided by the library being instrumented. If the SQL statement has an ambiguous operation, or performs more than one operation, this value may be omitted. +Deprecated: Replaced by `db.operation.name`. +""" + +DB_OPERATION_NAME: Final = "db.operation.name" +""" +The name of the operation or command being executed. +Note: It is RECOMMENDED to capture the value as provided by the application without attempting to do any case normalization. +""" + +DB_QUERY_PARAMETER_TEMPLATE: Final = "db.query.parameter" +""" +The query parameters used in `db.query.text`, with `` being the parameter name, and the attribute value being the parameter value. +Note: Query parameters should only be captured when `db.query.text` is parameterized with placeholders. + If a parameter has no name and instead is referenced only by index, then `` SHOULD be the 0-based index. +""" + +DB_QUERY_TEXT: Final = "db.query.text" +""" +The database query being executed. """ DB_REDIS_DATABASE_INDEX: Final = "db.redis.database_index" """ -The index of the database being accessed as used in the [`SELECT` command](https://redis.io/commands/select), provided as an integer. To be used instead of the generic `db.name` attribute. +Deprecated: Replaced by `db.namespace`. """ DB_SQL_TABLE: Final = "db.sql.table" """ -The name of the primary table that the operation is acting upon, including the database name (if applicable). -Note: It is not recommended to attempt any client-side parsing of `db.statement` just to get this property, but it should be set if it is provided by the library being instrumented. If the operation is acting upon an anonymous table, or more than one table, this value MUST NOT be set. +Deprecated: Replaced by `db.collection.name`. """ DB_STATEMENT: Final = "db.statement" """ -The database statement being executed. +Deprecated: Replaced by `db.query.text`. """ DB_SYSTEM: Final = "db.system" """ -An identifier for the database management system (DBMS) product being used. See below for a list of well-known identifiers. +The database management system (DBMS) product as identified by the client instrumentation. +Note: The actual DBMS may differ from the one identified by the client. For example, when using PostgreSQL client libraries to connect to a CockroachDB, the `db.system` is set to `postgresql` based on the instrumentation's best knowledge. """ DB_USER: Final = "db.user" """ -Username for accessing the database. +Deprecated: No replacement at this time. """ @@ -201,6 +240,13 @@ class DbCassandraConsistencyLevelValues(Enum): """local_serial.""" +class DbClientConnectionsStateValues(Enum): + IDLE: Final = "idle" + """idle.""" + USED: Final = "used" + """used.""" + + class DbCosmosdbConnectionModeValues(Enum): GATEWAY: Final = "gateway" """Gateway (HTTP) connections mode.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/event_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/event_attributes.py index b2d0c22c082..7950283d6a6 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/event_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/event_attributes.py @@ -17,5 +17,5 @@ EVENT_NAME: Final = "event.name" """ Identifies the class / type of event. -Note: Event names are subject to the same rules as [attribute names](https://github.com/open-telemetry/opentelemetry-specification/tree/v1.31.0/specification/common/attribute-naming.md). Notably, event names are namespaced to avoid collisions and provide a clean separation of semantics for events in separate domains like browser, mobile, and kubernetes. +Note: Event names are subject to the same rules as [attribute names](https://github.com/open-telemetry/opentelemetry-specification/tree/v1.33.0/specification/common/attribute-naming.md). Notably, event names are namespaced to avoid collisions and provide a clean separation of semantics for events in separate domains like browser, mobile, and kubernetes. """ diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/gen_ai_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/gen_ai_attributes.py new file mode 100644 index 00000000000..d8b60f52f0f --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/gen_ai_attributes.py @@ -0,0 +1,84 @@ +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from enum import Enum +from typing import Final + +GEN_AI_COMPLETION: Final = "gen_ai.completion" +""" +The full response received from the LLM. +Note: It's RECOMMENDED to format completions as JSON string matching [OpenAI messages format](https://platform.openai.com/docs/guides/text-generation). +""" + +GEN_AI_PROMPT: Final = "gen_ai.prompt" +""" +The full prompt sent to an LLM. +Note: It's RECOMMENDED to format prompts as JSON string matching [OpenAI messages format](https://platform.openai.com/docs/guides/text-generation). +""" + +GEN_AI_REQUEST_MAX_TOKENS: Final = "gen_ai.request.max_tokens" +""" +The maximum number of tokens the LLM generates for a request. +""" + +GEN_AI_REQUEST_MODEL: Final = "gen_ai.request.model" +""" +The name of the LLM a request is being made to. +""" + +GEN_AI_REQUEST_TEMPERATURE: Final = "gen_ai.request.temperature" +""" +The temperature setting for the LLM request. +""" + +GEN_AI_REQUEST_TOP_P: Final = "gen_ai.request.top_p" +""" +The top_p sampling setting for the LLM request. +""" + +GEN_AI_RESPONSE_FINISH_REASONS: Final = "gen_ai.response.finish_reasons" +""" +Array of reasons the model stopped generating tokens, corresponding to each generation received. +""" + +GEN_AI_RESPONSE_ID: Final = "gen_ai.response.id" +""" +The unique identifier for the completion. +""" + +GEN_AI_RESPONSE_MODEL: Final = "gen_ai.response.model" +""" +The name of the LLM a response was generated from. +""" + +GEN_AI_SYSTEM: Final = "gen_ai.system" +""" +The Generative AI product as identified by the client instrumentation. +Note: The actual GenAI product may differ from the one identified by the client. For example, when using OpenAI client libraries to communicate with Mistral, the `gen_ai.system` is set to `openai` based on the instrumentation's best knowledge. +""" + +GEN_AI_USAGE_COMPLETION_TOKENS: Final = "gen_ai.usage.completion_tokens" +""" +The number of tokens used in the LLM response (completion). +""" + +GEN_AI_USAGE_PROMPT_TOKENS: Final = "gen_ai.usage.prompt_tokens" +""" +The number of tokens used in the LLM prompt. +""" + + +class GenAiSystemValues(Enum): + OPENAI: Final = "openai" + """OpenAI.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/http_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/http_attributes.py index ee1bbf0b262..74cacb51089 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/http_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/http_attributes.py @@ -17,6 +17,11 @@ from deprecated import deprecated +HTTP_CLIENT_IP: Final = "http.client_ip" +""" +Deprecated: Replaced by `client.address`. +""" + HTTP_CONNECTION_STATE: Final = "http.connection.state" """ State of the HTTP connection in the HTTP connection pool. @@ -27,6 +32,11 @@ Deprecated: Replaced by `network.protocol.name`. """ +HTTP_HOST: Final = "http.host" +""" +Deprecated: Replaced by one of `server.address`, `client.address` or `http.request.header.host`, depending on the usage. +""" + HTTP_METHOD: Final = "http.method" """ Deprecated: Replaced by `http.request.method`. @@ -67,6 +77,13 @@ Deprecated: Replaced by `http.request.header.content-length`. """ +HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED: Final = ( + "http.request_content_length_uncompressed" +) +""" +Deprecated: Replaced by `http.request.body.size`. +""" + HTTP_RESPONSE_BODY_SIZE: Final = "http.response.body.size" """ The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size. @@ -92,6 +109,13 @@ Deprecated: Replaced by `http.response.header.content-length`. """ +HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED: Final = ( + "http.response_content_length_uncompressed" +) +""" +Deprecated: Replace by `http.response.body.size`. +""" + HTTP_ROUTE: Final = "http.route" """ Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HTTP_ROUTE`. @@ -102,6 +126,11 @@ Deprecated: Replaced by `url.scheme` instead. """ +HTTP_SERVER_NAME: Final = "http.server_name" +""" +Deprecated: Replaced by `server.address`. +""" + HTTP_STATUS_CODE: Final = "http.status_code" """ Deprecated: Replaced by `http.response.status_code`. diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/k8s_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/k8s_attributes.py index 1ea56350199..f5faf841811 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/k8s_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/k8s_attributes.py @@ -56,6 +56,13 @@ Number of times the container was restarted. This attribute can be used to identify a particular container (running or stopped) within a container spec. """ +K8S_CONTAINER_STATUS_LAST_TERMINATED_REASON: Final = ( + "k8s.container.status.last_terminated_reason" +) +""" +Last terminated reason of the Container. +""" + K8S_CRONJOB_NAME: Final = "k8s.cronjob.name" """ The name of the CronJob. diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/message_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/message_attributes.py index 90c8efff2ca..1124daaee17 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/message_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/message_attributes.py @@ -15,28 +15,30 @@ from enum import Enum from typing import Final +from deprecated import deprecated + MESSAGE_COMPRESSED_SIZE: Final = "message.compressed_size" """ -Compressed size of the message in bytes. +Deprecated: Replaced by `rpc.message.compressed_size`. """ MESSAGE_ID: Final = "message.id" """ -MUST be calculated as two different counters starting from `1` one for sent messages and one for received message. -Note: This way we guarantee that the values will be consistent between different implementations. +Deprecated: Replaced by `rpc.message.id`. """ MESSAGE_TYPE: Final = "message.type" """ -Whether this is a received or sent message. +Deprecated: Replaced by `rpc.message.type`. """ MESSAGE_UNCOMPRESSED_SIZE: Final = "message.uncompressed_size" """ -Uncompressed size of the message in bytes. +Deprecated: Replaced by `rpc.message.uncompressed_size`. """ +@deprecated(reason="The attribute message.type is deprecated - Replaced by `rpc.message.type`") # type: ignore class MessageTypeValues(Enum): SENT: Final = "SENT" """sent.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py index e36d2ec9429..906e12ea640 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py @@ -21,11 +21,16 @@ Note: Instrumentations SHOULD NOT set `messaging.batch.message_count` on spans that operate with a single message. When a messaging client library supports both batch and single-message API for the same operation, instrumentations SHOULD use `messaging.batch.message_count` for batching APIs and SHOULD NOT use it for single-message APIs. """ -MESSAGING_CLIENT_ID: Final = "messaging.client_id" +MESSAGING_CLIENT_ID: Final = "messaging.client.id" """ A unique identifier for the client that consumes or produces a message. """ +# MESSAGING_CLIENT_ID: Final = "messaging.client_id" +""" +Deprecated: Replaced by `messaging.client.id`. +""" + MESSAGING_DESTINATION_ANONYMOUS: Final = "messaging.destination.anonymous" """ A boolean that is true if the message destination is anonymous (could be unnamed or have auto-generated name). @@ -86,6 +91,27 @@ The UTC epoch seconds at which the message has been accepted and stored in the entity. """ +MESSAGING_GCP_PUBSUB_MESSAGE_ACK_DEADLINE: Final = ( + "messaging.gcp_pubsub.message.ack_deadline" +) +""" +The ack deadline in seconds set for the modify ack deadline request. +""" + +MESSAGING_GCP_PUBSUB_MESSAGE_ACK_ID: Final = ( + "messaging.gcp_pubsub.message.ack_id" +) +""" +The ack id for a given message. +""" + +MESSAGING_GCP_PUBSUB_MESSAGE_DELIVERY_ATTEMPT: Final = ( + "messaging.gcp_pubsub.message.delivery_attempt" +) +""" +The delivery attempt for a given message. +""" + MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY: Final = ( "messaging.gcp_pubsub.message.ordering_key" ) @@ -147,7 +173,17 @@ MESSAGING_OPERATION: Final = "messaging.operation" """ -A string identifying the kind of messaging operation. +Deprecated: Replaced by `messaging.operation.type`. +""" + +MESSAGING_OPERATION_NAME: Final = "messaging.operation.name" +""" +The system-specific name of the messaging operation. +""" + +MESSAGING_OPERATION_TYPE: Final = "messaging.operation.type" +""" +A string identifying the type of the messaging operation. Note: If a custom value is used, it MUST be of low cardinality. """ @@ -246,11 +282,12 @@ MESSAGING_SYSTEM: Final = "messaging.system" """ -An identifier for the messaging system being used. See below for a list of well-known identifiers. +The messaging system as identified by the client instrumentation. +Note: The actual messaging system may differ from the one known by the client. For example, when using Kafka client libraries to communicate with Azure Event Hubs, the `messaging.system` is set to `kafka` based on the instrumentation's best knowledge. """ -class MessagingOperationValues(Enum): +class MessagingOperationTypeValues(Enum): PUBLISH: Final = "publish" """One or more messages are provided for publishing to an intermediary. If a single message is published, the context of the "Publish" span can be used as the creation context and no "Create" span needs to be created.""" CREATE: Final = "create" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/net_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/net_attributes.py index 1f48da2799d..da0e3828e7e 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/net_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/net_attributes.py @@ -17,6 +17,11 @@ from deprecated import deprecated +NET_HOST_IP: Final = "net.host.ip" +""" +Deprecated: Replaced by `network.local.address`. +""" + NET_HOST_NAME: Final = "net.host.name" """ Deprecated: Replaced by `server.address`. @@ -27,6 +32,11 @@ Deprecated: Replaced by `server.port`. """ +NET_PEER_IP: Final = "net.peer.ip" +""" +Deprecated: Replaced by `network.peer.address`. +""" + NET_PEER_NAME: Final = "net.peer.name" """ Deprecated: Replaced by `server.address` on client spans and `client.address` on server spans. diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/other_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/other_attributes.py index 9600adbf75f..d95b7ec6091 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/other_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/other_attributes.py @@ -15,12 +15,15 @@ from enum import Enum from typing import Final +from deprecated import deprecated + STATE: Final = "state" """ -The state of a connection in the pool. +Deprecated: Replaced by `db.client.connections.state`. """ +@deprecated(reason="The attribute state is deprecated - Replaced by `db.client.connections.state`") # type: ignore class StateValues(Enum): IDLE: Final = "idle" """idle.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/pool_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/pool_attributes.py index a4a02a5fd0f..8feecee761b 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/pool_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/pool_attributes.py @@ -16,5 +16,5 @@ POOL_NAME: Final = "pool.name" """ -The name of the connection pool; unique within the instrumented application. In case the connection pool implementation doesn't provide a name, instrumentation should use a combination of `server.address` and `server.port` attributes formatted as `server.address:server.port`. +Deprecated: Replaced by `db.client.connections.pool.name`. """ diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/process_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/process_attributes.py index b55307102cd..322d694923f 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/process_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/process_attributes.py @@ -37,7 +37,12 @@ PROCESS_CPU_STATE: Final = "process.cpu.state" """ -The CPU state for this data point. A process SHOULD be characterized _either_ by data points with no `state` labels, _or only_ data points with `state` labels. +The CPU state of the process. +""" + +PROCESS_CREATION_TIME: Final = "process.creation.time" +""" +The date and time the process was created, in ISO 8601 format. """ PROCESS_EXECUTABLE_NAME: Final = "process.executable.name" @@ -50,6 +55,26 @@ The full path to the process executable. On Linux based systems, can be set to the target of `proc/[pid]/exe`. On Windows, can be set to the result of `GetProcessImageFileNameW`. """ +PROCESS_EXIT_CODE: Final = "process.exit.code" +""" +The exit code of the process. +""" + +PROCESS_EXIT_TIME: Final = "process.exit.time" +""" +The date and time the process exited, in ISO 8601 format. +""" + +PROCESS_GROUP_LEADER_PID: Final = "process.group_leader.pid" +""" +The PID of the process's group leader. This is also the process group ID (PGID) of the process. +""" + +PROCESS_INTERACTIVE: Final = "process.interactive" +""" +Whether the process is connected to an interactive shell. +""" + PROCESS_OWNER: Final = "process.owner" """ The username of the user that owns the process. @@ -70,6 +95,16 @@ Process identifier (PID). """ +PROCESS_REAL_USER_ID: Final = "process.real_user.id" +""" +The real user ID (RUID) of the process. +""" + +PROCESS_REAL_USER_NAME: Final = "process.real_user.name" +""" +The username of the real user of the process. +""" + PROCESS_RUNTIME_DESCRIPTION: Final = "process.runtime.description" """ An additional description about the runtime of the process, for example a specific vendor customization of the runtime environment. @@ -85,6 +120,37 @@ The version of the runtime of this process, as returned by the runtime without modification. """ +PROCESS_SAVED_USER_ID: Final = "process.saved_user.id" +""" +The saved user ID (SUID) of the process. +""" + +PROCESS_SAVED_USER_NAME: Final = "process.saved_user.name" +""" +The username of the saved user. +""" + +PROCESS_SESSION_LEADER_PID: Final = "process.session_leader.pid" +""" +The PID of the process's session leader. This is also the session ID (SID) of the process. +""" + +PROCESS_USER_ID: Final = "process.user.id" +""" +The effective user ID (EUID) of the process. +""" + +PROCESS_USER_NAME: Final = "process.user.name" +""" +The username of the effective user of the process. +""" + +PROCESS_VPID: Final = "process.vpid" +""" +Virtual process identifier. +Note: The process ID within a PID namespace. This is not necessarily unique across all processes on the host but it is unique within the process namespace that the process exists within. +""" + class ProcessContextSwitchTypeValues(Enum): VOLUNTARY: Final = "voluntary" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/rpc_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/rpc_attributes.py index 20847b2776b..0dd632ceda3 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/rpc_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/rpc_attributes.py @@ -73,6 +73,27 @@ Protocol version as in `jsonrpc` property of request/response. Since JSON-RPC 1.0 doesn't specify this, the value can be omitted. """ +RPC_MESSAGE_COMPRESSED_SIZE: Final = "rpc.message.compressed_size" +""" +Compressed size of the message in bytes. +""" + +RPC_MESSAGE_ID: Final = "rpc.message.id" +""" +MUST be calculated as two different counters starting from `1` one for sent messages and one for received message. +Note: This way we guarantee that the values will be consistent between different implementations. +""" + +RPC_MESSAGE_TYPE: Final = "rpc.message.type" +""" +Whether this is a received or sent message. +""" + +RPC_MESSAGE_UNCOMPRESSED_SIZE: Final = "rpc.message.uncompressed_size" +""" +Uncompressed size of the message in bytes. +""" + RPC_METHOD: Final = "rpc.method" """ The name of the (logical) method being called, must be equal to the $method part in the span name. @@ -163,6 +184,13 @@ class RpcGrpcStatusCodeValues(Enum): """UNAUTHENTICATED.""" +class RpcMessageTypeValues(Enum): + SENT: Final = "SENT" + """sent.""" + RECEIVED: Final = "RECEIVED" + """received.""" + + class RpcSystemValues(Enum): GRPC: Final = "grpc" """gRPC.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/system_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/system_attributes.py index 2ba8699a8a0..bfb0dedc271 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/system_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/system_attributes.py @@ -24,7 +24,7 @@ SYSTEM_CPU_STATE: Final = "system.cpu.state" """ -The CPU state for this data point. A system's CPU SHOULD be characterized *either* by data points with no `state` labels, *or only* data points with `state` labels. +The state of the CPU. """ SYSTEM_DEVICE: Final = "system.device" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/url_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/url_attributes.py index 68d7d1873fe..89ce57bd788 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/url_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/url_attributes.py @@ -75,6 +75,11 @@ Note: The subdomain portion of `www.east.mydomain.co.uk` is `east`. If the domain has multiple levels of subdomain, such as `sub2.sub1.example.com`, the subdomain field should contain `sub2.sub1`, with no trailing period. """ +URL_TEMPLATE: Final = "url.template" +""" +The low-cardinality template of an [absolute path reference](https://www.rfc-editor.org/rfc/rfc3986#section-4.2). +""" + URL_TOP_LEVEL_DOMAIN: Final = "url.top_level_domain" """ The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for example.com is `com`. diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/db_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/db_metrics.py index deb414e5cc5..1d959d1bded 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/db_metrics.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/db_metrics.py @@ -17,24 +17,41 @@ from opentelemetry.metrics import Counter, Histogram, Meter, UpDownCounter -DB_CLIENT_CONNECTIONS_CREATE_TIME: Final = "db.client.connections.create_time" +DB_CLIENT_CONNECTION_COUNT: Final = "db.client.connection.count" +""" +The number of connections that are currently in state described by the `state` attribute +Instrument: updowncounter +Unit: {connection} +""" + + +def create_db_client_connection_count(meter: Meter) -> UpDownCounter: + """The number of connections that are currently in state described by the `state` attribute""" + return meter.create_up_down_counter( + name=DB_CLIENT_CONNECTION_COUNT, + description="The number of connections that are currently in state described by the `state` attribute", + unit="{connection}", + ) + + +DB_CLIENT_CONNECTION_CREATE_TIME: Final = "db.client.connection.create_time" """ The time it took to create a new connection Instrument: histogram -Unit: ms +Unit: s """ -def create_db_client_connections_create_time(meter: Meter) -> Histogram: +def create_db_client_connection_create_time(meter: Meter) -> Histogram: """The time it took to create a new connection""" return meter.create_histogram( - name=DB_CLIENT_CONNECTIONS_CREATE_TIME, + name=DB_CLIENT_CONNECTION_CREATE_TIME, description="The time it took to create a new connection", - unit="ms", + unit="s", ) -DB_CLIENT_CONNECTIONS_IDLE_MAX: Final = "db.client.connections.idle.max" +DB_CLIENT_CONNECTION_IDLE_MAX: Final = "db.client.connection.idle.max" """ The maximum number of idle open connections allowed Instrument: updowncounter @@ -42,16 +59,16 @@ def create_db_client_connections_create_time(meter: Meter) -> Histogram: """ -def create_db_client_connections_idle_max(meter: Meter) -> UpDownCounter: +def create_db_client_connection_idle_max(meter: Meter) -> UpDownCounter: """The maximum number of idle open connections allowed""" return meter.create_up_down_counter( - name=DB_CLIENT_CONNECTIONS_IDLE_MAX, + name=DB_CLIENT_CONNECTION_IDLE_MAX, description="The maximum number of idle open connections allowed", unit="{connection}", ) -DB_CLIENT_CONNECTIONS_IDLE_MIN: Final = "db.client.connections.idle.min" +DB_CLIENT_CONNECTION_IDLE_MIN: Final = "db.client.connection.idle.min" """ The minimum number of idle open connections allowed Instrument: updowncounter @@ -59,16 +76,16 @@ def create_db_client_connections_idle_max(meter: Meter) -> UpDownCounter: """ -def create_db_client_connections_idle_min(meter: Meter) -> UpDownCounter: +def create_db_client_connection_idle_min(meter: Meter) -> UpDownCounter: """The minimum number of idle open connections allowed""" return meter.create_up_down_counter( - name=DB_CLIENT_CONNECTIONS_IDLE_MIN, + name=DB_CLIENT_CONNECTION_IDLE_MIN, description="The minimum number of idle open connections allowed", unit="{connection}", ) -DB_CLIENT_CONNECTIONS_MAX: Final = "db.client.connections.max" +DB_CLIENT_CONNECTION_MAX: Final = "db.client.connection.max" """ The maximum number of open connections allowed Instrument: updowncounter @@ -76,17 +93,17 @@ def create_db_client_connections_idle_min(meter: Meter) -> UpDownCounter: """ -def create_db_client_connections_max(meter: Meter) -> UpDownCounter: +def create_db_client_connection_max(meter: Meter) -> UpDownCounter: """The maximum number of open connections allowed""" return meter.create_up_down_counter( - name=DB_CLIENT_CONNECTIONS_MAX, + name=DB_CLIENT_CONNECTION_MAX, description="The maximum number of open connections allowed", unit="{connection}", ) -DB_CLIENT_CONNECTIONS_PENDING_REQUESTS: Final = ( - "db.client.connections.pending_requests" +DB_CLIENT_CONNECTION_PENDING_REQUESTS: Final = ( + "db.client.connection.pending_requests" ) """ The number of pending requests for an open connection, cumulative for the entire pool @@ -95,18 +112,18 @@ def create_db_client_connections_max(meter: Meter) -> UpDownCounter: """ -def create_db_client_connections_pending_requests( +def create_db_client_connection_pending_requests( meter: Meter, ) -> UpDownCounter: """The number of pending requests for an open connection, cumulative for the entire pool""" return meter.create_up_down_counter( - name=DB_CLIENT_CONNECTIONS_PENDING_REQUESTS, + name=DB_CLIENT_CONNECTION_PENDING_REQUESTS, description="The number of pending requests for an open connection, cumulative for the entire pool", unit="{request}", ) -DB_CLIENT_CONNECTIONS_TIMEOUTS: Final = "db.client.connections.timeouts" +DB_CLIENT_CONNECTION_TIMEOUTS: Final = "db.client.connection.timeouts" """ The number of connection timeouts that have occurred trying to obtain a connection from the pool Instrument: counter @@ -114,61 +131,200 @@ def create_db_client_connections_pending_requests( """ -def create_db_client_connections_timeouts(meter: Meter) -> Counter: +def create_db_client_connection_timeouts(meter: Meter) -> Counter: """The number of connection timeouts that have occurred trying to obtain a connection from the pool""" return meter.create_counter( - name=DB_CLIENT_CONNECTIONS_TIMEOUTS, + name=DB_CLIENT_CONNECTION_TIMEOUTS, description="The number of connection timeouts that have occurred trying to obtain a connection from the pool", unit="{timeout}", ) +DB_CLIENT_CONNECTION_USE_TIME: Final = "db.client.connection.use_time" +""" +The time between borrowing a connection and returning it to the pool +Instrument: histogram +Unit: s +""" + + +def create_db_client_connection_use_time(meter: Meter) -> Histogram: + """The time between borrowing a connection and returning it to the pool""" + return meter.create_histogram( + name=DB_CLIENT_CONNECTION_USE_TIME, + description="The time between borrowing a connection and returning it to the pool", + unit="s", + ) + + +DB_CLIENT_CONNECTION_WAIT_TIME: Final = "db.client.connection.wait_time" +""" +The time it took to obtain an open connection from the pool +Instrument: histogram +Unit: s +""" + + +def create_db_client_connection_wait_time(meter: Meter) -> Histogram: + """The time it took to obtain an open connection from the pool""" + return meter.create_histogram( + name=DB_CLIENT_CONNECTION_WAIT_TIME, + description="The time it took to obtain an open connection from the pool", + unit="s", + ) + + +DB_CLIENT_CONNECTIONS_CREATE_TIME: Final = "db.client.connections.create_time" +""" +Deprecated: Replaced by `db.client.connection.create_time`. Note: the unit also changed from `ms` to `s`. +""" + + +def create_db_client_connections_create_time(meter: Meter) -> Histogram: + """Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from `ms` to `s`""" + return meter.create_histogram( + name=DB_CLIENT_CONNECTIONS_CREATE_TIME, + description="Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from `ms` to `s`.", + unit="ms", + ) + + +DB_CLIENT_CONNECTIONS_IDLE_MAX: Final = "db.client.connections.idle.max" +""" +Deprecated: Replaced by `db.client.connection.idle.max`. +""" + + +def create_db_client_connections_idle_max(meter: Meter) -> UpDownCounter: + """Deprecated, use `db.client.connection.idle.max` instead""" + return meter.create_up_down_counter( + name=DB_CLIENT_CONNECTIONS_IDLE_MAX, + description="Deprecated, use `db.client.connection.idle.max` instead.", + unit="{connection}", + ) + + +DB_CLIENT_CONNECTIONS_IDLE_MIN: Final = "db.client.connections.idle.min" +""" +Deprecated: Replaced by `db.client.connection.idle.min`. +""" + + +def create_db_client_connections_idle_min(meter: Meter) -> UpDownCounter: + """Deprecated, use `db.client.connection.idle.min` instead""" + return meter.create_up_down_counter( + name=DB_CLIENT_CONNECTIONS_IDLE_MIN, + description="Deprecated, use `db.client.connection.idle.min` instead.", + unit="{connection}", + ) + + +DB_CLIENT_CONNECTIONS_MAX: Final = "db.client.connections.max" +""" +Deprecated: Replaced by `db.client.connection.max`. +""" + + +def create_db_client_connections_max(meter: Meter) -> UpDownCounter: + """Deprecated, use `db.client.connection.max` instead""" + return meter.create_up_down_counter( + name=DB_CLIENT_CONNECTIONS_MAX, + description="Deprecated, use `db.client.connection.max` instead.", + unit="{connection}", + ) + + +DB_CLIENT_CONNECTIONS_PENDING_REQUESTS: Final = ( + "db.client.connections.pending_requests" +) +""" +Deprecated: Replaced by `db.client.connection.pending_requests`. +""" + + +def create_db_client_connections_pending_requests( + meter: Meter, +) -> UpDownCounter: + """Deprecated, use `db.client.connection.pending_requests` instead""" + return meter.create_up_down_counter( + name=DB_CLIENT_CONNECTIONS_PENDING_REQUESTS, + description="Deprecated, use `db.client.connection.pending_requests` instead.", + unit="{request}", + ) + + +DB_CLIENT_CONNECTIONS_TIMEOUTS: Final = "db.client.connections.timeouts" +""" +Deprecated: Replaced by `db.client.connection.timeouts`. +""" + + +def create_db_client_connections_timeouts(meter: Meter) -> Counter: + """Deprecated, use `db.client.connection.timeouts` instead""" + return meter.create_counter( + name=DB_CLIENT_CONNECTIONS_TIMEOUTS, + description="Deprecated, use `db.client.connection.timeouts` instead.", + unit="{timeout}", + ) + + DB_CLIENT_CONNECTIONS_USAGE: Final = "db.client.connections.usage" """ -The number of connections that are currently in state described by the `state` attribute -Instrument: updowncounter -Unit: {connection} +Deprecated: Replaced by `db.client.connection.count`. """ def create_db_client_connections_usage(meter: Meter) -> UpDownCounter: - """The number of connections that are currently in state described by the `state` attribute""" + """Deprecated, use `db.client.connection.count` instead""" return meter.create_up_down_counter( name=DB_CLIENT_CONNECTIONS_USAGE, - description="The number of connections that are currently in state described by the `state` attribute", + description="Deprecated, use `db.client.connection.count` instead.", unit="{connection}", ) DB_CLIENT_CONNECTIONS_USE_TIME: Final = "db.client.connections.use_time" """ -The time between borrowing a connection and returning it to the pool -Instrument: histogram -Unit: ms +Deprecated: Replaced by `db.client.connection.use_time`. Note: the unit also changed from `ms` to `s`. """ def create_db_client_connections_use_time(meter: Meter) -> Histogram: - """The time between borrowing a connection and returning it to the pool""" + """Deprecated, use `db.client.connection.use_time` instead. Note: the unit also changed from `ms` to `s`""" return meter.create_histogram( name=DB_CLIENT_CONNECTIONS_USE_TIME, - description="The time between borrowing a connection and returning it to the pool", + description="Deprecated, use `db.client.connection.use_time` instead. Note: the unit also changed from `ms` to `s`.", unit="ms", ) DB_CLIENT_CONNECTIONS_WAIT_TIME: Final = "db.client.connections.wait_time" """ -The time it took to obtain an open connection from the pool -Instrument: histogram -Unit: ms +Deprecated: Replaced by `db.client.connection.wait_time`. Note: the unit also changed from `ms` to `s`. """ def create_db_client_connections_wait_time(meter: Meter) -> Histogram: - """The time it took to obtain an open connection from the pool""" + """Deprecated, use `db.client.connection.wait_time` instead. Note: the unit also changed from `ms` to `s`""" return meter.create_histogram( name=DB_CLIENT_CONNECTIONS_WAIT_TIME, - description="The time it took to obtain an open connection from the pool", + description="Deprecated, use `db.client.connection.wait_time` instead. Note: the unit also changed from `ms` to `s`.", unit="ms", ) + + +DB_CLIENT_OPERATION_DURATION: Final = "db.client.operation.duration" +""" +Duration of database client operations +Instrument: histogram +Unit: s +""" + + +def create_db_client_operation_duration(meter: Meter) -> Histogram: + """Duration of database client operations""" + return meter.create_histogram( + name=DB_CLIENT_OPERATION_DURATION, + description="Duration of database client operations.", + unit="s", + ) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/system_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/system_metrics.py index 32a00fcd2a1..3d193ef1801 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/system_metrics.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/system_metrics.py @@ -292,6 +292,25 @@ def create_system_memory_limit(meter: Meter) -> UpDownCounter: ) +SYSTEM_MEMORY_SHARED: Final = "system.memory.shared" +""" +Shared memory used (mostly by tmpfs) +Instrument: updowncounter +Unit: By +Note: Equivalent of `shared` from [`free` command](https://man7.org/linux/man-pages/man1/free.1.html) or + `Shmem` from [`/proc/meminfo`](https://man7.org/linux/man-pages/man5/proc.5.html)". +""" + + +def create_system_memory_shared(meter: Meter) -> UpDownCounter: + """Shared memory used (mostly by tmpfs)""" + return meter.create_up_down_counter( + name=SYSTEM_MEMORY_SHARED, + description="Shared memory used (mostly by tmpfs).", + unit="By", + ) + + SYSTEM_MEMORY_USAGE: Final = "system.memory.usage" """ Reports memory in use by state diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/error_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/error_attributes.py index c657ecb36f9..9fe10d596d4 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/error_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/error_attributes.py @@ -18,7 +18,11 @@ ERROR_TYPE: Final = "error.type" """ Describes a class of error the operation ended with. -Note: The `error.type` SHOULD be predictable and SHOULD have low cardinality. +Note: The `error.type` SHOULD be predictable, and SHOULD have low cardinality. + + When `error.type` is set to a type (e.g., an exception type), its + canonical class name identifying the type within the artifact SHOULD be used. + Instrumentations SHOULD document the list of errors they report. The cardinality of `error.type` within one instrumentation library SHOULD be low. diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/exception_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/exception_attributes.py index a197b22a4ba..1d1ebe84155 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/exception_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/exception_attributes.py @@ -27,7 +27,7 @@ whether it will escape the scope of a span. However, it is trivial to know that an exception will escape, if one checks for an active exception just before ending the span, - as done in the [example for recording span exceptions](#recording-an-exception). + as done in the [example for recording span exceptions](https://opentelemetry.io/docs/specs/semconv/exceptions/exceptions-spans/#recording-an-exception). It follows that an exception may still escape the scope of the span even if the `exception.escaped` attribute was not set or set to false, diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/service_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/service_attributes.py index 573a58cbbed..7ad038e92e0 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/service_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/service_attributes.py @@ -17,7 +17,7 @@ SERVICE_NAME: Final = "service.name" """ Logical name of the service. -Note: MUST be the same for all instances of horizontally scaled services. If the value was not specified, SDKs MUST fallback to `unknown_service:` concatenated with [`process.executable.name`](process.md#process), e.g. `unknown_service:bash`. If `process.executable.name` is not available, the value MUST be set to `unknown_service`. +Note: MUST be the same for all instances of horizontally scaled services. If the value was not specified, SDKs MUST fallback to `unknown_service:` concatenated with [`process.executable.name`](process.md), e.g. `unknown_service:bash`. If `process.executable.name` is not available, the value MUST be set to `unknown_service`. """ SERVICE_VERSION: Final = "service.version" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/schemas.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/schemas.py index b4099607745..9af106cef99 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/schemas.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/schemas.py @@ -26,5 +26,10 @@ class Schemas(Enum): The URL of the OpenTelemetry schema version v1.25.0. """ + V1_26_0 = "https://opentelemetry.io/schemas/v1.26.0" + """ + The URL of the OpenTelemetry schema version v1.26.0. + """ + # when generating new semantic conventions, # make sure to add new versions version here. diff --git a/scripts/semconv/generate.sh b/scripts/semconv/generate.sh index 7035702b283..12efd2b0b1e 100755 --- a/scripts/semconv/generate.sh +++ b/scripts/semconv/generate.sh @@ -5,7 +5,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ROOT_DIR="${SCRIPT_DIR}/../../" # freeze the spec version to make SemanticAttributes generation reproducible -SEMCONV_VERSION=v1.25.0 +SEMCONV_VERSION=v1.26.0 OTEL_SEMCONV_GEN_IMG_VERSION=0.24.0 INCUBATING_DIR=_incubating cd ${SCRIPT_DIR} @@ -34,7 +34,7 @@ EXCLUDED_NAMESPACES="jvm aspnetcore dotnet signalr ios android kestrel" # excluded attributes will be commented out in the generated code # this behavior is fully controlled by jinja templates -EXCLUDED_ATTRIBUTES="" +EXCLUDED_ATTRIBUTES="messaging.client_id" generate() { TEMPLATE=$1 From c905e117d2cfa6ca66b73384ffce4f5b4d1eb505 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Mon, 17 Jun 2024 16:19:17 +0200 Subject: [PATCH 2/2] Don't use multi line comments with excluded attributes To please pylint --- .../attributes/messaging_attributes.py | 5 ++--- .../semconv/templates/semantic_attributes.j2 | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py index 906e12ea640..a684e4471f1 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py @@ -27,9 +27,8 @@ """ # MESSAGING_CLIENT_ID: Final = "messaging.client_id" -""" -Deprecated: Replaced by `messaging.client.id`. -""" + +# Deprecated: Replaced by `messaging.client.id`. MESSAGING_DESTINATION_ANONYMOUS: Final = "messaging.destination.anonymous" """ diff --git a/scripts/semconv/templates/semantic_attributes.j2 b/scripts/semconv/templates/semantic_attributes.j2 index 2812679f920..7ea1ffde7c9 100644 --- a/scripts/semconv/templates/semantic_attributes.j2 +++ b/scripts/semconv/templates/semantic_attributes.j2 @@ -27,19 +27,21 @@ {%- endif -%} {%- endmacro -%} -{%- macro attribute_brief(attribute) -%} -""" +{%- macro attribute_brief(attribute, prefix) -%} +{%- if not prefix %}""" +{%- endif %} {%- if attribute | is_deprecated %} -Deprecated: {{ common.to_docstring(attribute.deprecated) }}. +{{ prefix }}Deprecated: {{ common.to_docstring(attribute.deprecated) }}. {%- elif attribute | is_stable and filter == "any" %} -Deprecated in favor of stable :py:const:`{{stable_class_ref(attribute_name(attribute), '.')}}`. +{{ prefix }}Deprecated in favor of stable :py:const:`{{stable_class_ref(attribute_name(attribute), '.')}}`. {%- else %} -{{ common.to_docstring(attribute.brief) }}. +{{ prefix }}{{ common.to_docstring(attribute.brief) }}. {%- if attribute.note %} -Note: {{ common.to_docstring(attribute.note | indent)}}. +{{ prefix }}Note: {{ common.to_docstring(attribute.note | indent)}}. {%- endif -%} {%- endif %} -""" +{%- if not prefix %} +"""{%- endif %} {%- endmacro -%} {%- if root_namespace not in excluded_namespaces.split(' ') -%} @@ -74,7 +76,7 @@ from enum import Enum {% for attribute in filtered_attributes -%} {%- set prefix = "# " if attribute.fqn in excluded_attributes else "" -%} {{prefix}}{{attribute_name(attribute)}}: Final = "{{attribute.fqn}}" -{{attribute_brief(attribute)}} +{{attribute_brief(attribute, prefix)}} {% endfor %} {%- for attribute in filtered_enum_attributes | rejectattr("fqn", "in", excluded_attributes) -%}