diff --git a/CHANGELOG.md b/CHANGELOG.md index dd9b0b19ed..bb2f3e65ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,8 +21,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3785](https://github.com/open-telemetry/opentelemetry-python/pull/3785)) - Add capture the fully qualified type name for raised exceptions in spans ([#3837](https://github.com/open-telemetry/opentelemetry-python/pull/3837)) -- Prometheus exporter sort label keys to prevent duplicate metrics when user input changes order +- Prometheus exporter sort label keys to prevent duplicate metrics when user input changes order ([#3698](https://github.com/open-telemetry/opentelemetry-python/pull/3698)) +- Update semantic conventions to version 1.25.0. + Refactor semantic-convention structure: + - `SpanAttributes`, `ResourceAttributes`, and `MetricInstruments` are deprecated. + - Attribute and metric definitions are now grouped by the namespace. + - Stable attributes and metrics are moved to `opentelemetry.semconv.attributes` + and `opentelemetry.semconv.metrics` modules. + - Stable and experimental attributes and metrics are defined under + `opentelemetry.semconv._incubating` import path. + ([#3586](https://github.com/open-telemetry/opentelemetry-python/pull/3586)) ## Version 1.24.0/0.45b0 (2024-03-28) @@ -67,7 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3564](https://github.com/open-telemetry/opentelemetry-python/pull/3564)) - Fix explicit bucket histogram aggregation ([#3429](https://github.com/open-telemetry/opentelemetry-python/pull/3429)) -- Add `code.lineno`, `code.function` and `code.filepath` to all logs +- Add `code.lineno`, `code.function` and `code.filepath` to all logs ([#3675](https://github.com/open-telemetry/opentelemetry-python/pull/3675)) - Add Synchronous Gauge instrument ([#3462](https://github.com/open-telemetry/opentelemetry-python/pull/3462)) @@ -92,7 +101,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3572](https://github.com/open-telemetry/opentelemetry-python/pull/3572)) - Remove Jaeger exporters ([#3554](https://github.com/open-telemetry/opentelemetry-python/pull/3554)) -- Log stacktrace on `UNKNOWN` status OTLP export error +- Log stacktrace on `UNKNOWN` status OTLP export error ([#3536](https://github.com/open-telemetry/opentelemetry-python/pull/3536)) - Fix OTLPExporterMixin shutdown timeout period ([#3524](https://github.com/open-telemetry/opentelemetry-python/pull/3524)) @@ -117,7 +126,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3251](https://github.com/open-telemetry/opentelemetry-python/pull/3251)) - Add missing schema_url in global api for logging and metrics ([#3251](https://github.com/open-telemetry/opentelemetry-python/pull/3251)) -- Prometheus exporter support for auto instrumentation +- Prometheus exporter support for auto instrumentation ([#3413](https://github.com/open-telemetry/opentelemetry-python/pull/3413)) - Implement Process Resource detector ([#3472](https://github.com/open-telemetry/opentelemetry-python/pull/3472)) @@ -1500,7 +1509,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#3564](https://github.com/open-telemetry/opentelemetry-python/pull/3564)) - Fix explicit bucket histogram aggregation ([#3429](https://github.com/open-telemetry/opentelemetry-python/pull/3429)) -- Add `code.lineno`, `code.function` and `code.filepath` to all logs +- Add `code.lineno`, `code.function` and `code.filepath` to all logs ([#3645](https://github.com/open-telemetry/opentelemetry-python/pull/3645)) - Add Synchronous Gauge instrument ([#3462](https://github.com/open-telemetry/opentelemetry-python/pull/3462)) diff --git a/opentelemetry-semantic-conventions/pyproject.toml b/opentelemetry-semantic-conventions/pyproject.toml index 876fb94a98..2a02df79e4 100644 --- a/opentelemetry-semantic-conventions/pyproject.toml +++ b/opentelemetry-semantic-conventions/pyproject.toml @@ -24,6 +24,10 @@ classifiers = [ "Programming Language :: Python :: 3.11", ] +dependencies = [ + "opentelemetry-api == 1.25.0.dev", +] + [project.urls] Homepage = "https://github.com/open-telemetry/opentelemetry-python/tree/main/opentelemetry-semantic-conventions" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/aws_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/aws_attributes.py new file mode 100644 index 0000000000..f5edbbcb80 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/aws_attributes.py @@ -0,0 +1,283 @@ +# 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 + +AWS_DYNAMODB_ATTRIBUTE_DEFINITIONS = "aws.dynamodb.attribute_definitions" +""" +The JSON-serialized value of each item in the `AttributeDefinitions` request field. +""" + +AWS_DYNAMODB_ATTRIBUTES_TO_GET = "aws.dynamodb.attributes_to_get" +""" +The value of the `AttributesToGet` request parameter. +""" + +AWS_DYNAMODB_CONSISTENT_READ = "aws.dynamodb.consistent_read" +""" +The value of the `ConsistentRead` request parameter. +""" + +AWS_DYNAMODB_CONSUMED_CAPACITY = "aws.dynamodb.consumed_capacity" +""" +The JSON-serialized value of each item in the `ConsumedCapacity` response field. +""" + +AWS_DYNAMODB_COUNT = "aws.dynamodb.count" +""" +The value of the `Count` response parameter. +""" + +AWS_DYNAMODB_EXCLUSIVE_START_TABLE = "aws.dynamodb.exclusive_start_table" +""" +The value of the `ExclusiveStartTableName` request parameter. +""" + +AWS_DYNAMODB_GLOBAL_SECONDARY_INDEX_UPDATES = ( + "aws.dynamodb.global_secondary_index_updates" +) +""" +The JSON-serialized value of each item in the `GlobalSecondaryIndexUpdates` request field. +""" + +AWS_DYNAMODB_GLOBAL_SECONDARY_INDEXES = "aws.dynamodb.global_secondary_indexes" +""" +The JSON-serialized value of each item of the `GlobalSecondaryIndexes` request field. +""" + +AWS_DYNAMODB_INDEX_NAME = "aws.dynamodb.index_name" +""" +The value of the `IndexName` request parameter. +""" + +AWS_DYNAMODB_ITEM_COLLECTION_METRICS = "aws.dynamodb.item_collection_metrics" +""" +The JSON-serialized value of the `ItemCollectionMetrics` response field. +""" + +AWS_DYNAMODB_LIMIT = "aws.dynamodb.limit" +""" +The value of the `Limit` request parameter. +""" + +AWS_DYNAMODB_LOCAL_SECONDARY_INDEXES = "aws.dynamodb.local_secondary_indexes" +""" +The JSON-serialized value of each item of the `LocalSecondaryIndexes` request field. +""" + +AWS_DYNAMODB_PROJECTION = "aws.dynamodb.projection" +""" +The value of the `ProjectionExpression` request parameter. +""" + +AWS_DYNAMODB_PROVISIONED_READ_CAPACITY = ( + "aws.dynamodb.provisioned_read_capacity" +) +""" +The value of the `ProvisionedThroughput.ReadCapacityUnits` request parameter. +""" + +AWS_DYNAMODB_PROVISIONED_WRITE_CAPACITY = ( + "aws.dynamodb.provisioned_write_capacity" +) +""" +The value of the `ProvisionedThroughput.WriteCapacityUnits` request parameter. +""" + +AWS_DYNAMODB_SCAN_FORWARD = "aws.dynamodb.scan_forward" +""" +The value of the `ScanIndexForward` request parameter. +""" + +AWS_DYNAMODB_SCANNED_COUNT = "aws.dynamodb.scanned_count" +""" +The value of the `ScannedCount` response parameter. +""" + +AWS_DYNAMODB_SEGMENT = "aws.dynamodb.segment" +""" +The value of the `Segment` request parameter. +""" + +AWS_DYNAMODB_SELECT = "aws.dynamodb.select" +""" +The value of the `Select` request parameter. +""" + +AWS_DYNAMODB_TABLE_COUNT = "aws.dynamodb.table_count" +""" +The number of items in the `TableNames` response parameter. +""" + +AWS_DYNAMODB_TABLE_NAMES = "aws.dynamodb.table_names" +""" +The keys in the `RequestItems` object field. +""" + +AWS_DYNAMODB_TOTAL_SEGMENTS = "aws.dynamodb.total_segments" +""" +The value of the `TotalSegments` request parameter. +""" + +AWS_ECS_CLUSTER_ARN = "aws.ecs.cluster.arn" +""" +The ARN of an [ECS cluster](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/clusters.html). +""" + +AWS_ECS_CONTAINER_ARN = "aws.ecs.container.arn" +""" +The Amazon Resource Name (ARN) of an [ECS container instance](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_instances.html). +""" + +AWS_ECS_LAUNCHTYPE = "aws.ecs.launchtype" +""" +The [launch type](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_types.html) for an ECS task. +""" + +AWS_ECS_TASK_ARN = "aws.ecs.task.arn" +""" +The ARN of a running [ECS task](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-account-settings.html#ecs-resource-ids). +""" + +AWS_ECS_TASK_FAMILY = "aws.ecs.task.family" +""" +The family name of the [ECS task definition](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html) used to create the ECS task. +""" + +AWS_ECS_TASK_ID = "aws.ecs.task.id" +""" +The ID of a running ECS task. The ID MUST be extracted from `task.arn`. +""" + +AWS_ECS_TASK_REVISION = "aws.ecs.task.revision" +""" +The revision for the task definition used to create the ECS task. +""" + +AWS_EKS_CLUSTER_ARN = "aws.eks.cluster.arn" +""" +The ARN of an EKS cluster. +""" + +AWS_LAMBDA_INVOKED_ARN = "aws.lambda.invoked_arn" +""" +The full invoked ARN as provided on the `Context` passed to the function (`Lambda-Runtime-Invoked-Function-Arn` header on the `/runtime/invocation/next` applicable). +Note: This may be different from `cloud.resource_id` if an alias is involved. +""" + +AWS_LOG_GROUP_ARNS = "aws.log.group.arns" +""" +The Amazon Resource Name(s) (ARN) of the AWS log group(s). +Note: See the [log group ARN format documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format). +""" + +AWS_LOG_GROUP_NAMES = "aws.log.group.names" +""" +The name(s) of the AWS log group(s) an application is writing to. +Note: Multiple log groups must be supported for cases like multi-container applications, where a single application has sidecar containers, and each write to their own log group. +""" + +AWS_LOG_STREAM_ARNS = "aws.log.stream.arns" +""" +The ARN(s) of the AWS log stream(s). +Note: See the [log stream ARN format documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/iam-access-control-overview-cwl.html#CWL_ARN_Format). One log group can contain several log streams, so these ARNs necessarily identify both a log group and a log stream. +""" + +AWS_LOG_STREAM_NAMES = "aws.log.stream.names" +""" +The name(s) of the AWS log stream(s) an application is writing to. +""" + +AWS_REQUEST_ID = "aws.request_id" +""" +The AWS request ID as returned in the response headers `x-amz-request-id` or `x-amz-requestid`. +""" + +AWS_S3_BUCKET = "aws.s3.bucket" +""" +The S3 bucket name the request refers to. Corresponds to the `--bucket` parameter of the [S3 API](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html) operations. +Note: The `bucket` attribute is applicable to all S3 operations that reference a bucket, i.e. that require the bucket name as a mandatory parameter. + This applies to almost all S3 operations except `list-buckets`. +""" + +AWS_S3_COPY_SOURCE = "aws.s3.copy_source" +""" +The source object (in the form `bucket`/`key`) for the copy operation. +Note: The `copy_source` attribute applies to S3 copy operations and corresponds to the `--copy-source` parameter + of the [copy-object operation within the S3 API](https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html). + This applies in particular to the following operations: + + - [copy-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html) + - [upload-part-copy](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html). +""" + +AWS_S3_DELETE = "aws.s3.delete" +""" +The delete request container that specifies the objects to be deleted. +Note: The `delete` attribute is only applicable to the [delete-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html) operation. + The `delete` attribute corresponds to the `--delete` parameter of the + [delete-objects operation within the S3 API](https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-objects.html). +""" + +AWS_S3_KEY = "aws.s3.key" +""" +The S3 object key the request refers to. Corresponds to the `--key` parameter of the [S3 API](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html) operations. +Note: The `key` attribute is applicable to all object-related S3 operations, i.e. that require the object key as a mandatory parameter. + This applies in particular to the following operations: + + - [copy-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/copy-object.html) + - [delete-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html) + - [get-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html) + - [head-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/head-object.html) + - [put-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object.html) + - [restore-object](https://docs.aws.amazon.com/cli/latest/reference/s3api/restore-object.html) + - [select-object-content](https://docs.aws.amazon.com/cli/latest/reference/s3api/select-object-content.html) + - [abort-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html) + - [complete-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html) + - [create-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/create-multipart-upload.html) + - [list-parts](https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html) + - [upload-part](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html) + - [upload-part-copy](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html). +""" + +AWS_S3_PART_NUMBER = "aws.s3.part_number" +""" +The part number of the part being uploaded in a multipart-upload operation. This is a positive integer between 1 and 10,000. +Note: The `part_number` attribute is only applicable to the [upload-part](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html) + and [upload-part-copy](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html) operations. + The `part_number` attribute corresponds to the `--part-number` parameter of the + [upload-part operation within the S3 API](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html). +""" + +AWS_S3_UPLOAD_ID = "aws.s3.upload_id" +""" +Upload ID that identifies the multipart upload. +Note: The `upload_id` attribute applies to S3 multipart-upload operations and corresponds to the `--upload-id` parameter + of the [S3 API](https://docs.aws.amazon.com/cli/latest/reference/s3api/index.html) multipart operations. + This applies in particular to the following operations: + + - [abort-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/abort-multipart-upload.html) + - [complete-multipart-upload](https://docs.aws.amazon.com/cli/latest/reference/s3api/complete-multipart-upload.html) + - [list-parts](https://docs.aws.amazon.com/cli/latest/reference/s3api/list-parts.html) + - [upload-part](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part.html) + - [upload-part-copy](https://docs.aws.amazon.com/cli/latest/reference/s3api/upload-part-copy.html). +""" + + +class AwsEcsLaunchtypeValues(Enum): + EC2 = "ec2" + """ec2.""" + FARGATE = "fargate" + """fargate.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/browser_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/browser_attributes.py new file mode 100644 index 0000000000..e792af8073 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/browser_attributes.py @@ -0,0 +1,39 @@ +# 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. + + +BROWSER_BRANDS = "browser.brands" +""" +Array of brand name and version separated by a space. +Note: This value is intended to be taken from the [UA client hints API](https://wicg.github.io/ua-client-hints/#interface) (`navigator.userAgentData.brands`). +""" + +BROWSER_LANGUAGE = "browser.language" +""" +Preferred language of the user using the browser. +Note: This value is intended to be taken from the Navigator API `navigator.language`. +""" + +BROWSER_MOBILE = "browser.mobile" +""" +A boolean that is true if the browser is running on a mobile device. +Note: This value is intended to be taken from the [UA client hints API](https://wicg.github.io/ua-client-hints/#interface) (`navigator.userAgentData.mobile`). If unavailable, this attribute SHOULD be left unset. +""" + +BROWSER_PLATFORM = "browser.platform" +""" +The platform on which the browser is running. +Note: This value is intended to be taken from the [UA client hints API](https://wicg.github.io/ua-client-hints/#interface) (`navigator.userAgentData.platform`). If unavailable, the legacy `navigator.platform` API SHOULD NOT be used instead and this attribute SHOULD be left unset in order for the values to be consistent. + The list of possible values is defined in the [W3C User-Agent Client Hints specification](https://wicg.github.io/ua-client-hints/#sec-ch-ua-platform). Note that some (but not all) of these values can overlap with values in the [`os.type` and `os.name` attributes](./os.md). However, for consistency, the values in the `browser.platform` attribute should capture the exact value that the user agent provides. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/client_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/client_attributes.py new file mode 100644 index 0000000000..a8514b5639 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/client_attributes.py @@ -0,0 +1,24 @@ +# 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. + + +CLIENT_ADDRESS = "client.address" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.client_attributes.CLIENT_ADDRESS`. +""" + +CLIENT_PORT = "client.port" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.client_attributes.CLIENT_PORT`. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/cloud_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/cloud_attributes.py new file mode 100644 index 0000000000..43e181e308 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/cloud_attributes.py @@ -0,0 +1,142 @@ +# 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 + +CLOUD_ACCOUNT_ID = "cloud.account.id" +""" +The cloud account ID the resource is assigned to. +""" + +CLOUD_AVAILABILITY_ZONE = "cloud.availability_zone" +""" +Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running. +Note: Availability zones are called "zones" on Alibaba Cloud and Google Cloud. +""" + +CLOUD_PLATFORM = "cloud.platform" +""" +The cloud platform in use. +Note: The prefix of the service SHOULD match the one specified in `cloud.provider`. +""" + +CLOUD_PROVIDER = "cloud.provider" +""" +Name of the cloud provider. +""" + +CLOUD_REGION = "cloud.region" +""" +The geographical region the resource is running. +Note: Refer to your provider's docs to see the available regions, for example [Alibaba Cloud regions](https://www.alibabacloud.com/help/doc-detail/40654.htm), [AWS regions](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/), [Azure regions](https://azure.microsoft.com/global-infrastructure/geographies/), [Google Cloud regions](https://cloud.google.com/about/locations), or [Tencent Cloud regions](https://www.tencentcloud.com/document/product/213/6091). +""" + +CLOUD_RESOURCE_ID = "cloud.resource_id" +""" +Cloud provider-specific native identifier of the monitored cloud resource (e.g. an [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) on AWS, a [fully qualified resource ID](https://learn.microsoft.com/rest/api/resources/resources/get-by-id) on Azure, a [full resource name](https://cloud.google.com/apis/design/resource_names#full_resource_name) on GCP). +Note: On some cloud providers, it may not be possible to determine the full ID at startup, + so it may be necessary to set `cloud.resource_id` as a span attribute instead. + + The exact value to use for `cloud.resource_id` depends on the cloud provider. + The following well-known definitions MUST be used if you set this attribute and they apply: + + * **AWS Lambda:** The function [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html). + Take care not to use the "invoked ARN" directly but replace any + [alias suffix](https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html) + with the resolved function version, as the same runtime instance may be invokable with + multiple different aliases. + * **GCP:** The [URI of the resource](https://cloud.google.com/iam/docs/full-resource-names) + * **Azure:** The [Fully Qualified Resource ID](https://docs.microsoft.com/rest/api/resources/resources/get-by-id) of the invoked function, + *not* the function app, having the form + `/subscriptions//resourceGroups//providers/Microsoft.Web/sites//functions/`. + This means that a span attribute MUST be used, as an Azure function app can host multiple functions that would usually share + a TracerProvider. +""" + + +class CloudPlatformValues(Enum): + ALIBABA_CLOUD_ECS = "alibaba_cloud_ecs" + """Alibaba Cloud Elastic Compute Service.""" + ALIBABA_CLOUD_FC = "alibaba_cloud_fc" + """Alibaba Cloud Function Compute.""" + ALIBABA_CLOUD_OPENSHIFT = "alibaba_cloud_openshift" + """Red Hat OpenShift on Alibaba Cloud.""" + AWS_EC2 = "aws_ec2" + """AWS Elastic Compute Cloud.""" + AWS_ECS = "aws_ecs" + """AWS Elastic Container Service.""" + AWS_EKS = "aws_eks" + """AWS Elastic Kubernetes Service.""" + AWS_LAMBDA = "aws_lambda" + """AWS Lambda.""" + AWS_ELASTIC_BEANSTALK = "aws_elastic_beanstalk" + """AWS Elastic Beanstalk.""" + AWS_APP_RUNNER = "aws_app_runner" + """AWS App Runner.""" + AWS_OPENSHIFT = "aws_openshift" + """Red Hat OpenShift on AWS (ROSA).""" + AZURE_VM = "azure_vm" + """Azure Virtual Machines.""" + AZURE_CONTAINER_APPS = "azure_container_apps" + """Azure Container Apps.""" + AZURE_CONTAINER_INSTANCES = "azure_container_instances" + """Azure Container Instances.""" + AZURE_AKS = "azure_aks" + """Azure Kubernetes Service.""" + AZURE_FUNCTIONS = "azure_functions" + """Azure Functions.""" + AZURE_APP_SERVICE = "azure_app_service" + """Azure App Service.""" + AZURE_OPENSHIFT = "azure_openshift" + """Azure Red Hat OpenShift.""" + GCP_BARE_METAL_SOLUTION = "gcp_bare_metal_solution" + """Google Bare Metal Solution (BMS).""" + GCP_COMPUTE_ENGINE = "gcp_compute_engine" + """Google Cloud Compute Engine (GCE).""" + GCP_CLOUD_RUN = "gcp_cloud_run" + """Google Cloud Run.""" + GCP_KUBERNETES_ENGINE = "gcp_kubernetes_engine" + """Google Cloud Kubernetes Engine (GKE).""" + GCP_CLOUD_FUNCTIONS = "gcp_cloud_functions" + """Google Cloud Functions (GCF).""" + GCP_APP_ENGINE = "gcp_app_engine" + """Google Cloud App Engine (GAE).""" + GCP_OPENSHIFT = "gcp_openshift" + """Red Hat OpenShift on Google Cloud.""" + IBM_CLOUD_OPENSHIFT = "ibm_cloud_openshift" + """Red Hat OpenShift on IBM Cloud.""" + TENCENT_CLOUD_CVM = "tencent_cloud_cvm" + """Tencent Cloud Cloud Virtual Machine (CVM).""" + TENCENT_CLOUD_EKS = "tencent_cloud_eks" + """Tencent Cloud Elastic Kubernetes Service (EKS).""" + TENCENT_CLOUD_SCF = "tencent_cloud_scf" + """Tencent Cloud Serverless Cloud Function (SCF).""" + + +class CloudProviderValues(Enum): + ALIBABA_CLOUD = "alibaba_cloud" + """Alibaba Cloud.""" + AWS = "aws" + """Amazon Web Services.""" + AZURE = "azure" + """Microsoft Azure.""" + GCP = "gcp" + """Google Cloud Platform.""" + HEROKU = "heroku" + """Heroku Platform as a Service.""" + IBM_CLOUD = "ibm_cloud" + """IBM Cloud.""" + TENCENT_CLOUD = "tencent_cloud" + """Tencent Cloud.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/cloudevents_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/cloudevents_attributes.py new file mode 100644 index 0000000000..30fe19c74e --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/cloudevents_attributes.py @@ -0,0 +1,39 @@ +# 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. + + +CLOUDEVENTS_EVENT_ID = "cloudevents.event_id" +""" +The [event_id](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#id) uniquely identifies the event. +""" + +CLOUDEVENTS_EVENT_SOURCE = "cloudevents.event_source" +""" +The [source](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#source-1) identifies the context in which an event happened. +""" + +CLOUDEVENTS_EVENT_SPEC_VERSION = "cloudevents.event_spec_version" +""" +The [version of the CloudEvents specification](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#specversion) which the event uses. +""" + +CLOUDEVENTS_EVENT_SUBJECT = "cloudevents.event_subject" +""" +The [subject](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#subject) of the event in the context of the event producer (identified by source). +""" + +CLOUDEVENTS_EVENT_TYPE = "cloudevents.event_type" +""" +The [event_type](https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md#type) contains a value describing the type of event related to the originating occurrence. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/code_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/code_attributes.py new file mode 100644 index 0000000000..6a9d55ec0a --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/code_attributes.py @@ -0,0 +1,44 @@ +# 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. + + +CODE_COLUMN = "code.column" +""" +The column number in `code.filepath` best representing the operation. It SHOULD point within the code unit named in `code.function`. +""" + +CODE_FILEPATH = "code.filepath" +""" +The source code file name that identifies the code unit as uniquely as possible (preferably an absolute file path). +""" + +CODE_FUNCTION = "code.function" +""" +The method or function name, or equivalent (usually rightmost part of the code unit's name). +""" + +CODE_LINENO = "code.lineno" +""" +The line number in `code.filepath` best representing the operation. It SHOULD point within the code unit named in `code.function`. +""" + +CODE_NAMESPACE = "code.namespace" +""" +The "namespace" within which `code.function` is defined. Usually the qualified class or module name, such that `code.namespace` + some separator + `code.function` form a unique identifier for the code unit. +""" + +CODE_STACKTRACE = "code.stacktrace" +""" +A stacktrace as a string in the natural representation for the language runtime. The representation is to be determined and documented by each language SIG. +""" 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 new file mode 100644 index 0000000000..03391d1114 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/container_attributes.py @@ -0,0 +1,95 @@ +# 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 + +CONTAINER_COMMAND = "container.command" +""" +The command used to run the container (i.e. the command name). +Note: If using embedded credentials or sensitive data, it is recommended to remove them to prevent potential leakage. +""" + +CONTAINER_COMMAND_ARGS = "container.command_args" +""" +All the command arguments (including the command/executable itself) run by the container. [2]. +""" + +CONTAINER_COMMAND_LINE = "container.command_line" +""" +The full command run by the container as a single string representing the full command. [2]. +""" + +CONTAINER_CPU_STATE = "container.cpu.state" +""" +The CPU state for this data point. +""" + +CONTAINER_ID = "container.id" +""" +Container ID. Usually a UUID, as for example used to [identify Docker containers](https://docs.docker.com/engine/reference/run/#container-identification). The UUID might be abbreviated. +""" + +CONTAINER_IMAGE_ID = "container.image.id" +""" +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. +""" + +CONTAINER_IMAGE_NAME = "container.image.name" +""" +Name of the image the container was built on. +""" + +CONTAINER_IMAGE_REPO_DIGESTS = "container.image.repo_digests" +""" +Repo digests of the container image as provided by the container runtime. +Note: [Docker](https://docs.docker.com/engine/api/v1.43/#tag/Image/operation/ImageInspect) and [CRI](https://github.com/kubernetes/cri-api/blob/c75ef5b473bbe2d0a4fc92f82235efd665ea8e9f/pkg/apis/runtime/v1/api.proto#L1237-L1238) report those under the `RepoDigests` field. +""" + +CONTAINER_IMAGE_TAGS = "container.image.tags" +""" +Container image tags. An example can be found in [Docker Image Inspect](https://docs.docker.com/engine/api/v1.43/#tag/Image/operation/ImageInspect). Should be only the `` section of the full name for example from `registry.example.com/my-org/my-image:`. +""" + +CONTAINER_LABEL_TEMPLATE = "container.label" +""" +Container labels, `` being the label name, the value being the label value. +""" + +CONTAINER_LABELS_TEMPLATE = "container.labels" +""" +Deprecated: Replaced by `container.label`. +""" + +CONTAINER_NAME = "container.name" +""" +Container name used by container runtime. +""" + +CONTAINER_RUNTIME = "container.runtime" +""" +The container runtime managing this container. +""" + + +class ContainerCpuStateValues(Enum): + USER = "user" + """When tasks of the cgroup are in user mode (Linux). When all container processes are in user mode (Windows).""" + SYSTEM = "system" + """When CPU is used by the system (host OS).""" + KERNEL = "kernel" + """When tasks of the cgroup are in kernel mode (Linux). When all container processes are in kernel mode (Windows).""" 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 new file mode 100644 index 0000000000..e1cf5e017d --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/db_attributes.py @@ -0,0 +1,346 @@ +# 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 + +DB_CASSANDRA_CONSISTENCY_LEVEL = "db.cassandra.consistency_level" +""" +The consistency level of the query. Based on consistency values from [CQL](https://docs.datastax.com/en/cassandra-oss/3.0/cassandra/dml/dmlConfigConsistency.html). +""" + +DB_CASSANDRA_COORDINATOR_DC = "db.cassandra.coordinator.dc" +""" +The data center of the coordinating node for a query. +""" + +DB_CASSANDRA_COORDINATOR_ID = "db.cassandra.coordinator.id" +""" +The ID of the coordinating node for a query. +""" + +DB_CASSANDRA_IDEMPOTENCE = "db.cassandra.idempotence" +""" +Whether or not the query is idempotent. +""" + +DB_CASSANDRA_PAGE_SIZE = "db.cassandra.page_size" +""" +The fetch size used for paging, i.e. how many rows will be returned at once. +""" + +DB_CASSANDRA_SPECULATIVE_EXECUTION_COUNT = ( + "db.cassandra.speculative_execution_count" +) +""" +The number of times a query was speculatively executed. Not set or `0` if the query was not executed speculatively. +""" + +DB_CASSANDRA_TABLE = "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. +""" + +DB_CONNECTION_STRING = "db.connection_string" +""" +Deprecated: "Replaced by `server.address` and `server.port`.". +""" + +DB_COSMOSDB_CLIENT_ID = "db.cosmosdb.client_id" +""" +Unique Cosmos client instance id. +""" + +DB_COSMOSDB_CONNECTION_MODE = "db.cosmosdb.connection_mode" +""" +Cosmos client connection mode. +""" + +DB_COSMOSDB_CONTAINER = "db.cosmosdb.container" +""" +Cosmos DB container name. +""" + +DB_COSMOSDB_OPERATION_TYPE = "db.cosmosdb.operation_type" +""" +CosmosDB Operation Type. +""" + +DB_COSMOSDB_REQUEST_CHARGE = "db.cosmosdb.request_charge" +""" +RU consumed for that operation. +""" + +DB_COSMOSDB_REQUEST_CONTENT_LENGTH = "db.cosmosdb.request_content_length" +""" +Request payload size in bytes. +""" + +DB_COSMOSDB_STATUS_CODE = "db.cosmosdb.status_code" +""" +Cosmos DB status code. +""" + +DB_COSMOSDB_SUB_STATUS_CODE = "db.cosmosdb.sub_status_code" +""" +Cosmos DB sub status code. +""" + +DB_ELASTICSEARCH_CLUSTER_NAME = "db.elasticsearch.cluster.name" +""" +Represents the identifier of an Elasticsearch cluster. +""" + +DB_ELASTICSEARCH_NODE_NAME = "db.elasticsearch.node.name" +""" +Deprecated: Replaced by `db.instance.id`. +""" + +DB_ELASTICSEARCH_PATH_PARTS_TEMPLATE = "db.elasticsearch.path_parts" +""" +A dynamic value in the url path. +Note: Many Elasticsearch url paths allow dynamic values. These SHOULD be recorded in span attributes in the format `db.elasticsearch.path_parts.`, where `` is the url path part name. The implementation SHOULD reference the [elasticsearch schema](https://raw.githubusercontent.com/elastic/elasticsearch-specification/main/output/schema/schema.json) in order to map the path part values to their names. +""" + +DB_INSTANCE_ID = "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`. +""" + +DB_JDBC_DRIVER_CLASSNAME = "db.jdbc.driver_classname" +""" +Deprecated: Removed as not used. +""" + +DB_MONGODB_COLLECTION = "db.mongodb.collection" +""" +The MongoDB collection being accessed within the database stated in `db.name`. +""" + +DB_MSSQL_INSTANCE_NAME = "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). +""" + +DB_NAME = "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). +""" + +DB_OPERATION = "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. +""" + +DB_REDIS_DATABASE_INDEX = "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. +""" + +DB_SQL_TABLE = "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. +""" + +DB_STATEMENT = "db.statement" +""" +The database statement being executed. +""" + +DB_SYSTEM = "db.system" +""" +An identifier for the database management system (DBMS) product being used. See below for a list of well-known identifiers. +""" + +DB_USER = "db.user" +""" +Username for accessing the database. +""" + + +class DbCassandraConsistencyLevelValues(Enum): + ALL = "all" + """all.""" + EACH_QUORUM = "each_quorum" + """each_quorum.""" + QUORUM = "quorum" + """quorum.""" + LOCAL_QUORUM = "local_quorum" + """local_quorum.""" + ONE = "one" + """one.""" + TWO = "two" + """two.""" + THREE = "three" + """three.""" + LOCAL_ONE = "local_one" + """local_one.""" + ANY = "any" + """any.""" + SERIAL = "serial" + """serial.""" + LOCAL_SERIAL = "local_serial" + """local_serial.""" + + +class DbCosmosdbConnectionModeValues(Enum): + GATEWAY = "gateway" + """Gateway (HTTP) connections mode.""" + DIRECT = "direct" + """Direct connection.""" + + +class DbCosmosdbOperationTypeValues(Enum): + INVALID = "Invalid" + """invalid.""" + CREATE = "Create" + """create.""" + PATCH = "Patch" + """patch.""" + READ = "Read" + """read.""" + READ_FEED = "ReadFeed" + """read_feed.""" + DELETE = "Delete" + """delete.""" + REPLACE = "Replace" + """replace.""" + EXECUTE = "Execute" + """execute.""" + QUERY = "Query" + """query.""" + HEAD = "Head" + """head.""" + HEAD_FEED = "HeadFeed" + """head_feed.""" + UPSERT = "Upsert" + """upsert.""" + BATCH = "Batch" + """batch.""" + QUERY_PLAN = "QueryPlan" + """query_plan.""" + EXECUTE_JAVASCRIPT = "ExecuteJavaScript" + """execute_javascript.""" + + +class DbSystemValues(Enum): + OTHER_SQL = "other_sql" + """Some other SQL database. Fallback only. See notes.""" + MSSQL = "mssql" + """Microsoft SQL Server.""" + MSSQLCOMPACT = "mssqlcompact" + """Microsoft SQL Server Compact.""" + MYSQL = "mysql" + """MySQL.""" + ORACLE = "oracle" + """Oracle Database.""" + DB2 = "db2" + """IBM Db2.""" + POSTGRESQL = "postgresql" + """PostgreSQL.""" + REDSHIFT = "redshift" + """Amazon Redshift.""" + HIVE = "hive" + """Apache Hive.""" + CLOUDSCAPE = "cloudscape" + """Cloudscape.""" + HSQLDB = "hsqldb" + """HyperSQL DataBase.""" + PROGRESS = "progress" + """Progress Database.""" + MAXDB = "maxdb" + """SAP MaxDB.""" + HANADB = "hanadb" + """SAP HANA.""" + INGRES = "ingres" + """Ingres.""" + FIRSTSQL = "firstsql" + """FirstSQL.""" + EDB = "edb" + """EnterpriseDB.""" + CACHE = "cache" + """InterSystems Caché.""" + ADABAS = "adabas" + """Adabas (Adaptable Database System).""" + FIREBIRD = "firebird" + """Firebird.""" + DERBY = "derby" + """Apache Derby.""" + FILEMAKER = "filemaker" + """FileMaker.""" + INFORMIX = "informix" + """Informix.""" + INSTANTDB = "instantdb" + """InstantDB.""" + INTERBASE = "interbase" + """InterBase.""" + MARIADB = "mariadb" + """MariaDB.""" + NETEZZA = "netezza" + """Netezza.""" + PERVASIVE = "pervasive" + """Pervasive PSQL.""" + POINTBASE = "pointbase" + """PointBase.""" + SQLITE = "sqlite" + """SQLite.""" + SYBASE = "sybase" + """Sybase.""" + TERADATA = "teradata" + """Teradata.""" + VERTICA = "vertica" + """Vertica.""" + H2 = "h2" + """H2.""" + COLDFUSION = "coldfusion" + """ColdFusion IMQ.""" + CASSANDRA = "cassandra" + """Apache Cassandra.""" + HBASE = "hbase" + """Apache HBase.""" + MONGODB = "mongodb" + """MongoDB.""" + REDIS = "redis" + """Redis.""" + COUCHBASE = "couchbase" + """Couchbase.""" + COUCHDB = "couchdb" + """CouchDB.""" + COSMOSDB = "cosmosdb" + """Microsoft Azure Cosmos DB.""" + DYNAMODB = "dynamodb" + """Amazon DynamoDB.""" + NEO4J = "neo4j" + """Neo4j.""" + GEODE = "geode" + """Apache Geode.""" + ELASTICSEARCH = "elasticsearch" + """Elasticsearch.""" + MEMCACHED = "memcached" + """Memcached.""" + COCKROACHDB = "cockroachdb" + """CockroachDB.""" + OPENSEARCH = "opensearch" + """OpenSearch.""" + CLICKHOUSE = "clickhouse" + """ClickHouse.""" + SPANNER = "spanner" + """Cloud Spanner.""" + TRINO = "trino" + """Trino.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/deployment_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/deployment_attributes.py new file mode 100644 index 0000000000..c735bf2a10 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/deployment_attributes.py @@ -0,0 +1,26 @@ +# 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. + + +DEPLOYMENT_ENVIRONMENT = "deployment.environment" +""" +Name of the [deployment environment](https://wikipedia.org/wiki/Deployment_environment) (aka deployment tier). +Note: `deployment.environment` does not affect the uniqueness constraints defined through + the `service.namespace`, `service.name` and `service.instance.id` resource attributes. + This implies that resources carrying the following attribute combinations MUST be + considered to be identifying the same service: + + * `service.name=frontend`, `deployment.environment=production` + * `service.name=frontend`, `deployment.environment=staging`. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/destination_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/destination_attributes.py new file mode 100644 index 0000000000..c96ae68f43 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/destination_attributes.py @@ -0,0 +1,25 @@ +# 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. + + +DESTINATION_ADDRESS = "destination.address" +""" +Destination address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. +Note: When observed from the source side, and when communicating through an intermediary, `destination.address` SHOULD represent the destination address behind any intermediaries, for example proxies, if it's available. +""" + +DESTINATION_PORT = "destination.port" +""" +Destination port number. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/device_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/device_attributes.py new file mode 100644 index 0000000000..f9fc6503eb --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/device_attributes.py @@ -0,0 +1,38 @@ +# 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. + + +DEVICE_ID = "device.id" +""" +A unique identifier representing the device. +Note: The device identifier MUST only be defined using the values outlined below. This value is not an advertising identifier and MUST NOT be used as such. On iOS (Swift or Objective-C), this value MUST be equal to the [vendor identifier](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor). On Android (Java or Kotlin), this value MUST be equal to the Firebase Installation ID or a globally unique UUID which is persisted across sessions in your application. More information can be found [here](https://developer.android.com/training/articles/user-data-ids) on best practices and exact implementation details. Caution should be taken when storing personal data or anything which can identify a user. GDPR and data protection laws may apply, ensure you do your own due diligence. +""" + +DEVICE_MANUFACTURER = "device.manufacturer" +""" +The name of the device manufacturer. +Note: The Android OS provides this field via [Build](https://developer.android.com/reference/android/os/Build#MANUFACTURER). iOS apps SHOULD hardcode the value `Apple`. +""" + +DEVICE_MODEL_IDENTIFIER = "device.model.identifier" +""" +The model identifier for the device. +Note: It's recommended this value represents a machine-readable version of the model identifier rather than the market or consumer-friendly name of the device. +""" + +DEVICE_MODEL_NAME = "device.model.name" +""" +The marketing name for the device model. +Note: It's recommended this value represents a human-readable version of the device model rather than a machine-readable alternative. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/disk_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/disk_attributes.py new file mode 100644 index 0000000000..0553eb2625 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/disk_attributes.py @@ -0,0 +1,28 @@ +# 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 + +DISK_IO_DIRECTION = "disk.io.direction" +""" +The disk IO operation direction. +""" + + +class DiskIoDirectionValues(Enum): + READ = "read" + """read.""" + WRITE = "write" + """write.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/dns_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/dns_attributes.py new file mode 100644 index 0000000000..899e2587d0 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/dns_attributes.py @@ -0,0 +1,20 @@ +# 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. + + +DNS_QUESTION_NAME = "dns.question.name" +""" +The name being queried. +Note: If the name field contains non-printable characters (below 32 or above 126), those characters should be represented as escaped base 10 integers (\\DDD). Back slashes and quotes should be escaped. Tabs, carriage returns, and line feeds should be converted to \\t, \\r, and \\n respectively. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/enduser_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/enduser_attributes.py new file mode 100644 index 0000000000..05d83db373 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/enduser_attributes.py @@ -0,0 +1,29 @@ +# 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. + + +ENDUSER_ID = "enduser.id" +""" +Username or client_id extracted from the access token or [Authorization](https://tools.ietf.org/html/rfc7235#section-4.2) header in the inbound request from outside the system. +""" + +ENDUSER_ROLE = "enduser.role" +""" +Actual/assumed role the client is making the request under extracted from token or application security context. +""" + +ENDUSER_SCOPE = "enduser.scope" +""" +Scopes or granted authorities the client currently possesses extracted from token or application security context. The value would come from the scope associated with an [OAuth 2.0 Access Token](https://tools.ietf.org/html/rfc6749#section-3.3) or an attribute value in a [SAML 2.0 Assertion](http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html). +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/error_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/error_attributes.py new file mode 100644 index 0000000000..603d6ed72e --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/error_attributes.py @@ -0,0 +1,31 @@ +# 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 deprecated import deprecated + +ERROR_TYPE = "error.type" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.error_attributes.ERROR_TYPE`. +""" + + +@deprecated( + reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.error_attributes.ErrorTypeValues`." +) +class ErrorTypeValues(Enum): + OTHER = "_OTHER" + """A fallback error value to be used when the instrumentation doesn't define a custom value.""" 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 new file mode 100644 index 0000000000..c417cc70d3 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/event_attributes.py @@ -0,0 +1,20 @@ +# 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. + + +EVENT_NAME = "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. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/exception_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/exception_attributes.py new file mode 100644 index 0000000000..dd78656b4a --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/exception_attributes.py @@ -0,0 +1,34 @@ +# 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. + + +EXCEPTION_ESCAPED = "exception.escaped" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.exception_attributes.EXCEPTION_ESCAPED`. +""" + +EXCEPTION_MESSAGE = "exception.message" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.exception_attributes.EXCEPTION_MESSAGE`. +""" + +EXCEPTION_STACKTRACE = "exception.stacktrace" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.exception_attributes.EXCEPTION_STACKTRACE`. +""" + +EXCEPTION_TYPE = "exception.type" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.exception_attributes.EXCEPTION_TYPE`. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/faas_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/faas_attributes.py new file mode 100644 index 0000000000..f93a016414 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/faas_attributes.py @@ -0,0 +1,161 @@ +# 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 + +FAAS_COLDSTART = "faas.coldstart" +""" +A boolean that is true if the serverless function is executed for the first time (aka cold-start). +""" + +FAAS_CRON = "faas.cron" +""" +A string containing the schedule period as [Cron Expression](https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm). +""" + +FAAS_DOCUMENT_COLLECTION = "faas.document.collection" +""" +The name of the source on which the triggering operation was performed. For example, in Cloud Storage or S3 corresponds to the bucket name, and in Cosmos DB to the database name. +""" + +FAAS_DOCUMENT_NAME = "faas.document.name" +""" +The document name/table subjected to the operation. For example, in Cloud Storage or S3 is the name of the file, and in Cosmos DB the table name. +""" + +FAAS_DOCUMENT_OPERATION = "faas.document.operation" +""" +Describes the type of the operation that was performed on the data. +""" + +FAAS_DOCUMENT_TIME = "faas.document.time" +""" +A string containing the time when the data was accessed in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). +""" + +FAAS_INSTANCE = "faas.instance" +""" +The execution environment ID as a string, that will be potentially reused for other invocations to the same function/function version. +Note: * **AWS Lambda:** Use the (full) log stream name. +""" + +FAAS_INVOCATION_ID = "faas.invocation_id" +""" +The invocation ID of the current function invocation. +""" + +FAAS_INVOKED_NAME = "faas.invoked_name" +""" +The name of the invoked function. +Note: SHOULD be equal to the `faas.name` resource attribute of the invoked function. +""" + +FAAS_INVOKED_PROVIDER = "faas.invoked_provider" +""" +The cloud provider of the invoked function. +Note: SHOULD be equal to the `cloud.provider` resource attribute of the invoked function. +""" + +FAAS_INVOKED_REGION = "faas.invoked_region" +""" +The cloud region of the invoked function. +Note: SHOULD be equal to the `cloud.region` resource attribute of the invoked function. +""" + +FAAS_MAX_MEMORY = "faas.max_memory" +""" +The amount of memory available to the serverless function converted to Bytes. +Note: It's recommended to set this attribute since e.g. too little memory can easily stop a Java AWS Lambda function from working correctly. On AWS Lambda, the environment variable `AWS_LAMBDA_FUNCTION_MEMORY_SIZE` provides this information (which must be multiplied by 1,048,576). +""" + +FAAS_NAME = "faas.name" +""" +The name of the single function that this runtime instance executes. +Note: This is the name of the function as configured/deployed on the FaaS + platform and is usually different from the name of the callback + function (which may be stored in the + [`code.namespace`/`code.function`](/docs/general/attributes.md#source-code-attributes) + span attributes). + + For some cloud providers, the above definition is ambiguous. The following + definition of function name MUST be used for this attribute + (and consequently the span name) for the listed cloud providers/products: + + * **Azure:** The full name `/`, i.e., function app name + followed by a forward slash followed by the function name (this form + can also be seen in the resource JSON for the function). + This means that a span attribute MUST be used, as an Azure function + app can host multiple functions that would usually share + a TracerProvider (see also the `cloud.resource_id` attribute). +""" + +FAAS_TIME = "faas.time" +""" +A string containing the function invocation time in the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format expressed in [UTC](https://www.w3.org/TR/NOTE-datetime). +""" + +FAAS_TRIGGER = "faas.trigger" +""" +Type of the trigger which caused this function invocation. +""" + +FAAS_VERSION = "faas.version" +""" +The immutable version of the function being executed. +Note: Depending on the cloud provider and platform, use: + + * **AWS Lambda:** The [function version](https://docs.aws.amazon.com/lambda/latest/dg/configuration-versions.html) + (an integer represented as a decimal string). + * **Google Cloud Run (Services):** The [revision](https://cloud.google.com/run/docs/managing/revisions) + (i.e., the function name plus the revision suffix). + * **Google Cloud Functions:** The value of the + [`K_REVISION` environment variable](https://cloud.google.com/functions/docs/env-var#runtime_environment_variables_set_automatically). + * **Azure Functions:** Not applicable. Do not set this attribute. +""" + + +class FaasDocumentOperationValues(Enum): + INSERT = "insert" + """When a new object is created.""" + EDIT = "edit" + """When an object is modified.""" + DELETE = "delete" + """When an object is deleted.""" + + +class FaasInvokedProviderValues(Enum): + ALIBABA_CLOUD = "alibaba_cloud" + """Alibaba Cloud.""" + AWS = "aws" + """Amazon Web Services.""" + AZURE = "azure" + """Microsoft Azure.""" + GCP = "gcp" + """Google Cloud Platform.""" + TENCENT_CLOUD = "tencent_cloud" + """Tencent Cloud.""" + + +class FaasTriggerValues(Enum): + DATASOURCE = "datasource" + """A response to some data source operation such as a database or filesystem read/write.""" + HTTP = "http" + """To provide an answer to an inbound HTTP request.""" + PUBSUB = "pubsub" + """A function is set to be executed when messages are sent to a messaging system.""" + TIMER = "timer" + """A function is scheduled to be executed regularly.""" + OTHER = "other" + """If none of the others apply.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/feature_flag_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/feature_flag_attributes.py new file mode 100644 index 0000000000..8302f9666a --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/feature_flag_attributes.py @@ -0,0 +1,37 @@ +# 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. + + +FEATURE_FLAG_KEY = "feature_flag.key" +""" +The unique identifier of the feature flag. +""" + +FEATURE_FLAG_PROVIDER_NAME = "feature_flag.provider_name" +""" +The name of the service provider that performs the flag evaluation. +""" + +FEATURE_FLAG_VARIANT = "feature_flag.variant" +""" +SHOULD be a semantic identifier for a value. If one is unavailable, a stringified version of the value can be used. +Note: A semantic identifier, commonly referred to as a variant, provides a means + for referring to a value without including the value itself. This can + provide additional context for understanding the meaning behind a value. + For example, the variant `red` maybe be used for the value `#c05543`. + + A stringified version of the value can be used in situations where a + semantic identifier is unavailable. String representation of the value + should be determined by the implementer. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/file_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/file_attributes.py new file mode 100644 index 0000000000..1b760c4d1d --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/file_attributes.py @@ -0,0 +1,40 @@ +# 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. + + +FILE_DIRECTORY = "file.directory" +""" +Directory where the file is located. It should include the drive letter, when appropriate. +""" + +FILE_EXTENSION = "file.extension" +""" +File extension, excluding the leading dot. +Note: When the file name has multiple extensions (example.tar.gz), only the last one should be captured ("gz", not "tar.gz"). +""" + +FILE_NAME = "file.name" +""" +Name of the file including the extension, without the directory. +""" + +FILE_PATH = "file.path" +""" +Full path to the file, including the file name. It should include the drive letter, when appropriate. +""" + +FILE_SIZE = "file.size" +""" +File size in bytes. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/gcp_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/gcp_attributes.py new file mode 100644 index 0000000000..0b5f6a0c96 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/gcp_attributes.py @@ -0,0 +1,34 @@ +# 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. + + +GCP_CLOUD_RUN_JOB_EXECUTION = "gcp.cloud_run.job.execution" +""" +The name of the Cloud Run [execution](https://cloud.google.com/run/docs/managing/job-executions) being run for the Job, as set by the [`CLOUD_RUN_EXECUTION`](https://cloud.google.com/run/docs/container-contract#jobs-env-vars) environment variable. +""" + +GCP_CLOUD_RUN_JOB_TASK_INDEX = "gcp.cloud_run.job.task_index" +""" +The index for a task within an execution as provided by the [`CLOUD_RUN_TASK_INDEX`](https://cloud.google.com/run/docs/container-contract#jobs-env-vars) environment variable. +""" + +GCP_GCE_INSTANCE_HOSTNAME = "gcp.gce.instance.hostname" +""" +The hostname of a GCE instance. This is the full value of the default or [custom hostname](https://cloud.google.com/compute/docs/instances/custom-hostname-vm). +""" + +GCP_GCE_INSTANCE_NAME = "gcp.gce.instance.name" +""" +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). +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/graphql_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/graphql_attributes.py new file mode 100644 index 0000000000..f005d167d6 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/graphql_attributes.py @@ -0,0 +1,41 @@ +# 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 + +GRAPHQL_DOCUMENT = "graphql.document" +""" +The GraphQL document being executed. +Note: The value may be sanitized to exclude sensitive information. +""" + +GRAPHQL_OPERATION_NAME = "graphql.operation.name" +""" +The name of the operation being executed. +""" + +GRAPHQL_OPERATION_TYPE = "graphql.operation.type" +""" +The type of the operation being executed. +""" + + +class GraphqlOperationTypeValues(Enum): + QUERY = "query" + """GraphQL query.""" + MUTATION = "mutation" + """GraphQL mutation.""" + SUBSCRIPTION = "subscription" + """GraphQL subscription.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/heroku_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/heroku_attributes.py new file mode 100644 index 0000000000..27ec50229e --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/heroku_attributes.py @@ -0,0 +1,29 @@ +# 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. + + +HEROKU_APP_ID = "heroku.app.id" +""" +Unique identifier for the application. +""" + +HEROKU_RELEASE_COMMIT = "heroku.release.commit" +""" +Commit hash for the current release. +""" + +HEROKU_RELEASE_CREATION_TIMESTAMP = "heroku.release.creation_timestamp" +""" +Time and date the release was created. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/host_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/host_attributes.py new file mode 100644 index 0000000000..994c57a406 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/host_attributes.py @@ -0,0 +1,113 @@ +# 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 + +HOST_ARCH = "host.arch" +""" +The CPU architecture the host system is running on. +""" + +HOST_CPU_CACHE_L2_SIZE = "host.cpu.cache.l2.size" +""" +The amount of level 2 memory cache available to the processor (in Bytes). +""" + +HOST_CPU_FAMILY = "host.cpu.family" +""" +Family or generation of the CPU. +""" + +HOST_CPU_MODEL_ID = "host.cpu.model.id" +""" +Model identifier. It provides more granular information about the CPU, distinguishing it from other CPUs within the same family. +""" + +HOST_CPU_MODEL_NAME = "host.cpu.model.name" +""" +Model designation of the processor. +""" + +HOST_CPU_STEPPING = "host.cpu.stepping" +""" +Stepping or core revisions. +""" + +HOST_CPU_VENDOR_ID = "host.cpu.vendor.id" +""" +Processor manufacturer identifier. A maximum 12-character string. +Note: [CPUID](https://wiki.osdev.org/CPUID) command returns the vendor ID string in EBX, EDX and ECX registers. Writing these to memory in this order results in a 12-character string. +""" + +HOST_ID = "host.id" +""" +Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. For non-containerized systems, this should be the `machine-id`. See the table below for the sources to use to determine the `machine-id` based on operating system. +""" + +HOST_IMAGE_ID = "host.image.id" +""" +VM image ID or host OS image ID. For Cloud, this value is from the provider. +""" + +HOST_IMAGE_NAME = "host.image.name" +""" +Name of the VM image or OS install the host was instantiated from. +""" + +HOST_IMAGE_VERSION = "host.image.version" +""" +The version string of the VM image or host OS as defined in [Version Attributes](/docs/resource/README.md#version-attributes). +""" + +HOST_IP = "host.ip" +""" +Available IP addresses of the host, excluding loopback interfaces. +Note: IPv4 Addresses MUST be specified in dotted-quad notation. IPv6 addresses MUST be specified in the [RFC 5952](https://www.rfc-editor.org/rfc/rfc5952.html) format. +""" + +HOST_MAC = "host.mac" +""" +Available MAC addresses of the host, excluding loopback interfaces. +Note: MAC Addresses MUST be represented in [IEEE RA hexadecimal form](https://standards.ieee.org/wp-content/uploads/import/documents/tutorials/eui.pdf): as hyphen-separated octets in uppercase hexadecimal form from most to least significant. +""" + +HOST_NAME = "host.name" +""" +Name of the host. On Unix systems, it may contain what the hostname command returns, or the fully qualified hostname, or another name specified by the user. +""" + +HOST_TYPE = "host.type" +""" +Type of host. For Cloud, this must be the machine type. +""" + + +class HostArchValues(Enum): + AMD64 = "amd64" + """AMD64.""" + ARM32 = "arm32" + """ARM32.""" + ARM64 = "arm64" + """ARM64.""" + IA64 = "ia64" + """Itanium.""" + PPC32 = "ppc32" + """32-bit PowerPC.""" + PPC64 = "ppc64" + """64-bit PowerPC.""" + S390X = "s390x" + """IBM z/Architecture.""" + X86 = "x86" + """32-bit x86.""" 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 new file mode 100644 index 0000000000..70e0e8d2f3 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/http_attributes.py @@ -0,0 +1,174 @@ +# 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 deprecated import deprecated + +HTTP_CONNECTION_STATE = "http.connection.state" +""" +State of the HTTP connection in the HTTP connection pool. +""" + +HTTP_FLAVOR = "http.flavor" +""" +Deprecated: Replaced by `network.protocol.name`. +""" + +HTTP_METHOD = "http.method" +""" +Deprecated: Replaced by `http.request.method`. +""" + +HTTP_REQUEST_BODY_SIZE = "http.request.body.size" +""" +The size of the request 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. +""" + +HTTP_REQUEST_HEADER_TEMPLATE = "http.request.header" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HTTP_REQUEST_HEADER_TEMPLATE`. +""" + +HTTP_REQUEST_METHOD = "http.request.method" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HTTP_REQUEST_METHOD`. +""" + +HTTP_REQUEST_METHOD_ORIGINAL = "http.request.method_original" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HTTP_REQUEST_METHOD_ORIGINAL`. +""" + +HTTP_REQUEST_RESEND_COUNT = "http.request.resend_count" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HTTP_REQUEST_RESEND_COUNT`. +""" + +HTTP_REQUEST_SIZE = "http.request.size" +""" +The total size of the request in bytes. This should be the total number of bytes sent over the wire, including the request line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and request body if any. +""" + +HTTP_REQUEST_CONTENT_LENGTH = "http.request_content_length" +""" +Deprecated: Replaced by `http.request.header.content-length`. +""" + +HTTP_RESPONSE_BODY_SIZE = "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. +""" + +HTTP_RESPONSE_HEADER_TEMPLATE = "http.response.header" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HTTP_RESPONSE_HEADER_TEMPLATE`. +""" + +HTTP_RESPONSE_SIZE = "http.response.size" +""" +The total size of the response in bytes. This should be the total number of bytes sent over the wire, including the status line (HTTP/1.1), framing (HTTP/2 and HTTP/3), headers, and response body and trailers if any. +""" + +HTTP_RESPONSE_STATUS_CODE = "http.response.status_code" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HTTP_RESPONSE_STATUS_CODE`. +""" + +HTTP_RESPONSE_CONTENT_LENGTH = "http.response_content_length" +""" +Deprecated: Replaced by `http.response.header.content-length`. +""" + +HTTP_ROUTE = "http.route" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HTTP_ROUTE`. +""" + +HTTP_SCHEME = "http.scheme" +""" +Deprecated: Replaced by `url.scheme` instead. +""" + +HTTP_STATUS_CODE = "http.status_code" +""" +Deprecated: Replaced by `http.response.status_code`. +""" + +HTTP_TARGET = "http.target" +""" +Deprecated: Split to `url.path` and `url.query. +""" + +HTTP_URL = "http.url" +""" +Deprecated: Replaced by `url.full`. +""" + +HTTP_USER_AGENT = "http.user_agent" +""" +Deprecated: Replaced by `user_agent.original`. +""" + + +class HttpConnectionStateValues(Enum): + ACTIVE = "active" + """active state.""" + IDLE = "idle" + """idle state.""" + + +@deprecated( + reason="The attribute http.flavor is deprecated - Replaced by `network.protocol.name`" +) +class HttpFlavorValues(Enum): + HTTP_1_0 = "1.0" + """HTTP/1.0.""" + HTTP_1_1 = "1.1" + """HTTP/1.1.""" + HTTP_2_0 = "2.0" + """HTTP/2.""" + HTTP_3_0 = "3.0" + """HTTP/3.""" + SPDY = "SPDY" + """SPDY protocol.""" + QUIC = "QUIC" + """QUIC protocol.""" + + +@deprecated( + reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.http_attributes.HttpRequestMethodValues`." +) +class HttpRequestMethodValues(Enum): + CONNECT = "CONNECT" + """CONNECT method.""" + DELETE = "DELETE" + """DELETE method.""" + GET = "GET" + """GET method.""" + HEAD = "HEAD" + """HEAD method.""" + OPTIONS = "OPTIONS" + """OPTIONS method.""" + PATCH = "PATCH" + """PATCH method.""" + POST = "POST" + """POST method.""" + PUT = "PUT" + """PUT method.""" + TRACE = "TRACE" + """TRACE method.""" + OTHER = "_OTHER" + """Any HTTP method that the instrumentation has no prior knowledge of.""" 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 new file mode 100644 index 0000000000..fcc1d0d8de --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/k8s_attributes.py @@ -0,0 +1,156 @@ +# 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. + + +K8S_CLUSTER_NAME = "k8s.cluster.name" +""" +The name of the cluster. +""" + +K8S_CLUSTER_UID = "k8s.cluster.uid" +""" +A pseudo-ID for the cluster, set to the UID of the `kube-system` namespace. +Note: K8s doesn't have support for obtaining a cluster ID. If this is ever + added, we will recommend collecting the `k8s.cluster.uid` through the + official APIs. In the meantime, we are able to use the `uid` of the + `kube-system` namespace as a proxy for cluster ID. Read on for the + rationale. + + Every object created in a K8s cluster is assigned a distinct UID. The + `kube-system` namespace is used by Kubernetes itself and will exist + for the lifetime of the cluster. Using the `uid` of the `kube-system` + namespace is a reasonable proxy for the K8s ClusterID as it will only + change if the cluster is rebuilt. Furthermore, Kubernetes UIDs are + UUIDs as standardized by + [ISO/IEC 9834-8 and ITU-T X.667](https://www.itu.int/ITU-T/studygroups/com17/oid.html). + Which states: + + > If generated according to one of the mechanisms defined in Rec. + ITU-T X.667 | ISO/IEC 9834-8, a UUID is either guaranteed to be + different from all other UUIDs generated before 3603 A.D., or is + extremely likely to be different (depending on the mechanism chosen). + + Therefore, UIDs between clusters should be extremely unlikely to + conflict. +""" + +K8S_CONTAINER_NAME = "k8s.container.name" +""" +The name of the Container from Pod specification, must be unique within a Pod. Container runtime usually uses different globally unique name (`container.name`). +""" + +K8S_CONTAINER_RESTART_COUNT = "k8s.container.restart_count" +""" +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_CRONJOB_NAME = "k8s.cronjob.name" +""" +The name of the CronJob. +""" + +K8S_CRONJOB_UID = "k8s.cronjob.uid" +""" +The UID of the CronJob. +""" + +K8S_DAEMONSET_NAME = "k8s.daemonset.name" +""" +The name of the DaemonSet. +""" + +K8S_DAEMONSET_UID = "k8s.daemonset.uid" +""" +The UID of the DaemonSet. +""" + +K8S_DEPLOYMENT_NAME = "k8s.deployment.name" +""" +The name of the Deployment. +""" + +K8S_DEPLOYMENT_UID = "k8s.deployment.uid" +""" +The UID of the Deployment. +""" + +K8S_JOB_NAME = "k8s.job.name" +""" +The name of the Job. +""" + +K8S_JOB_UID = "k8s.job.uid" +""" +The UID of the Job. +""" + +K8S_NAMESPACE_NAME = "k8s.namespace.name" +""" +The name of the namespace that the pod is running in. +""" + +K8S_NODE_NAME = "k8s.node.name" +""" +The name of the Node. +""" + +K8S_NODE_UID = "k8s.node.uid" +""" +The UID of the Node. +""" + +K8S_POD_ANNOTATION_TEMPLATE = "k8s.pod.annotation" +""" +The annotation key-value pairs placed on the Pod, the `` being the annotation name, the value being the annotation value. +""" + +K8S_POD_LABEL_TEMPLATE = "k8s.pod.label" +""" +The label key-value pairs placed on the Pod, the `` being the label name, the value being the label value. +""" + +K8S_POD_LABELS_TEMPLATE = "k8s.pod.labels" +""" +Deprecated: Replaced by `k8s.pod.label`. +""" + +K8S_POD_NAME = "k8s.pod.name" +""" +The name of the Pod. +""" + +K8S_POD_UID = "k8s.pod.uid" +""" +The UID of the Pod. +""" + +K8S_REPLICASET_NAME = "k8s.replicaset.name" +""" +The name of the ReplicaSet. +""" + +K8S_REPLICASET_UID = "k8s.replicaset.uid" +""" +The UID of the ReplicaSet. +""" + +K8S_STATEFULSET_NAME = "k8s.statefulset.name" +""" +The name of the StatefulSet. +""" + +K8S_STATEFULSET_UID = "k8s.statefulset.uid" +""" +The UID of the StatefulSet. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/log_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/log_attributes.py new file mode 100644 index 0000000000..ff94348558 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/log_attributes.py @@ -0,0 +1,55 @@ +# 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 + +LOG_FILE_NAME = "log.file.name" +""" +The basename of the file. +""" + +LOG_FILE_NAME_RESOLVED = "log.file.name_resolved" +""" +The basename of the file, with symlinks resolved. +""" + +LOG_FILE_PATH = "log.file.path" +""" +The full path to the file. +""" + +LOG_FILE_PATH_RESOLVED = "log.file.path_resolved" +""" +The full path to the file, with symlinks resolved. +""" + +LOG_IOSTREAM = "log.iostream" +""" +The stream associated with the log. See below for a list of well-known values. +""" + +LOG_RECORD_UID = "log.record.uid" +""" +A unique identifier for the Log Record. +Note: If an id is provided, other log records with the same id will be considered duplicates and can be removed safely. This means, that two distinguishable log records MUST have different values. + The id MAY be an [Universally Unique Lexicographically Sortable Identifier (ULID)](https://github.com/ulid/spec), but other identifiers (e.g. UUID) may be used as needed. +""" + + +class LogIostreamValues(Enum): + STDOUT = "stdout" + """Logs from stdout stream.""" + STDERR = "stderr" + """Events from stderr stream.""" 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 new file mode 100644 index 0000000000..dea3ba65ae --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/message_attributes.py @@ -0,0 +1,44 @@ +# 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 + +MESSAGE_COMPRESSED_SIZE = "message.compressed_size" +""" +Compressed size of the message in bytes. +""" + +MESSAGE_ID = "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. +""" + +MESSAGE_TYPE = "message.type" +""" +Whether this is a received or sent message. +""" + +MESSAGE_UNCOMPRESSED_SIZE = "message.uncompressed_size" +""" +Uncompressed size of the message in bytes. +""" + + +class MessageTypeValues(Enum): + SENT = "SENT" + """sent.""" + RECEIVED = "RECEIVED" + """received.""" 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 new file mode 100644 index 0000000000..c3c7ce85c6 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/messaging_attributes.py @@ -0,0 +1,305 @@ +# 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 + +MESSAGING_BATCH_MESSAGE_COUNT = "messaging.batch.message_count" +""" +The number of messages sent, received, or processed in the scope of the batching operation. +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 = "messaging.client_id" +""" +A unique identifier for the client that consumes or produces a message. +""" + +MESSAGING_DESTINATION_ANONYMOUS = "messaging.destination.anonymous" +""" +A boolean that is true if the message destination is anonymous (could be unnamed or have auto-generated name). +""" + +MESSAGING_DESTINATION_NAME = "messaging.destination.name" +""" +The message destination name. +Note: Destination name SHOULD uniquely identify a specific queue, topic or other entity within the broker. If + the broker doesn't have such notion, the destination name SHOULD uniquely identify the broker. +""" + +MESSAGING_DESTINATION_PARTITION_ID = "messaging.destination.partition.id" +""" +The identifier of the partition messages are sent to or received from, unique within the `messaging.destination.name`. +""" + +MESSAGING_DESTINATION_TEMPLATE = "messaging.destination.template" +""" +Low cardinality representation of the messaging destination name. +Note: Destination names could be constructed from templates. An example would be a destination name involving a user name or product id. Although the destination name in this case is of high cardinality, the underlying template is of low cardinality and can be effectively used for grouping and aggregation. +""" + +MESSAGING_DESTINATION_TEMPORARY = "messaging.destination.temporary" +""" +A boolean that is true if the message destination is temporary and might not exist anymore after messages are processed. +""" + +MESSAGING_DESTINATION_PUBLISH_ANONYMOUS = ( + "messaging.destination_publish.anonymous" +) +""" +A boolean that is true if the publish message destination is anonymous (could be unnamed or have auto-generated name). +""" + +MESSAGING_DESTINATION_PUBLISH_NAME = "messaging.destination_publish.name" +""" +The name of the original destination the message was published to. +Note: The name SHOULD uniquely identify a specific queue, topic, or other entity within the broker. If + the broker doesn't have such notion, the original destination name SHOULD uniquely identify the broker. +""" + +MESSAGING_EVENTHUBS_CONSUMER_GROUP = "messaging.eventhubs.consumer.group" +""" +The name of the consumer group the event consumer is associated with. +""" + +MESSAGING_EVENTHUBS_MESSAGE_ENQUEUED_TIME = ( + "messaging.eventhubs.message.enqueued_time" +) +""" +The UTC epoch seconds at which the message has been accepted and stored in the entity. +""" + +MESSAGING_GCP_PUBSUB_MESSAGE_ORDERING_KEY = ( + "messaging.gcp_pubsub.message.ordering_key" +) +""" +The ordering key for a given message. If the attribute is not present, the message does not have an ordering key. +""" + +MESSAGING_KAFKA_CONSUMER_GROUP = "messaging.kafka.consumer.group" +""" +Name of the Kafka Consumer Group that is handling the message. Only applies to consumers, not producers. +""" + +MESSAGING_KAFKA_DESTINATION_PARTITION = "messaging.kafka.destination.partition" +""" +Deprecated: Replaced by `messaging.destination.partition.id`. +""" + +MESSAGING_KAFKA_MESSAGE_KEY = "messaging.kafka.message.key" +""" +Message keys in Kafka are used for grouping alike messages to ensure they're processed on the same partition. They differ from `messaging.message.id` in that they're not unique. If the key is `null`, the attribute MUST NOT be set. +Note: If the key type is not string, it's string representation has to be supplied for the attribute. If the key has no unambiguous, canonical string form, don't include its value. +""" + +MESSAGING_KAFKA_MESSAGE_OFFSET = "messaging.kafka.message.offset" +""" +The offset of a record in the corresponding Kafka partition. +""" + +MESSAGING_KAFKA_MESSAGE_TOMBSTONE = "messaging.kafka.message.tombstone" +""" +A boolean that is true if the message is a tombstone. +""" + +MESSAGING_MESSAGE_BODY_SIZE = "messaging.message.body.size" +""" +The size of the message body in bytes. +Note: This can refer to both the compressed or uncompressed body size. If both sizes are known, the uncompressed + body size should be used. +""" + +MESSAGING_MESSAGE_CONVERSATION_ID = "messaging.message.conversation_id" +""" +The conversation ID identifying the conversation to which the message belongs, represented as a string. Sometimes called "Correlation ID". +""" + +MESSAGING_MESSAGE_ENVELOPE_SIZE = "messaging.message.envelope.size" +""" +The size of the message body and metadata in bytes. +Note: This can refer to both the compressed or uncompressed size. If both sizes are known, the uncompressed + size should be used. +""" + +MESSAGING_MESSAGE_ID = "messaging.message.id" +""" +A value used by the messaging system as an identifier for the message, represented as a string. +""" + +MESSAGING_OPERATION = "messaging.operation" +""" +A string identifying the kind of messaging operation. +Note: If a custom value is used, it MUST be of low cardinality. +""" + +MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY = ( + "messaging.rabbitmq.destination.routing_key" +) +""" +RabbitMQ message routing key. +""" + +MESSAGING_RABBITMQ_MESSAGE_DELIVERY_TAG = ( + "messaging.rabbitmq.message.delivery_tag" +) +""" +RabbitMQ message delivery tag. +""" + +MESSAGING_ROCKETMQ_CLIENT_GROUP = "messaging.rocketmq.client_group" +""" +Name of the RocketMQ producer/consumer group that is handling the message. The client type is identified by the SpanKind. +""" + +MESSAGING_ROCKETMQ_CONSUMPTION_MODEL = "messaging.rocketmq.consumption_model" +""" +Model of message consumption. This only applies to consumer spans. +""" + +MESSAGING_ROCKETMQ_MESSAGE_DELAY_TIME_LEVEL = ( + "messaging.rocketmq.message.delay_time_level" +) +""" +The delay time level for delay message, which determines the message delay time. +""" + +MESSAGING_ROCKETMQ_MESSAGE_DELIVERY_TIMESTAMP = ( + "messaging.rocketmq.message.delivery_timestamp" +) +""" +The timestamp in milliseconds that the delay message is expected to be delivered to consumer. +""" + +MESSAGING_ROCKETMQ_MESSAGE_GROUP = "messaging.rocketmq.message.group" +""" +It is essential for FIFO message. Messages that belong to the same message group are always processed one by one within the same consumer group. +""" + +MESSAGING_ROCKETMQ_MESSAGE_KEYS = "messaging.rocketmq.message.keys" +""" +Key(s) of message, another way to mark message besides message id. +""" + +MESSAGING_ROCKETMQ_MESSAGE_TAG = "messaging.rocketmq.message.tag" +""" +The secondary classifier of message besides topic. +""" + +MESSAGING_ROCKETMQ_MESSAGE_TYPE = "messaging.rocketmq.message.type" +""" +Type of message. +""" + +MESSAGING_ROCKETMQ_NAMESPACE = "messaging.rocketmq.namespace" +""" +Namespace of RocketMQ resources, resources in different namespaces are individual. +""" + +MESSAGING_SERVICEBUS_DESTINATION_SUBSCRIPTION_NAME = ( + "messaging.servicebus.destination.subscription_name" +) +""" +The name of the subscription in the topic messages are received from. +""" + +MESSAGING_SERVICEBUS_DISPOSITION_STATUS = ( + "messaging.servicebus.disposition_status" +) +""" +Describes the [settlement type](https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock). +""" + +MESSAGING_SERVICEBUS_MESSAGE_DELIVERY_COUNT = ( + "messaging.servicebus.message.delivery_count" +) +""" +Number of deliveries that have been attempted for this message. +""" + +MESSAGING_SERVICEBUS_MESSAGE_ENQUEUED_TIME = ( + "messaging.servicebus.message.enqueued_time" +) +""" +The UTC epoch seconds at which the message has been accepted and stored in the entity. +""" + +MESSAGING_SYSTEM = "messaging.system" +""" +An identifier for the messaging system being used. See below for a list of well-known identifiers. +""" + + +class MessagingOperationValues(Enum): + PUBLISH = "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 = "create" + """A message is created. "Create" spans always refer to a single message and are used to provide a unique creation context for messages in batch publishing scenarios.""" + RECEIVE = "receive" + """One or more messages are requested by a consumer. This operation refers to pull-based scenarios, where consumers explicitly call methods of messaging SDKs to receive messages.""" + DELIVER = "process" + """One or more messages are delivered to or processed by a consumer.""" + SETTLE = "settle" + """One or more messages are settled.""" + + +class MessagingRocketmqConsumptionModelValues(Enum): + CLUSTERING = "clustering" + """Clustering consumption model.""" + BROADCASTING = "broadcasting" + """Broadcasting consumption model.""" + + +class MessagingRocketmqMessageTypeValues(Enum): + NORMAL = "normal" + """Normal message.""" + FIFO = "fifo" + """FIFO message.""" + DELAY = "delay" + """Delay message.""" + TRANSACTION = "transaction" + """Transaction message.""" + + +class MessagingServicebusDispositionStatusValues(Enum): + COMPLETE = "complete" + """Message is completed.""" + ABANDON = "abandon" + """Message is abandoned.""" + DEAD_LETTER = "dead_letter" + """Message is sent to dead letter queue.""" + DEFER = "defer" + """Message is deferred.""" + + +class MessagingSystemValues(Enum): + ACTIVEMQ = "activemq" + """Apache ActiveMQ.""" + AWS_SQS = "aws_sqs" + """Amazon Simple Queue Service (SQS).""" + EVENTGRID = "eventgrid" + """Azure Event Grid.""" + EVENTHUBS = "eventhubs" + """Azure Event Hubs.""" + SERVICEBUS = "servicebus" + """Azure Service Bus.""" + GCP_PUBSUB = "gcp_pubsub" + """Google Cloud Pub/Sub.""" + JMS = "jms" + """Java Message Service.""" + KAFKA = "kafka" + """Apache Kafka.""" + RABBITMQ = "rabbitmq" + """RabbitMQ.""" + ROCKETMQ = "rocketmq" + """Apache RocketMQ.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/network_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/network_attributes.py new file mode 100644 index 0000000000..d226ff311c --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/network_attributes.py @@ -0,0 +1,182 @@ +# 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 deprecated import deprecated + +NETWORK_CARRIER_ICC = "network.carrier.icc" +""" +The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. +""" + +NETWORK_CARRIER_MCC = "network.carrier.mcc" +""" +The mobile carrier country code. +""" + +NETWORK_CARRIER_MNC = "network.carrier.mnc" +""" +The mobile carrier network code. +""" + +NETWORK_CARRIER_NAME = "network.carrier.name" +""" +The name of the mobile carrier. +""" + +NETWORK_CONNECTION_SUBTYPE = "network.connection.subtype" +""" +This describes more details regarding the connection.type. It may be the type of cell technology connection, but it could be used for describing details about a wifi connection. +""" + +NETWORK_CONNECTION_TYPE = "network.connection.type" +""" +The internet connection type. +""" + +NETWORK_IO_DIRECTION = "network.io.direction" +""" +The network IO operation direction. +""" + +NETWORK_LOCAL_ADDRESS = "network.local.address" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NETWORK_LOCAL_ADDRESS`. +""" + +NETWORK_LOCAL_PORT = "network.local.port" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NETWORK_LOCAL_PORT`. +""" + +NETWORK_PEER_ADDRESS = "network.peer.address" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NETWORK_PEER_ADDRESS`. +""" + +NETWORK_PEER_PORT = "network.peer.port" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NETWORK_PEER_PORT`. +""" + +NETWORK_PROTOCOL_NAME = "network.protocol.name" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NETWORK_PROTOCOL_NAME`. +""" + +NETWORK_PROTOCOL_VERSION = "network.protocol.version" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NETWORK_PROTOCOL_VERSION`. +""" + +NETWORK_TRANSPORT = "network.transport" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NETWORK_TRANSPORT`. +""" + +NETWORK_TYPE = "network.type" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NETWORK_TYPE`. +""" + + +class NetworkConnectionSubtypeValues(Enum): + GPRS = "gprs" + """GPRS.""" + EDGE = "edge" + """EDGE.""" + UMTS = "umts" + """UMTS.""" + CDMA = "cdma" + """CDMA.""" + EVDO_0 = "evdo_0" + """EVDO Rel. 0.""" + EVDO_A = "evdo_a" + """EVDO Rev. A.""" + CDMA2000_1XRTT = "cdma2000_1xrtt" + """CDMA2000 1XRTT.""" + HSDPA = "hsdpa" + """HSDPA.""" + HSUPA = "hsupa" + """HSUPA.""" + HSPA = "hspa" + """HSPA.""" + IDEN = "iden" + """IDEN.""" + EVDO_B = "evdo_b" + """EVDO Rev. B.""" + LTE = "lte" + """LTE.""" + EHRPD = "ehrpd" + """EHRPD.""" + HSPAP = "hspap" + """HSPAP.""" + GSM = "gsm" + """GSM.""" + TD_SCDMA = "td_scdma" + """TD-SCDMA.""" + IWLAN = "iwlan" + """IWLAN.""" + NR = "nr" + """5G NR (New Radio).""" + NRNSA = "nrnsa" + """5G NRNSA (New Radio Non-Standalone).""" + LTE_CA = "lte_ca" + """LTE CA.""" + + +class NetworkConnectionTypeValues(Enum): + WIFI = "wifi" + """wifi.""" + WIRED = "wired" + """wired.""" + CELL = "cell" + """cell.""" + UNAVAILABLE = "unavailable" + """unavailable.""" + UNKNOWN = "unknown" + """unknown.""" + + +class NetworkIoDirectionValues(Enum): + TRANSMIT = "transmit" + """transmit.""" + RECEIVE = "receive" + """receive.""" + + +@deprecated( + reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTransportValues`." +) +class NetworkTransportValues(Enum): + TCP = "tcp" + """TCP.""" + UDP = "udp" + """UDP.""" + PIPE = "pipe" + """Named or anonymous pipe.""" + UNIX = "unix" + """Unix domain socket.""" + + +@deprecated( + reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.network_attributes.NetworkTypeValues`." +) +class NetworkTypeValues(Enum): + IPV4 = "ipv4" + """IPv4.""" + IPV6 = "ipv6" + """IPv6.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/oci_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/oci_attributes.py new file mode 100644 index 0000000000..bda352d8ba --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/oci_attributes.py @@ -0,0 +1,21 @@ +# 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. + + +OCI_MANIFEST_DIGEST = "oci.manifest.digest" +""" +The digest of the OCI image manifest. For container images specifically is the digest by which the container image is known. +Note: Follows [OCI Image Manifest Specification](https://github.com/opencontainers/image-spec/blob/main/manifest.md), and specifically the [Digest property](https://github.com/opencontainers/image-spec/blob/main/descriptor.md#digests). + An example can be found in [Example Image Manifest](https://docs.docker.com/registry/spec/manifest-v2-2/#example-image-manifest). +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/opentracing_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/opentracing_attributes.py new file mode 100644 index 0000000000..6c2f4143b9 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/opentracing_attributes.py @@ -0,0 +1,29 @@ +# 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 + +OPENTRACING_REF_TYPE = "opentracing.ref_type" +""" +Parent-child Reference type. +Note: The causal relationship between a child Span and a parent Span. +""" + + +class OpentracingRefTypeValues(Enum): + CHILD_OF = "child_of" + """The parent Span depends on the child Span in some capacity.""" + FOLLOWS_FROM = "follows_from" + """The parent Span doesn't depend in any way on the result of the child Span.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/otel_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/otel_attributes.py new file mode 100644 index 0000000000..9a04a2ac95 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/otel_attributes.py @@ -0,0 +1,58 @@ +# 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 deprecated import deprecated + +OTEL_LIBRARY_NAME = "otel.library.name" +""" +Deprecated: use the `otel.scope.name` attribute. +""" + +OTEL_LIBRARY_VERSION = "otel.library.version" +""" +Deprecated: use the `otel.scope.version` attribute. +""" + +OTEL_SCOPE_NAME = "otel.scope.name" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.otel_attributes.OTEL_SCOPE_NAME`. +""" + +OTEL_SCOPE_VERSION = "otel.scope.version" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.otel_attributes.OTEL_SCOPE_VERSION`. +""" + +OTEL_STATUS_CODE = "otel.status_code" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.otel_attributes.OTEL_STATUS_CODE`. +""" + +OTEL_STATUS_DESCRIPTION = "otel.status_description" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.otel_attributes.OTEL_STATUS_DESCRIPTION`. +""" + + +@deprecated( + reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.otel_attributes.OtelStatusCodeValues`." +) +class OtelStatusCodeValues(Enum): + OK = "OK" + """The operation has been validated by an Application developer or Operator to have completed successfully.""" + ERROR = "ERROR" + """The operation contains an error.""" 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 new file mode 100644 index 0000000000..53f5cfc638 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/other_attributes.py @@ -0,0 +1,28 @@ +# 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 + +STATE = "state" +""" +The state of a connection in the pool. +""" + + +class StateValues(Enum): + IDLE = "idle" + """idle.""" + USED = "used" + """used.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/peer_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/peer_attributes.py new file mode 100644 index 0000000000..74a6926822 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/peer_attributes.py @@ -0,0 +1,19 @@ +# 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. + + +PEER_SERVICE = "peer.service" +""" +The [`service.name`](/docs/resource/README.md#service) of the remote service. SHOULD be equal to the actual `service.name` resource attribute of the remote service if any. +""" 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 new file mode 100644 index 0000000000..f02d6101d5 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/pool_attributes.py @@ -0,0 +1,19 @@ +# 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. + + +POOL_NAME = "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`. +""" 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 new file mode 100644 index 0000000000..5ab7c72f49 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/process_attributes.py @@ -0,0 +1,109 @@ +# 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 + +PROCESS_COMMAND = "process.command" +""" +The command used to launch the process (i.e. the command name). On Linux based systems, can be set to the zeroth string in `proc/[pid]/cmdline`. On Windows, can be set to the first parameter extracted from `GetCommandLineW`. +""" + +PROCESS_COMMAND_ARGS = "process.command_args" +""" +All the command arguments (including the command/executable itself) as received by the process. On Linux-based systems (and some other Unixoid systems supporting procfs), can be set according to the list of null-delimited strings extracted from `proc/[pid]/cmdline`. For libc-based executables, this would be the full argv vector passed to `main`. +""" + +PROCESS_COMMAND_LINE = "process.command_line" +""" +The full command used to launch the process as a single string representing the full command. On Windows, can be set to the result of `GetCommandLineW`. Do not set this if you have to assemble it just for monitoring; use `process.command_args` instead. +""" + +PROCESS_CONTEXT_SWITCH_TYPE = "process.context_switch_type" +""" +Specifies whether the context switches for this data point were voluntary or involuntary. +""" + +PROCESS_CPU_STATE = "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. +""" + +PROCESS_EXECUTABLE_NAME = "process.executable.name" +""" +The name of the process executable. On Linux based systems, can be set to the `Name` in `proc/[pid]/status`. On Windows, can be set to the base name of `GetProcessImageFileNameW`. +""" + +PROCESS_EXECUTABLE_PATH = "process.executable.path" +""" +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_OWNER = "process.owner" +""" +The username of the user that owns the process. +""" + +PROCESS_PAGING_FAULT_TYPE = "process.paging.fault_type" +""" +The type of page fault for this data point. Type `major` is for major/hard page faults, and `minor` is for minor/soft page faults. +""" + +PROCESS_PARENT_PID = "process.parent_pid" +""" +Parent Process identifier (PPID). +""" + +PROCESS_PID = "process.pid" +""" +Process identifier (PID). +""" + +PROCESS_RUNTIME_DESCRIPTION = "process.runtime.description" +""" +An additional description about the runtime of the process, for example a specific vendor customization of the runtime environment. +""" + +PROCESS_RUNTIME_NAME = "process.runtime.name" +""" +The name of the runtime of this process. For compiled native binaries, this SHOULD be the name of the compiler. +""" + +PROCESS_RUNTIME_VERSION = "process.runtime.version" +""" +The version of the runtime of this process, as returned by the runtime without modification. +""" + + +class ProcessContextSwitchTypeValues(Enum): + VOLUNTARY = "voluntary" + """voluntary.""" + INVOLUNTARY = "involuntary" + """involuntary.""" + + +class ProcessCpuStateValues(Enum): + SYSTEM = "system" + """system.""" + USER = "user" + """user.""" + WAIT = "wait" + """wait.""" + + +class ProcessPagingFaultTypeValues(Enum): + MAJOR = "major" + """major.""" + MINOR = "minor" + """minor.""" 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 new file mode 100644 index 0000000000..0d86cc211c --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/rpc_attributes.py @@ -0,0 +1,174 @@ +# 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 + +RPC_CONNECT_RPC_ERROR_CODE = "rpc.connect_rpc.error_code" +""" +The [error codes](https://connect.build/docs/protocol/#error-codes) of the Connect request. Error codes are always string values. +""" + +RPC_CONNECT_RPC_REQUEST_METADATA_TEMPLATE = "rpc.connect_rpc.request.metadata" +""" +Connect request metadata, `` being the normalized Connect Metadata key (lowercase), the value being the metadata values. +Note: Instrumentations SHOULD require an explicit configuration of which metadata values are to be captured. Including all request metadata values can be a security risk - explicit configuration helps avoid leaking sensitive information. +""" + +RPC_CONNECT_RPC_RESPONSE_METADATA_TEMPLATE = ( + "rpc.connect_rpc.response.metadata" +) +""" +Connect response metadata, `` being the normalized Connect Metadata key (lowercase), the value being the metadata values. +Note: Instrumentations SHOULD require an explicit configuration of which metadata values are to be captured. Including all response metadata values can be a security risk - explicit configuration helps avoid leaking sensitive information. +""" + +RPC_GRPC_REQUEST_METADATA_TEMPLATE = "rpc.grpc.request.metadata" +""" +gRPC request metadata, `` being the normalized gRPC Metadata key (lowercase), the value being the metadata values. +Note: Instrumentations SHOULD require an explicit configuration of which metadata values are to be captured. Including all request metadata values can be a security risk - explicit configuration helps avoid leaking sensitive information. +""" + +RPC_GRPC_RESPONSE_METADATA_TEMPLATE = "rpc.grpc.response.metadata" +""" +gRPC response metadata, `` being the normalized gRPC Metadata key (lowercase), the value being the metadata values. +Note: Instrumentations SHOULD require an explicit configuration of which metadata values are to be captured. Including all response metadata values can be a security risk - explicit configuration helps avoid leaking sensitive information. +""" + +RPC_GRPC_STATUS_CODE = "rpc.grpc.status_code" +""" +The [numeric status code](https://github.com/grpc/grpc/blob/v1.33.2/doc/statuscodes.md) of the gRPC request. +""" + +RPC_JSONRPC_ERROR_CODE = "rpc.jsonrpc.error_code" +""" +`error.code` property of response if it is an error response. +""" + +RPC_JSONRPC_ERROR_MESSAGE = "rpc.jsonrpc.error_message" +""" +`error.message` property of response if it is an error response. +""" + +RPC_JSONRPC_REQUEST_ID = "rpc.jsonrpc.request_id" +""" +`id` property of request or response. Since protocol allows id to be int, string, `null` or missing (for notifications), value is expected to be cast to string for simplicity. Use empty string in case of `null` value. Omit entirely if this is a notification. +""" + +RPC_JSONRPC_VERSION = "rpc.jsonrpc.version" +""" +Protocol version as in `jsonrpc` property of request/response. Since JSON-RPC 1.0 doesn't specify this, the value can be omitted. +""" + +RPC_METHOD = "rpc.method" +""" +The name of the (logical) method being called, must be equal to the $method part in the span name. +Note: This is the logical name of the method from the RPC interface perspective, which can be different from the name of any implementing method/function. The `code.function` attribute may be used to store the latter (e.g., method actually executing the call on the server side, RPC client stub method on the client side). +""" + +RPC_SERVICE = "rpc.service" +""" +The full (logical) name of the service being called, including its package name, if applicable. +Note: This is the logical name of the service from the RPC interface perspective, which can be different from the name of any implementing class. The `code.namespace` attribute may be used to store the latter (despite the attribute name, it may include a class name; e.g., class with method actually executing the call on the server side, RPC client stub class on the client side). +""" + +RPC_SYSTEM = "rpc.system" +""" +A string identifying the remoting system. See below for a list of well-known identifiers. +""" + + +class RpcConnectRpcErrorCodeValues(Enum): + CANCELLED = "cancelled" + """cancelled.""" + UNKNOWN = "unknown" + """unknown.""" + INVALID_ARGUMENT = "invalid_argument" + """invalid_argument.""" + DEADLINE_EXCEEDED = "deadline_exceeded" + """deadline_exceeded.""" + NOT_FOUND = "not_found" + """not_found.""" + ALREADY_EXISTS = "already_exists" + """already_exists.""" + PERMISSION_DENIED = "permission_denied" + """permission_denied.""" + RESOURCE_EXHAUSTED = "resource_exhausted" + """resource_exhausted.""" + FAILED_PRECONDITION = "failed_precondition" + """failed_precondition.""" + ABORTED = "aborted" + """aborted.""" + OUT_OF_RANGE = "out_of_range" + """out_of_range.""" + UNIMPLEMENTED = "unimplemented" + """unimplemented.""" + INTERNAL = "internal" + """internal.""" + UNAVAILABLE = "unavailable" + """unavailable.""" + DATA_LOSS = "data_loss" + """data_loss.""" + UNAUTHENTICATED = "unauthenticated" + """unauthenticated.""" + + +class RpcGrpcStatusCodeValues(Enum): + OK = 0 + """OK.""" + CANCELLED = 1 + """CANCELLED.""" + UNKNOWN = 2 + """UNKNOWN.""" + INVALID_ARGUMENT = 3 + """INVALID_ARGUMENT.""" + DEADLINE_EXCEEDED = 4 + """DEADLINE_EXCEEDED.""" + NOT_FOUND = 5 + """NOT_FOUND.""" + ALREADY_EXISTS = 6 + """ALREADY_EXISTS.""" + PERMISSION_DENIED = 7 + """PERMISSION_DENIED.""" + RESOURCE_EXHAUSTED = 8 + """RESOURCE_EXHAUSTED.""" + FAILED_PRECONDITION = 9 + """FAILED_PRECONDITION.""" + ABORTED = 10 + """ABORTED.""" + OUT_OF_RANGE = 11 + """OUT_OF_RANGE.""" + UNIMPLEMENTED = 12 + """UNIMPLEMENTED.""" + INTERNAL = 13 + """INTERNAL.""" + UNAVAILABLE = 14 + """UNAVAILABLE.""" + DATA_LOSS = 15 + """DATA_LOSS.""" + UNAUTHENTICATED = 16 + """UNAUTHENTICATED.""" + + +class RpcSystemValues(Enum): + GRPC = "grpc" + """gRPC.""" + JAVA_RMI = "java_rmi" + """Java RMI.""" + DOTNET_WCF = "dotnet_wcf" + """.NET WCF.""" + APACHE_DUBBO = "apache_dubbo" + """Apache Dubbo.""" + CONNECT_RPC = "connect_rpc" + """Connect RPC.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/server_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/server_attributes.py new file mode 100644 index 0000000000..b763be9a6c --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/server_attributes.py @@ -0,0 +1,24 @@ +# 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. + + +SERVER_ADDRESS = "server.address" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.server_attributes.SERVER_ADDRESS`. +""" + +SERVER_PORT = "server.port" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.server_attributes.SERVER_PORT`. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/service_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/service_attributes.py new file mode 100644 index 0000000000..eb8e9f498d --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/service_attributes.py @@ -0,0 +1,61 @@ +# 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. + + +SERVICE_INSTANCE_ID = "service.instance.id" +""" +The string ID of the service instance. +Note: MUST be unique for each instance of the same `service.namespace,service.name` pair (in other words + `service.namespace,service.name,service.instance.id` triplet MUST be globally unique). The ID helps to + distinguish instances of the same service that exist at the same time (e.g. instances of a horizontally scaled + service). + + Implementations, such as SDKs, are recommended to generate a random Version 1 or Version 4 [RFC + 4122](https://www.ietf.org/rfc/rfc4122.txt) UUID, but are free to use an inherent unique ID as the source of + this value if stability is desirable. In that case, the ID SHOULD be used as source of a UUID Version 5 and + SHOULD use the following UUID as the namespace: `4d63009a-8d0f-11ee-aad7-4c796ed8e320`. + + UUIDs are typically recommended, as only an opaque value for the purposes of identifying a service instance is + needed. Similar to what can be seen in the man page for the + [`/etc/machine-id`](https://www.freedesktop.org/software/systemd/man/machine-id.html) file, the underlying + data, such as pod name and namespace should be treated as confidential, being the user's choice to expose it + or not via another resource attribute. + + For applications running behind an application server (like unicorn), we do not recommend using one identifier + for all processes participating in the application. Instead, it's recommended each division (e.g. a worker + thread in unicorn) to have its own instance.id. + + It's not recommended for a Collector to set `service.instance.id` if it can't unambiguously determine the + service instance that is generating that telemetry. For instance, creating an UUID based on `pod.name` will + likely be wrong, as the Collector might not know from which container within that pod the telemetry originated. + However, Collectors can set the `service.instance.id` if they can unambiguously determine the service instance + for that telemetry. This is typically the case for scraping receivers, as they know the target address and + port. +""" + +SERVICE_NAME = "service.name" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.service_attributes.SERVICE_NAME`. +""" + +SERVICE_NAMESPACE = "service.namespace" +""" +A namespace for `service.name`. +Note: A string value having a meaning that helps to distinguish a group of services, for example the team name that owns a group of services. `service.name` is expected to be unique within the same namespace. If `service.namespace` is not specified in the Resource then `service.name` is expected to be unique for all services that have no explicit namespace defined (so the empty/unspecified namespace is simply one more valid namespace). Zero-length namespace string is assumed equal to unspecified namespace. +""" + +SERVICE_VERSION = "service.version" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.service_attributes.SERVICE_VERSION`. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/session_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/session_attributes.py new file mode 100644 index 0000000000..a0a9170aa3 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/session_attributes.py @@ -0,0 +1,24 @@ +# 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. + + +SESSION_ID = "session.id" +""" +A unique id to identify a session. +""" + +SESSION_PREVIOUS_ID = "session.previous_id" +""" +The previous `session.id` for this user, when known. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/source_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/source_attributes.py new file mode 100644 index 0000000000..b6020b30f6 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/source_attributes.py @@ -0,0 +1,25 @@ +# 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. + + +SOURCE_ADDRESS = "source.address" +""" +Source address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. +Note: When observed from the destination side, and when communicating through an intermediary, `source.address` SHOULD represent the source address behind any intermediaries, for example proxies, if it's available. +""" + +SOURCE_PORT = "source.port" +""" +Source port number. +""" 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 new file mode 100644 index 0000000000..eef4116900 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/system_attributes.py @@ -0,0 +1,215 @@ +# 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 deprecated import deprecated + +SYSTEM_CPU_LOGICAL_NUMBER = "system.cpu.logical_number" +""" +The logical CPU number [0..n-1]. +""" + +SYSTEM_CPU_STATE = "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. +""" + +SYSTEM_DEVICE = "system.device" +""" +The device identifier. +""" + +SYSTEM_FILESYSTEM_MODE = "system.filesystem.mode" +""" +The filesystem mode. +""" + +SYSTEM_FILESYSTEM_MOUNTPOINT = "system.filesystem.mountpoint" +""" +The filesystem mount path. +""" + +SYSTEM_FILESYSTEM_STATE = "system.filesystem.state" +""" +The filesystem state. +""" + +SYSTEM_FILESYSTEM_TYPE = "system.filesystem.type" +""" +The filesystem type. +""" + +SYSTEM_MEMORY_STATE = "system.memory.state" +""" +The memory state. +""" + +SYSTEM_NETWORK_STATE = "system.network.state" +""" +A stateless protocol MUST NOT set this attribute. +""" + +SYSTEM_PAGING_DIRECTION = "system.paging.direction" +""" +The paging access direction. +""" + +SYSTEM_PAGING_STATE = "system.paging.state" +""" +The memory paging state. +""" + +SYSTEM_PAGING_TYPE = "system.paging.type" +""" +The memory paging type. +""" + +SYSTEM_PROCESS_STATUS = "system.process.status" +""" +The process state, e.g., [Linux Process State Codes](https://man7.org/linux/man-pages/man1/ps.1.html#PROCESS_STATE_CODES). +""" + +SYSTEM_PROCESSES_STATUS = "system.processes.status" +""" +Deprecated: Replaced by `system.process.status`. +""" + + +class SystemCpuStateValues(Enum): + USER = "user" + """user.""" + SYSTEM = "system" + """system.""" + NICE = "nice" + """nice.""" + IDLE = "idle" + """idle.""" + IOWAIT = "iowait" + """iowait.""" + INTERRUPT = "interrupt" + """interrupt.""" + STEAL = "steal" + """steal.""" + + +class SystemFilesystemStateValues(Enum): + USED = "used" + """used.""" + FREE = "free" + """free.""" + RESERVED = "reserved" + """reserved.""" + + +class SystemFilesystemTypeValues(Enum): + FAT32 = "fat32" + """fat32.""" + EXFAT = "exfat" + """exfat.""" + NTFS = "ntfs" + """ntfs.""" + REFS = "refs" + """refs.""" + HFSPLUS = "hfsplus" + """hfsplus.""" + EXT4 = "ext4" + """ext4.""" + + +class SystemMemoryStateValues(Enum): + USED = "used" + """used.""" + FREE = "free" + """free.""" + SHARED = "shared" + """shared.""" + BUFFERS = "buffers" + """buffers.""" + CACHED = "cached" + """cached.""" + + +class SystemNetworkStateValues(Enum): + CLOSE = "close" + """close.""" + CLOSE_WAIT = "close_wait" + """close_wait.""" + CLOSING = "closing" + """closing.""" + DELETE = "delete" + """delete.""" + ESTABLISHED = "established" + """established.""" + FIN_WAIT_1 = "fin_wait_1" + """fin_wait_1.""" + FIN_WAIT_2 = "fin_wait_2" + """fin_wait_2.""" + LAST_ACK = "last_ack" + """last_ack.""" + LISTEN = "listen" + """listen.""" + SYN_RECV = "syn_recv" + """syn_recv.""" + SYN_SENT = "syn_sent" + """syn_sent.""" + TIME_WAIT = "time_wait" + """time_wait.""" + + +class SystemPagingDirectionValues(Enum): + IN = "in" + """in.""" + OUT = "out" + """out.""" + + +class SystemPagingStateValues(Enum): + USED = "used" + """used.""" + FREE = "free" + """free.""" + + +class SystemPagingTypeValues(Enum): + MAJOR = "major" + """major.""" + MINOR = "minor" + """minor.""" + + +class SystemProcessStatusValues(Enum): + RUNNING = "running" + """running.""" + SLEEPING = "sleeping" + """sleeping.""" + STOPPED = "stopped" + """stopped.""" + DEFUNCT = "defunct" + """defunct.""" + + +@deprecated( + reason="The attribute system.processes.status is deprecated - Replaced by `system.process.status`" +) +class SystemProcessesStatusValues(Enum): + RUNNING = "running" + """running.""" + SLEEPING = "sleeping" + """sleeping.""" + STOPPED = "stopped" + """stopped.""" + DEFUNCT = "defunct" + """defunct.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/telemetry_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/telemetry_attributes.py new file mode 100644 index 0000000000..b7ac5fac6c --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/telemetry_attributes.py @@ -0,0 +1,75 @@ +# 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 deprecated import deprecated + +TELEMETRY_DISTRO_NAME = "telemetry.distro.name" +""" +The name of the auto instrumentation agent or distribution, if used. +Note: Official auto instrumentation agents and distributions SHOULD set the `telemetry.distro.name` attribute to + a string starting with `opentelemetry-`, e.g. `opentelemetry-java-instrumentation`. +""" + +TELEMETRY_DISTRO_VERSION = "telemetry.distro.version" +""" +The version string of the auto instrumentation agent or distribution, if used. +""" + +TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.telemetry_attributes.TELEMETRY_SDK_LANGUAGE`. +""" + +TELEMETRY_SDK_NAME = "telemetry.sdk.name" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.telemetry_attributes.TELEMETRY_SDK_NAME`. +""" + +TELEMETRY_SDK_VERSION = "telemetry.sdk.version" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.telemetry_attributes.TELEMETRY_SDK_VERSION`. +""" + + +@deprecated( + reason="Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.telemetry_attributes.TelemetrySdkLanguageValues`." +) +class TelemetrySdkLanguageValues(Enum): + CPP = "cpp" + """cpp.""" + DOTNET = "dotnet" + """dotnet.""" + ERLANG = "erlang" + """erlang.""" + GO = "go" + """go.""" + JAVA = "java" + """java.""" + NODEJS = "nodejs" + """nodejs.""" + PHP = "php" + """php.""" + PYTHON = "python" + """python.""" + RUBY = "ruby" + """ruby.""" + RUST = "rust" + """rust.""" + SWIFT = "swift" + """swift.""" + WEBJS = "webjs" + """webjs.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/thread_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/thread_attributes.py new file mode 100644 index 0000000000..cd68db8197 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/thread_attributes.py @@ -0,0 +1,24 @@ +# 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. + + +THREAD_ID = "thread.id" +""" +Current "managed" thread ID (as opposed to OS thread ID). +""" + +THREAD_NAME = "thread.name" +""" +Current thread name. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/tls_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/tls_attributes.py new file mode 100644 index 0000000000..2abaa8cd60 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/tls_attributes.py @@ -0,0 +1,169 @@ +# 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 + +TLS_CIPHER = "tls.cipher" +""" +String indicating the [cipher](https://datatracker.ietf.org/doc/html/rfc5246#appendix-A.5) used during the current connection. +Note: The values allowed for `tls.cipher` MUST be one of the `Descriptions` of the [registered TLS Cipher Suits](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#table-tls-parameters-4). +""" + +TLS_CLIENT_CERTIFICATE = "tls.client.certificate" +""" +PEM-encoded stand-alone certificate offered by the client. This is usually mutually-exclusive of `client.certificate_chain` since this value also exists in that list. +""" + +TLS_CLIENT_CERTIFICATE_CHAIN = "tls.client.certificate_chain" +""" +Array of PEM-encoded certificates that make up the certificate chain offered by the client. This is usually mutually-exclusive of `client.certificate` since that value should be the first certificate in the chain. +""" + +TLS_CLIENT_HASH_MD5 = "tls.client.hash.md5" +""" +Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the client. For consistency with other hash values, this value should be formatted as an uppercase hash. +""" + +TLS_CLIENT_HASH_SHA1 = "tls.client.hash.sha1" +""" +Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by the client. For consistency with other hash values, this value should be formatted as an uppercase hash. +""" + +TLS_CLIENT_HASH_SHA256 = "tls.client.hash.sha256" +""" +Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by the client. For consistency with other hash values, this value should be formatted as an uppercase hash. +""" + +TLS_CLIENT_ISSUER = "tls.client.issuer" +""" +Distinguished name of [subject](https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6) of the issuer of the x.509 certificate presented by the client. +""" + +TLS_CLIENT_JA3 = "tls.client.ja3" +""" +A hash that identifies clients based on how they perform an SSL/TLS handshake. +""" + +TLS_CLIENT_NOT_AFTER = "tls.client.not_after" +""" +Date/Time indicating when client certificate is no longer considered valid. +""" + +TLS_CLIENT_NOT_BEFORE = "tls.client.not_before" +""" +Date/Time indicating when client certificate is first considered valid. +""" + +TLS_CLIENT_SERVER_NAME = "tls.client.server_name" +""" +Also called an SNI, this tells the server which hostname to which the client is attempting to connect to. +""" + +TLS_CLIENT_SUBJECT = "tls.client.subject" +""" +Distinguished name of subject of the x.509 certificate presented by the client. +""" + +TLS_CLIENT_SUPPORTED_CIPHERS = "tls.client.supported_ciphers" +""" +Array of ciphers offered by the client during the client hello. +""" + +TLS_CURVE = "tls.curve" +""" +String indicating the curve used for the given cipher, when applicable. +""" + +TLS_ESTABLISHED = "tls.established" +""" +Boolean flag indicating if the TLS negotiation was successful and transitioned to an encrypted tunnel. +""" + +TLS_NEXT_PROTOCOL = "tls.next_protocol" +""" +String indicating the protocol being tunneled. Per the values in the [IANA registry](https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids), this string should be lower case. +""" + +TLS_PROTOCOL_NAME = "tls.protocol.name" +""" +Normalized lowercase protocol name parsed from original string of the negotiated [SSL/TLS protocol version](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_version.html#RETURN-VALUES). +""" + +TLS_PROTOCOL_VERSION = "tls.protocol.version" +""" +Numeric part of the version parsed from the original string of the negotiated [SSL/TLS protocol version](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_version.html#RETURN-VALUES). +""" + +TLS_RESUMED = "tls.resumed" +""" +Boolean flag indicating if this TLS connection was resumed from an existing TLS negotiation. +""" + +TLS_SERVER_CERTIFICATE = "tls.server.certificate" +""" +PEM-encoded stand-alone certificate offered by the server. This is usually mutually-exclusive of `server.certificate_chain` since this value also exists in that list. +""" + +TLS_SERVER_CERTIFICATE_CHAIN = "tls.server.certificate_chain" +""" +Array of PEM-encoded certificates that make up the certificate chain offered by the server. This is usually mutually-exclusive of `server.certificate` since that value should be the first certificate in the chain. +""" + +TLS_SERVER_HASH_MD5 = "tls.server.hash.md5" +""" +Certificate fingerprint using the MD5 digest of DER-encoded version of certificate offered by the server. For consistency with other hash values, this value should be formatted as an uppercase hash. +""" + +TLS_SERVER_HASH_SHA1 = "tls.server.hash.sha1" +""" +Certificate fingerprint using the SHA1 digest of DER-encoded version of certificate offered by the server. For consistency with other hash values, this value should be formatted as an uppercase hash. +""" + +TLS_SERVER_HASH_SHA256 = "tls.server.hash.sha256" +""" +Certificate fingerprint using the SHA256 digest of DER-encoded version of certificate offered by the server. For consistency with other hash values, this value should be formatted as an uppercase hash. +""" + +TLS_SERVER_ISSUER = "tls.server.issuer" +""" +Distinguished name of [subject](https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6) of the issuer of the x.509 certificate presented by the client. +""" + +TLS_SERVER_JA3S = "tls.server.ja3s" +""" +A hash that identifies servers based on how they perform an SSL/TLS handshake. +""" + +TLS_SERVER_NOT_AFTER = "tls.server.not_after" +""" +Date/Time indicating when server certificate is no longer considered valid. +""" + +TLS_SERVER_NOT_BEFORE = "tls.server.not_before" +""" +Date/Time indicating when server certificate is first considered valid. +""" + +TLS_SERVER_SUBJECT = "tls.server.subject" +""" +Distinguished name of subject of the x.509 certificate presented by the server. +""" + + +class TlsProtocolNameValues(Enum): + SSL = "ssl" + """ssl.""" + TLS = "tls" + """tls.""" 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 new file mode 100644 index 0000000000..6646f2e68d --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/url_attributes.py @@ -0,0 +1,81 @@ +# 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. + + +URL_DOMAIN = "url.domain" +""" +Domain extracted from the `url.full`, such as "opentelemetry.io". +Note: In some cases a URL may refer to an IP and/or port directly, without a domain name. In this case, the IP address would go to the domain field. If the URL contains a [literal IPv6 address](https://www.rfc-editor.org/rfc/rfc2732#section-2) enclosed by `[` and `]`, the `[` and `]` characters should also be captured in the domain field. +""" + +URL_EXTENSION = "url.extension" +""" +The file extension extracted from the `url.full`, excluding the leading dot. +Note: The file extension is only set if it exists, as not every url has a file extension. When the file name has multiple extensions `example.tar.gz`, only the last one should be captured `gz`, not `tar.gz`. +""" + +URL_FRAGMENT = "url.fragment" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.url_attributes.URL_FRAGMENT`. +""" + +URL_FULL = "url.full" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.url_attributes.URL_FULL`. +""" + +URL_ORIGINAL = "url.original" +""" +Unmodified original URL as seen in the event source. +Note: In network monitoring, the observed URL may be a full URL, whereas in access logs, the URL is often just represented as a path. This field is meant to represent the URL as it was observed, complete or not. + `url.original` might contain credentials passed via URL in form of `https://username:password@www.example.com/`. In such case password and username SHOULD NOT be redacted and attribute's value SHOULD remain the same. +""" + +URL_PATH = "url.path" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.url_attributes.URL_PATH`. +""" + +URL_PORT = "url.port" +""" +Port extracted from the `url.full`. +""" + +URL_QUERY = "url.query" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.url_attributes.URL_QUERY`. +""" + +URL_REGISTERED_DOMAIN = "url.registered_domain" +""" +The highest registered url domain, stripped of the subdomain. +Note: This value can be determined precisely with the [public suffix list](http://publicsuffix.org). For example, the registered domain for `foo.example.com` is `example.com`. Trying to approximate this by simply taking the last two labels will not work well for TLDs such as `co.uk`. +""" + +URL_SCHEME = "url.scheme" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.url_attributes.URL_SCHEME`. +""" + +URL_SUBDOMAIN = "url.subdomain" +""" +The subdomain portion of a fully qualified domain name includes all of the names except the host name under the registered_domain. In a partially qualified domain, or if the qualification level of the full name cannot be determined, subdomain contains all of the names below the registered domain. +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_TOP_LEVEL_DOMAIN = "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`. +Note: This value can be determined precisely with the [public suffix list](http://publicsuffix.org). +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/user_agent_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/user_agent_attributes.py new file mode 100644 index 0000000000..2237a2d3f1 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/user_agent_attributes.py @@ -0,0 +1,31 @@ +# 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. + + +USER_AGENT_NAME = "user_agent.name" +""" +Name of the user-agent extracted from original. Usually refers to the browser's name. +Note: [Example](https://www.whatsmyua.info) of extracting browser's name from original string. In the case of using a user-agent for non-browser products, such as microservices with multiple names/versions inside the `user_agent.original`, the most significant name SHOULD be selected. In such a scenario it should align with `user_agent.version`. +""" + +USER_AGENT_ORIGINAL = "user_agent.original" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.attributes.user_agent_attributes.USER_AGENT_ORIGINAL`. +""" + +USER_AGENT_VERSION = "user_agent.version" +""" +Version of the user-agent extracted from original. Usually refers to the browser's version. +Note: [Example](https://www.whatsmyua.info) of extracting browser's version from original string. In the case of using a user-agent for non-browser products, such as microservices with multiple names/versions inside the `user_agent.original`, the most significant version SHOULD be selected. In such a scenario it should align with `user_agent.name`. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/webengine_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/webengine_attributes.py new file mode 100644 index 0000000000..e29971b032 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/attributes/webengine_attributes.py @@ -0,0 +1,29 @@ +# 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. + + +WEBENGINE_DESCRIPTION = "webengine.description" +""" +Additional description of the web engine (e.g. detailed version and edition information). +""" + +WEBENGINE_NAME = "webengine.name" +""" +The name of the web engine. +""" + +WEBENGINE_VERSION = "webengine.version" +""" +The version of the web engine. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/container_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/container_metrics.py new file mode 100644 index 0000000000..d4c8437ece --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/container_metrics.py @@ -0,0 +1,87 @@ +# 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 opentelemetry.metrics import Counter, Meter + +CONTAINER_CPU_TIME = "container.cpu.time" +""" +Total CPU time consumed +Instrument: counter +Unit: s +Note: Total CPU time consumed by the specific container on all available CPU cores. +""" + + +def create_container_cpu_time(meter: Meter) -> Counter: + """Total CPU time consumed""" + return meter.create_counter( + name="container.cpu.time", + description="Total CPU time consumed", + unit="s", + ) + + +CONTAINER_DISK_IO = "container.disk.io" +""" +Disk bytes for the container +Instrument: counter +Unit: By +Note: The total number of bytes read/written successfully (aggregated from all disks). +""" + + +def create_container_disk_io(meter: Meter) -> Counter: + """Disk bytes for the container""" + return meter.create_counter( + name="container.disk.io", + description="Disk bytes for the container.", + unit="By", + ) + + +CONTAINER_MEMORY_USAGE = "container.memory.usage" +""" +Memory usage of the container +Instrument: counter +Unit: By +Note: Memory usage of the container. +""" + + +def create_container_memory_usage(meter: Meter) -> Counter: + """Memory usage of the container""" + return meter.create_counter( + name="container.memory.usage", + description="Memory usage of the container.", + unit="By", + ) + + +CONTAINER_NETWORK_IO = "container.network.io" +""" +Network bytes for the container +Instrument: counter +Unit: By +Note: The number of bytes sent/received on all network interfaces by the container. +""" + + +def create_container_network_io(meter: Meter) -> Counter: + """Network bytes for the container""" + return meter.create_counter( + name="container.network.io", + description="Network bytes for the container.", + unit="By", + ) 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 new file mode 100644 index 0000000000..63a86e91c1 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/db_metrics.py @@ -0,0 +1,172 @@ +# 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 opentelemetry.metrics import Counter, Histogram, Meter, UpDownCounter + +DB_CLIENT_CONNECTIONS_CREATE_TIME = "db.client.connections.create_time" +""" +The time it took to create a new connection +Instrument: histogram +Unit: ms +""" + + +def create_db_client_connections_create_time(meter: Meter) -> Histogram: + """The time it took to create a new connection""" + return meter.create_histogram( + name="db.client.connections.create_time", + description="The time it took to create a new connection", + unit="ms", + ) + + +DB_CLIENT_CONNECTIONS_IDLE_MAX = "db.client.connections.idle.max" +""" +The maximum number of idle open connections allowed +Instrument: updowncounter +Unit: {connection} +""" + + +def create_db_client_connections_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", + description="The maximum number of idle open connections allowed", + unit="{connection}", + ) + + +DB_CLIENT_CONNECTIONS_IDLE_MIN = "db.client.connections.idle.min" +""" +The minimum number of idle open connections allowed +Instrument: updowncounter +Unit: {connection} +""" + + +def create_db_client_connections_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", + description="The minimum number of idle open connections allowed", + unit="{connection}", + ) + + +DB_CLIENT_CONNECTIONS_MAX = "db.client.connections.max" +""" +The maximum number of open connections allowed +Instrument: updowncounter +Unit: {connection} +""" + + +def create_db_client_connections_max(meter: Meter) -> UpDownCounter: + """The maximum number of open connections allowed""" + return meter.create_up_down_counter( + name="db.client.connections.max", + description="The maximum number of open connections allowed", + unit="{connection}", + ) + + +DB_CLIENT_CONNECTIONS_PENDING_REQUESTS = ( + "db.client.connections.pending_requests" +) +""" +The number of pending requests for an open connection, cumulative for the entire pool +Instrument: updowncounter +Unit: {request} +""" + + +def create_db_client_connections_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", + description="The number of pending requests for an open connection, cumulative for the entire pool", + unit="{request}", + ) + + +DB_CLIENT_CONNECTIONS_TIMEOUTS = "db.client.connections.timeouts" +""" +The number of connection timeouts that have occurred trying to obtain a connection from the pool +Instrument: counter +Unit: {timeout} +""" + + +def create_db_client_connections_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", + description="The number of connection timeouts that have occurred trying to obtain a connection from the pool", + unit="{timeout}", + ) + + +DB_CLIENT_CONNECTIONS_USAGE = "db.client.connections.usage" +""" +The number of connections that are currently in state described by the `state` attribute +Instrument: updowncounter +Unit: {connection} +""" + + +def create_db_client_connections_usage(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.connections.usage", + description="The number of connections that are currently in state described by the `state` attribute", + unit="{connection}", + ) + + +DB_CLIENT_CONNECTIONS_USE_TIME = "db.client.connections.use_time" +""" +The time between borrowing a connection and returning it to the pool +Instrument: histogram +Unit: ms +""" + + +def create_db_client_connections_use_time(meter: Meter) -> Histogram: + """The time between borrowing a connection and returning it to the pool""" + return meter.create_histogram( + name="db.client.connections.use_time", + description="The time between borrowing a connection and returning it to the pool", + unit="ms", + ) + + +DB_CLIENT_CONNECTIONS_WAIT_TIME = "db.client.connections.wait_time" +""" +The time it took to obtain an open connection from the pool +Instrument: histogram +Unit: ms +""" + + +def create_db_client_connections_wait_time(meter: Meter) -> Histogram: + """The time it took to obtain an open connection from the pool""" + return meter.create_histogram( + name="db.client.connections.wait_time", + description="The time it took to obtain an open connection from the pool", + unit="ms", + ) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/dns_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/dns_metrics.py new file mode 100644 index 0000000000..200b309c95 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/dns_metrics.py @@ -0,0 +1,32 @@ +# 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 opentelemetry.metrics import Histogram, Meter + +DNS_LOOKUP_DURATION = "dns.lookup.duration" +""" +Measures the time taken to perform a DNS lookup +Instrument: histogram +Unit: s +""" + + +def create_dns_lookup_duration(meter: Meter) -> Histogram: + """Measures the time taken to perform a DNS lookup""" + return meter.create_histogram( + name="dns.lookup.duration", + description="Measures the time taken to perform a DNS lookup.", + unit="s", + ) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/faas_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/faas_metrics.py new file mode 100644 index 0000000000..f93e707c00 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/faas_metrics.py @@ -0,0 +1,168 @@ +# 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 opentelemetry.metrics import Counter, Histogram, Meter + +FAAS_COLDSTARTS = "faas.coldstarts" +""" +Number of invocation cold starts +Instrument: counter +Unit: {coldstart} +""" + + +def create_faas_coldstarts(meter: Meter) -> Counter: + """Number of invocation cold starts""" + return meter.create_counter( + name="faas.coldstarts", + description="Number of invocation cold starts", + unit="{coldstart}", + ) + + +FAAS_CPU_USAGE = "faas.cpu_usage" +""" +Distribution of CPU usage per invocation +Instrument: histogram +Unit: s +""" + + +def create_faas_cpu_usage(meter: Meter) -> Histogram: + """Distribution of CPU usage per invocation""" + return meter.create_histogram( + name="faas.cpu_usage", + description="Distribution of CPU usage per invocation", + unit="s", + ) + + +FAAS_ERRORS = "faas.errors" +""" +Number of invocation errors +Instrument: counter +Unit: {error} +""" + + +def create_faas_errors(meter: Meter) -> Counter: + """Number of invocation errors""" + return meter.create_counter( + name="faas.errors", + description="Number of invocation errors", + unit="{error}", + ) + + +FAAS_INIT_DURATION = "faas.init_duration" +""" +Measures the duration of the function's initialization, such as a cold start +Instrument: histogram +Unit: s +""" + + +def create_faas_init_duration(meter: Meter) -> Histogram: + """Measures the duration of the function's initialization, such as a cold start""" + return meter.create_histogram( + name="faas.init_duration", + description="Measures the duration of the function's initialization, such as a cold start", + unit="s", + ) + + +FAAS_INVOCATIONS = "faas.invocations" +""" +Number of successful invocations +Instrument: counter +Unit: {invocation} +""" + + +def create_faas_invocations(meter: Meter) -> Counter: + """Number of successful invocations""" + return meter.create_counter( + name="faas.invocations", + description="Number of successful invocations", + unit="{invocation}", + ) + + +FAAS_INVOKE_DURATION = "faas.invoke_duration" +""" +Measures the duration of the function's logic execution +Instrument: histogram +Unit: s +""" + + +def create_faas_invoke_duration(meter: Meter) -> Histogram: + """Measures the duration of the function's logic execution""" + return meter.create_histogram( + name="faas.invoke_duration", + description="Measures the duration of the function's logic execution", + unit="s", + ) + + +FAAS_MEM_USAGE = "faas.mem_usage" +""" +Distribution of max memory usage per invocation +Instrument: histogram +Unit: By +""" + + +def create_faas_mem_usage(meter: Meter) -> Histogram: + """Distribution of max memory usage per invocation""" + return meter.create_histogram( + name="faas.mem_usage", + description="Distribution of max memory usage per invocation", + unit="By", + ) + + +FAAS_NET_IO = "faas.net_io" +""" +Distribution of net I/O usage per invocation +Instrument: histogram +Unit: By +""" + + +def create_faas_net_io(meter: Meter) -> Histogram: + """Distribution of net I/O usage per invocation""" + return meter.create_histogram( + name="faas.net_io", + description="Distribution of net I/O usage per invocation", + unit="By", + ) + + +FAAS_TIMEOUTS = "faas.timeouts" +""" +Number of invocation timeouts +Instrument: counter +Unit: {timeout} +""" + + +def create_faas_timeouts(meter: Meter) -> Counter: + """Number of invocation timeouts""" + return meter.create_counter( + name="faas.timeouts", + description="Number of invocation timeouts", + unit="{timeout}", + ) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/http_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/http_metrics.py new file mode 100644 index 0000000000..7852a39587 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/http_metrics.py @@ -0,0 +1,185 @@ +# 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 opentelemetry.metrics import Histogram, Meter, UpDownCounter + +HTTP_CLIENT_ACTIVE_REQUESTS = "http.client.active_requests" +""" +Number of active HTTP requests +Instrument: updowncounter +Unit: {request} +""" + + +def create_http_client_active_requests(meter: Meter) -> UpDownCounter: + """Number of active HTTP requests""" + return meter.create_up_down_counter( + name="http.client.active_requests", + description="Number of active HTTP requests.", + unit="{request}", + ) + + +HTTP_CLIENT_CONNECTION_DURATION = "http.client.connection.duration" +""" +The duration of the successfully established outbound HTTP connections +Instrument: histogram +Unit: s +""" + + +def create_http_client_connection_duration(meter: Meter) -> Histogram: + """The duration of the successfully established outbound HTTP connections""" + return meter.create_histogram( + name="http.client.connection.duration", + description="The duration of the successfully established outbound HTTP connections.", + unit="s", + ) + + +HTTP_CLIENT_OPEN_CONNECTIONS = "http.client.open_connections" +""" +Number of outbound HTTP connections that are currently active or idle on the client +Instrument: updowncounter +Unit: {connection} +""" + + +def create_http_client_open_connections(meter: Meter) -> UpDownCounter: + """Number of outbound HTTP connections that are currently active or idle on the client""" + return meter.create_up_down_counter( + name="http.client.open_connections", + description="Number of outbound HTTP connections that are currently active or idle on the client.", + unit="{connection}", + ) + + +HTTP_CLIENT_REQUEST_BODY_SIZE = "http.client.request.body.size" +""" +Size of HTTP client request bodies +Instrument: histogram +Unit: By +Note: The size of the request 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. +""" + + +def create_http_client_request_body_size(meter: Meter) -> Histogram: + """Size of HTTP client request bodies""" + return meter.create_histogram( + name="http.client.request.body.size", + description="Size of HTTP client request bodies.", + unit="By", + ) + + +HTTP_CLIENT_REQUEST_DURATION = "http.client.request.duration" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.metrics.http_metrics.HTTP_CLIENT_REQUEST_DURATION`. +""" + + +def create_http_client_request_duration(meter: Meter) -> Histogram: + """Duration of HTTP client requests""" + return meter.create_histogram( + name="http.client.request.duration", + description="Duration of HTTP client requests.", + unit="s", + ) + + +HTTP_CLIENT_RESPONSE_BODY_SIZE = "http.client.response.body.size" +""" +Size of HTTP client response bodies +Instrument: histogram +Unit: By +Note: 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. +""" + + +def create_http_client_response_body_size(meter: Meter) -> Histogram: + """Size of HTTP client response bodies""" + return meter.create_histogram( + name="http.client.response.body.size", + description="Size of HTTP client response bodies.", + unit="By", + ) + + +HTTP_SERVER_ACTIVE_REQUESTS = "http.server.active_requests" +""" +Number of active HTTP server requests +Instrument: updowncounter +Unit: {request} +""" + + +def create_http_server_active_requests(meter: Meter) -> UpDownCounter: + """Number of active HTTP server requests""" + return meter.create_up_down_counter( + name="http.server.active_requests", + description="Number of active HTTP server requests.", + unit="{request}", + ) + + +HTTP_SERVER_REQUEST_BODY_SIZE = "http.server.request.body.size" +""" +Size of HTTP server request bodies +Instrument: histogram +Unit: By +Note: The size of the request 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. +""" + + +def create_http_server_request_body_size(meter: Meter) -> Histogram: + """Size of HTTP server request bodies""" + return meter.create_histogram( + name="http.server.request.body.size", + description="Size of HTTP server request bodies.", + unit="By", + ) + + +HTTP_SERVER_REQUEST_DURATION = "http.server.request.duration" +""" +Deprecated in favor of stable :py:const:`opentelemetry.semconv.metrics.http_metrics.HTTP_SERVER_REQUEST_DURATION`. +""" + + +def create_http_server_request_duration(meter: Meter) -> Histogram: + """Duration of HTTP server requests""" + return meter.create_histogram( + name="http.server.request.duration", + description="Duration of HTTP server requests.", + unit="s", + ) + + +HTTP_SERVER_RESPONSE_BODY_SIZE = "http.server.response.body.size" +""" +Size of HTTP server response bodies +Instrument: histogram +Unit: By +Note: 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. +""" + + +def create_http_server_response_body_size(meter: Meter) -> Histogram: + """Size of HTTP server response bodies""" + return meter.create_histogram( + name="http.server.response.body.size", + description="Size of HTTP server response bodies.", + unit="By", + ) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/messaging_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/messaging_metrics.py new file mode 100644 index 0000000000..ac3cb549ab --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/messaging_metrics.py @@ -0,0 +1,117 @@ +# 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 opentelemetry.metrics import Counter, Histogram, Meter + +MESSAGING_PROCESS_DURATION = "messaging.process.duration" +""" +Measures the duration of process operation +Instrument: histogram +Unit: s +""" + + +def create_messaging_process_duration(meter: Meter) -> Histogram: + """Measures the duration of process operation""" + return meter.create_histogram( + name="messaging.process.duration", + description="Measures the duration of process operation.", + unit="s", + ) + + +MESSAGING_PROCESS_MESSAGES = "messaging.process.messages" +""" +Measures the number of processed messages +Instrument: counter +Unit: {message} +""" + + +def create_messaging_process_messages(meter: Meter) -> Counter: + """Measures the number of processed messages""" + return meter.create_counter( + name="messaging.process.messages", + description="Measures the number of processed messages.", + unit="{message}", + ) + + +MESSAGING_PUBLISH_DURATION = "messaging.publish.duration" +""" +Measures the duration of publish operation +Instrument: histogram +Unit: s +""" + + +def create_messaging_publish_duration(meter: Meter) -> Histogram: + """Measures the duration of publish operation""" + return meter.create_histogram( + name="messaging.publish.duration", + description="Measures the duration of publish operation.", + unit="s", + ) + + +MESSAGING_PUBLISH_MESSAGES = "messaging.publish.messages" +""" +Measures the number of published messages +Instrument: counter +Unit: {message} +""" + + +def create_messaging_publish_messages(meter: Meter) -> Counter: + """Measures the number of published messages""" + return meter.create_counter( + name="messaging.publish.messages", + description="Measures the number of published messages.", + unit="{message}", + ) + + +MESSAGING_RECEIVE_DURATION = "messaging.receive.duration" +""" +Measures the duration of receive operation +Instrument: histogram +Unit: s +""" + + +def create_messaging_receive_duration(meter: Meter) -> Histogram: + """Measures the duration of receive operation""" + return meter.create_histogram( + name="messaging.receive.duration", + description="Measures the duration of receive operation.", + unit="s", + ) + + +MESSAGING_RECEIVE_MESSAGES = "messaging.receive.messages" +""" +Measures the number of received messages +Instrument: counter +Unit: {message} +""" + + +def create_messaging_receive_messages(meter: Meter) -> Counter: + """Measures the number of received messages""" + return meter.create_counter( + name="messaging.receive.messages", + description="Measures the number of received messages.", + unit="{message}", + ) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/process_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/process_metrics.py new file mode 100644 index 0000000000..8d6e7fc75c --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/process_metrics.py @@ -0,0 +1,195 @@ +# 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 typing import Callable, Sequence + +from opentelemetry.metrics import ( + Counter, + Meter, + ObservableGauge, + UpDownCounter, +) + +PROCESS_CONTEXT_SWITCHES = "process.context_switches" +""" +Number of times the process has been context switched +Instrument: counter +Unit: {count} +""" + + +def create_process_context_switches(meter: Meter) -> Counter: + """Number of times the process has been context switched""" + return meter.create_counter( + name="process.context_switches", + description="Number of times the process has been context switched.", + unit="{count}", + ) + + +PROCESS_CPU_TIME = "process.cpu.time" +""" +Total CPU seconds broken down by different states +Instrument: counter +Unit: s +""" + + +def create_process_cpu_time(meter: Meter) -> Counter: + """Total CPU seconds broken down by different states""" + return meter.create_counter( + name="process.cpu.time", + description="Total CPU seconds broken down by different states.", + unit="s", + ) + + +PROCESS_CPU_UTILIZATION = "process.cpu.utilization" +""" +Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process +Instrument: gauge +Unit: 1 +""" + + +def create_process_cpu_utilization( + meter: Meter, callback: Sequence[Callable] +) -> ObservableGauge: + """Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process""" + return meter.create_observable_gauge( + name="process.cpu.utilization", + callback=callback, + description="Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process.", + unit="1", + ) + + +PROCESS_DISK_IO = "process.disk.io" +""" +Disk bytes transferred +Instrument: counter +Unit: By +""" + + +def create_process_disk_io(meter: Meter) -> Counter: + """Disk bytes transferred""" + return meter.create_counter( + name="process.disk.io", + description="Disk bytes transferred.", + unit="By", + ) + + +PROCESS_MEMORY_USAGE = "process.memory.usage" +""" +The amount of physical memory in use +Instrument: updowncounter +Unit: By +""" + + +def create_process_memory_usage(meter: Meter) -> UpDownCounter: + """The amount of physical memory in use""" + return meter.create_up_down_counter( + name="process.memory.usage", + description="The amount of physical memory in use.", + unit="By", + ) + + +PROCESS_MEMORY_VIRTUAL = "process.memory.virtual" +""" +The amount of committed virtual memory +Instrument: updowncounter +Unit: By +""" + + +def create_process_memory_virtual(meter: Meter) -> UpDownCounter: + """The amount of committed virtual memory""" + return meter.create_up_down_counter( + name="process.memory.virtual", + description="The amount of committed virtual memory.", + unit="By", + ) + + +PROCESS_NETWORK_IO = "process.network.io" +""" +Network bytes transferred +Instrument: counter +Unit: By +""" + + +def create_process_network_io(meter: Meter) -> Counter: + """Network bytes transferred""" + return meter.create_counter( + name="process.network.io", + description="Network bytes transferred.", + unit="By", + ) + + +PROCESS_OPEN_FILE_DESCRIPTOR_COUNT = "process.open_file_descriptor.count" +""" +Number of file descriptors in use by the process +Instrument: updowncounter +Unit: {count} +""" + + +def create_process_open_file_descriptor_count(meter: Meter) -> UpDownCounter: + """Number of file descriptors in use by the process""" + return meter.create_up_down_counter( + name="process.open_file_descriptor.count", + description="Number of file descriptors in use by the process.", + unit="{count}", + ) + + +PROCESS_PAGING_FAULTS = "process.paging.faults" +""" +Number of page faults the process has made +Instrument: counter +Unit: {fault} +""" + + +def create_process_paging_faults(meter: Meter) -> Counter: + """Number of page faults the process has made""" + return meter.create_counter( + name="process.paging.faults", + description="Number of page faults the process has made.", + unit="{fault}", + ) + + +PROCESS_THREAD_COUNT = "process.thread.count" +""" +Process threads count +Instrument: updowncounter +Unit: {thread} +""" + + +def create_process_thread_count(meter: Meter) -> UpDownCounter: + """Process threads count""" + return meter.create_up_down_counter( + name="process.thread.count", + description="Process threads count.", + unit="{thread}", + ) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/rpc_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/rpc_metrics.py new file mode 100644 index 0000000000..eb2f5edd75 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/rpc_metrics.py @@ -0,0 +1,209 @@ +# 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 opentelemetry.metrics import Histogram, Meter + +RPC_CLIENT_DURATION = "rpc.client.duration" +""" +Measures the duration of outbound RPC +Instrument: histogram +Unit: ms +Note: While streaming RPCs may record this metric as start-of-batch + to end-of-batch, it's hard to interpret in practice. + + **Streaming**: N/A. +""" + + +def create_rpc_client_duration(meter: Meter) -> Histogram: + """Measures the duration of outbound RPC""" + return meter.create_histogram( + name="rpc.client.duration", + description="Measures the duration of outbound RPC.", + unit="ms", + ) + + +RPC_CLIENT_REQUEST_SIZE = "rpc.client.request.size" +""" +Measures the size of RPC request messages (uncompressed) +Instrument: histogram +Unit: By +Note: **Streaming**: Recorded per message in a streaming batch. +""" + + +def create_rpc_client_request_size(meter: Meter) -> Histogram: + """Measures the size of RPC request messages (uncompressed)""" + return meter.create_histogram( + name="rpc.client.request.size", + description="Measures the size of RPC request messages (uncompressed).", + unit="By", + ) + + +RPC_CLIENT_REQUESTS_PER_RPC = "rpc.client.requests_per_rpc" +""" +Measures the number of messages received per RPC +Instrument: histogram +Unit: {count} +Note: Should be 1 for all non-streaming RPCs. + + **Streaming**: This metric is required for server and client streaming RPCs. +""" + + +def create_rpc_client_requests_per_rpc(meter: Meter) -> Histogram: + """Measures the number of messages received per RPC""" + return meter.create_histogram( + name="rpc.client.requests_per_rpc", + description="Measures the number of messages received per RPC.", + unit="{count}", + ) + + +RPC_CLIENT_RESPONSE_SIZE = "rpc.client.response.size" +""" +Measures the size of RPC response messages (uncompressed) +Instrument: histogram +Unit: By +Note: **Streaming**: Recorded per response in a streaming batch. +""" + + +def create_rpc_client_response_size(meter: Meter) -> Histogram: + """Measures the size of RPC response messages (uncompressed)""" + return meter.create_histogram( + name="rpc.client.response.size", + description="Measures the size of RPC response messages (uncompressed).", + unit="By", + ) + + +RPC_CLIENT_RESPONSES_PER_RPC = "rpc.client.responses_per_rpc" +""" +Measures the number of messages sent per RPC +Instrument: histogram +Unit: {count} +Note: Should be 1 for all non-streaming RPCs. + + **Streaming**: This metric is required for server and client streaming RPCs. +""" + + +def create_rpc_client_responses_per_rpc(meter: Meter) -> Histogram: + """Measures the number of messages sent per RPC""" + return meter.create_histogram( + name="rpc.client.responses_per_rpc", + description="Measures the number of messages sent per RPC.", + unit="{count}", + ) + + +RPC_SERVER_DURATION = "rpc.server.duration" +""" +Measures the duration of inbound RPC +Instrument: histogram +Unit: ms +Note: While streaming RPCs may record this metric as start-of-batch + to end-of-batch, it's hard to interpret in practice. + + **Streaming**: N/A. +""" + + +def create_rpc_server_duration(meter: Meter) -> Histogram: + """Measures the duration of inbound RPC""" + return meter.create_histogram( + name="rpc.server.duration", + description="Measures the duration of inbound RPC.", + unit="ms", + ) + + +RPC_SERVER_REQUEST_SIZE = "rpc.server.request.size" +""" +Measures the size of RPC request messages (uncompressed) +Instrument: histogram +Unit: By +Note: **Streaming**: Recorded per message in a streaming batch. +""" + + +def create_rpc_server_request_size(meter: Meter) -> Histogram: + """Measures the size of RPC request messages (uncompressed)""" + return meter.create_histogram( + name="rpc.server.request.size", + description="Measures the size of RPC request messages (uncompressed).", + unit="By", + ) + + +RPC_SERVER_REQUESTS_PER_RPC = "rpc.server.requests_per_rpc" +""" +Measures the number of messages received per RPC +Instrument: histogram +Unit: {count} +Note: Should be 1 for all non-streaming RPCs. + + **Streaming** : This metric is required for server and client streaming RPCs. +""" + + +def create_rpc_server_requests_per_rpc(meter: Meter) -> Histogram: + """Measures the number of messages received per RPC""" + return meter.create_histogram( + name="rpc.server.requests_per_rpc", + description="Measures the number of messages received per RPC.", + unit="{count}", + ) + + +RPC_SERVER_RESPONSE_SIZE = "rpc.server.response.size" +""" +Measures the size of RPC response messages (uncompressed) +Instrument: histogram +Unit: By +Note: **Streaming**: Recorded per response in a streaming batch. +""" + + +def create_rpc_server_response_size(meter: Meter) -> Histogram: + """Measures the size of RPC response messages (uncompressed)""" + return meter.create_histogram( + name="rpc.server.response.size", + description="Measures the size of RPC response messages (uncompressed).", + unit="By", + ) + + +RPC_SERVER_RESPONSES_PER_RPC = "rpc.server.responses_per_rpc" +""" +Measures the number of messages sent per RPC +Instrument: histogram +Unit: {count} +Note: Should be 1 for all non-streaming RPCs. + + **Streaming**: This metric is required for server and client streaming RPCs. +""" + + +def create_rpc_server_responses_per_rpc(meter: Meter) -> Histogram: + """Measures the number of messages sent per RPC""" + return meter.create_histogram( + name="rpc.server.responses_per_rpc", + description="Measures the number of messages sent per RPC.", + unit="{count}", + ) 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 new file mode 100644 index 0000000000..72fb32649c --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/system_metrics.py @@ -0,0 +1,500 @@ +# 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 typing import Callable, Sequence + +from opentelemetry.metrics import ( + Counter, + Meter, + ObservableGauge, + UpDownCounter, +) + +SYSTEM_CPU_FREQUENCY = "system.cpu.frequency" +""" +Reports the current frequency of the CPU in Hz +Instrument: gauge +Unit: {Hz} +""" + + +def create_system_cpu_frequency( + meter: Meter, callback: Sequence[Callable] +) -> ObservableGauge: + """Reports the current frequency of the CPU in Hz""" + return meter.create_observable_gauge( + name="system.cpu.frequency", + callback=callback, + description="Reports the current frequency of the CPU in Hz", + unit="{Hz}", + ) + + +SYSTEM_CPU_LOGICAL_COUNT = "system.cpu.logical.count" +""" +Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking +Instrument: updowncounter +Unit: {cpu} +""" + + +def create_system_cpu_logical_count(meter: Meter) -> UpDownCounter: + """Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking""" + return meter.create_up_down_counter( + name="system.cpu.logical.count", + description="Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking", + unit="{cpu}", + ) + + +SYSTEM_CPU_PHYSICAL_COUNT = "system.cpu.physical.count" +""" +Reports the number of actual physical processor cores on the hardware +Instrument: updowncounter +Unit: {cpu} +""" + + +def create_system_cpu_physical_count(meter: Meter) -> UpDownCounter: + """Reports the number of actual physical processor cores on the hardware""" + return meter.create_up_down_counter( + name="system.cpu.physical.count", + description="Reports the number of actual physical processor cores on the hardware", + unit="{cpu}", + ) + + +SYSTEM_CPU_TIME = "system.cpu.time" +""" +Seconds each logical CPU spent on each mode +Instrument: counter +Unit: s +""" + + +def create_system_cpu_time(meter: Meter) -> Counter: + """Seconds each logical CPU spent on each mode""" + return meter.create_counter( + name="system.cpu.time", + description="Seconds each logical CPU spent on each mode", + unit="s", + ) + + +SYSTEM_CPU_UTILIZATION = "system.cpu.utilization" +""" +Difference in system.cpu.time since the last measurement, divided by the elapsed time and number of logical CPUs +Instrument: gauge +Unit: 1 +""" + + +def create_system_cpu_utilization( + meter: Meter, callback: Sequence[Callable] +) -> ObservableGauge: + """Difference in system.cpu.time since the last measurement, divided by the elapsed time and number of logical CPUs""" + return meter.create_observable_gauge( + name="system.cpu.utilization", + callback=callback, + description="Difference in system.cpu.time since the last measurement, divided by the elapsed time and number of logical CPUs", + unit="1", + ) + + +SYSTEM_DISK_IO = "system.disk.io" +""" +Instrument: counter +Unit: By +""" + + +def create_system_disk_io(meter: Meter) -> Counter: + return meter.create_counter( + name="system.disk.io", + description="", + unit="By", + ) + + +SYSTEM_DISK_IO_TIME = "system.disk.io_time" +""" +Time disk spent activated +Instrument: counter +Unit: s +Note: The real elapsed time ("wall clock") used in the I/O path (time from operations running in parallel are not counted). Measured as: + + - Linux: Field 13 from [procfs-diskstats](https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats) + - Windows: The complement of + ["Disk\\% Idle Time"](https://learn.microsoft.com/archive/blogs/askcore/windows-performance-monitor-disk-counters-explained#windows-performance-monitor-disk-counters-explained) + performance counter: `uptime * (100 - "Disk\\% Idle Time") / 100`. +""" + + +def create_system_disk_io_time(meter: Meter) -> Counter: + """Time disk spent activated""" + return meter.create_counter( + name="system.disk.io_time", + description="Time disk spent activated", + unit="s", + ) + + +SYSTEM_DISK_MERGED = "system.disk.merged" +""" +Instrument: counter +Unit: {operation} +""" + + +def create_system_disk_merged(meter: Meter) -> Counter: + return meter.create_counter( + name="system.disk.merged", + description="", + unit="{operation}", + ) + + +SYSTEM_DISK_OPERATION_TIME = "system.disk.operation_time" +""" +Sum of the time each operation took to complete +Instrument: counter +Unit: s +Note: Because it is the sum of time each request took, parallel-issued requests each contribute to make the count grow. Measured as: + + - Linux: Fields 7 & 11 from [procfs-diskstats](https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats) + - Windows: "Avg. Disk sec/Read" perf counter multiplied by "Disk Reads/sec" perf counter (similar for Writes). +""" + + +def create_system_disk_operation_time(meter: Meter) -> Counter: + """Sum of the time each operation took to complete""" + return meter.create_counter( + name="system.disk.operation_time", + description="Sum of the time each operation took to complete", + unit="s", + ) + + +SYSTEM_DISK_OPERATIONS = "system.disk.operations" +""" +Instrument: counter +Unit: {operation} +""" + + +def create_system_disk_operations(meter: Meter) -> Counter: + return meter.create_counter( + name="system.disk.operations", + description="", + unit="{operation}", + ) + + +SYSTEM_FILESYSTEM_USAGE = "system.filesystem.usage" +""" +Instrument: updowncounter +Unit: By +""" + + +def create_system_filesystem_usage(meter: Meter) -> UpDownCounter: + return meter.create_up_down_counter( + name="system.filesystem.usage", + description="", + unit="By", + ) + + +SYSTEM_FILESYSTEM_UTILIZATION = "system.filesystem.utilization" +""" +Instrument: gauge +Unit: 1 +""" + + +def create_system_filesystem_utilization( + meter: Meter, callback: Sequence[Callable] +) -> ObservableGauge: + return meter.create_observable_gauge( + name="system.filesystem.utilization", + callback=callback, + description="", + unit="1", + ) + + +SYSTEM_LINUX_MEMORY_AVAILABLE = "system.linux.memory.available" +""" +An estimate of how much memory is available for starting new applications, without causing swapping +Instrument: updowncounter +Unit: By +Note: This is an alternative to `system.memory.usage` metric with `state=free`. + Linux starting from 3.14 exports "available" memory. It takes "free" memory as a baseline, and then factors in kernel-specific values. + This is supposed to be more accurate than just "free" memory. + For reference, see the calculations [here](https://superuser.com/a/980821). + See also `MemAvailable` in [/proc/meminfo](https://man7.org/linux/man-pages/man5/proc.5.html). +""" + + +def create_system_linux_memory_available(meter: Meter) -> UpDownCounter: + """An estimate of how much memory is available for starting new applications, without causing swapping""" + return meter.create_up_down_counter( + name="system.linux.memory.available", + description="An estimate of how much memory is available for starting new applications, without causing swapping", + unit="By", + ) + + +SYSTEM_MEMORY_LIMIT = "system.memory.limit" +""" +Total memory available in the system +Instrument: updowncounter +Unit: By +Note: Its value SHOULD equal the sum of `system.memory.state` over all states. +""" + + +def create_system_memory_limit(meter: Meter) -> UpDownCounter: + """Total memory available in the system""" + return meter.create_up_down_counter( + name="system.memory.limit", + description="Total memory available in the system.", + unit="By", + ) + + +SYSTEM_MEMORY_USAGE = "system.memory.usage" +""" +Reports memory in use by state +Instrument: updowncounter +Unit: By +Note: The sum over all `system.memory.state` values SHOULD equal the total memory + available on the system, that is `system.memory.limit`. +""" + + +def create_system_memory_usage(meter: Meter) -> UpDownCounter: + """Reports memory in use by state""" + return meter.create_up_down_counter( + name="system.memory.usage", + description="Reports memory in use by state.", + unit="By", + ) + + +SYSTEM_MEMORY_UTILIZATION = "system.memory.utilization" +""" +Instrument: gauge +Unit: 1 +""" + + +def create_system_memory_utilization( + meter: Meter, callback: Sequence[Callable] +) -> ObservableGauge: + return meter.create_observable_gauge( + name="system.memory.utilization", + callback=callback, + description="", + unit="1", + ) + + +SYSTEM_NETWORK_CONNECTIONS = "system.network.connections" +""" +Instrument: updowncounter +Unit: {connection} +""" + + +def create_system_network_connections(meter: Meter) -> UpDownCounter: + return meter.create_up_down_counter( + name="system.network.connections", + description="", + unit="{connection}", + ) + + +SYSTEM_NETWORK_DROPPED = "system.network.dropped" +""" +Count of packets that are dropped or discarded even though there was no error +Instrument: counter +Unit: {packet} +Note: Measured as: + + - Linux: the `drop` column in `/proc/dev/net` ([source](https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html)) + - Windows: [`InDiscards`/`OutDiscards`](https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2) + from [`GetIfEntry2`](https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2). +""" + + +def create_system_network_dropped(meter: Meter) -> Counter: + """Count of packets that are dropped or discarded even though there was no error""" + return meter.create_counter( + name="system.network.dropped", + description="Count of packets that are dropped or discarded even though there was no error", + unit="{packet}", + ) + + +SYSTEM_NETWORK_ERRORS = "system.network.errors" +""" +Count of network errors detected +Instrument: counter +Unit: {error} +Note: Measured as: + + - Linux: the `errs` column in `/proc/dev/net` ([source](https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html)). + - Windows: [`InErrors`/`OutErrors`](https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2) + from [`GetIfEntry2`](https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2). +""" + + +def create_system_network_errors(meter: Meter) -> Counter: + """Count of network errors detected""" + return meter.create_counter( + name="system.network.errors", + description="Count of network errors detected", + unit="{error}", + ) + + +SYSTEM_NETWORK_IO = "system.network.io" +""" +Instrument: counter +Unit: By +""" + + +def create_system_network_io(meter: Meter) -> Counter: + return meter.create_counter( + name="system.network.io", + description="", + unit="By", + ) + + +SYSTEM_NETWORK_PACKETS = "system.network.packets" +""" +Instrument: counter +Unit: {packet} +""" + + +def create_system_network_packets(meter: Meter) -> Counter: + return meter.create_counter( + name="system.network.packets", + description="", + unit="{packet}", + ) + + +SYSTEM_PAGING_FAULTS = "system.paging.faults" +""" +Instrument: counter +Unit: {fault} +""" + + +def create_system_paging_faults(meter: Meter) -> Counter: + return meter.create_counter( + name="system.paging.faults", + description="", + unit="{fault}", + ) + + +SYSTEM_PAGING_OPERATIONS = "system.paging.operations" +""" +Instrument: counter +Unit: {operation} +""" + + +def create_system_paging_operations(meter: Meter) -> Counter: + return meter.create_counter( + name="system.paging.operations", + description="", + unit="{operation}", + ) + + +SYSTEM_PAGING_USAGE = "system.paging.usage" +""" +Unix swap or windows pagefile usage +Instrument: updowncounter +Unit: By +""" + + +def create_system_paging_usage(meter: Meter) -> UpDownCounter: + """Unix swap or windows pagefile usage""" + return meter.create_up_down_counter( + name="system.paging.usage", + description="Unix swap or windows pagefile usage", + unit="By", + ) + + +SYSTEM_PAGING_UTILIZATION = "system.paging.utilization" +""" +Instrument: gauge +Unit: 1 +""" + + +def create_system_paging_utilization( + meter: Meter, callback: Sequence[Callable] +) -> ObservableGauge: + return meter.create_observable_gauge( + name="system.paging.utilization", + callback=callback, + description="", + unit="1", + ) + + +SYSTEM_PROCESS_COUNT = "system.process.count" +""" +Total number of processes in each state +Instrument: updowncounter +Unit: {process} +""" + + +def create_system_process_count(meter: Meter) -> UpDownCounter: + """Total number of processes in each state""" + return meter.create_up_down_counter( + name="system.process.count", + description="Total number of processes in each state", + unit="{process}", + ) + + +SYSTEM_PROCESS_CREATED = "system.process.created" +""" +Total number of processes created over uptime of the host +Instrument: counter +Unit: {process} +""" + + +def create_system_process_created(meter: Meter) -> Counter: + """Total number of processes created over uptime of the host""" + return meter.create_counter( + name="system.process.created", + description="Total number of processes created over uptime of the host", + unit="{process}", + ) diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/client_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/client_attributes.py new file mode 100644 index 0000000000..77c904c492 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/client_attributes.py @@ -0,0 +1,26 @@ +# 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. + + +CLIENT_ADDRESS = "client.address" +""" +Client address - domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. +Note: When observed from the server side, and when communicating through an intermediary, `client.address` SHOULD represent the client address behind any intermediaries, for example proxies, if it's available. +""" + +CLIENT_PORT = "client.port" +""" +Client port number. +Note: When observed from the server side, and when communicating through an intermediary, `client.port` SHOULD represent the client port behind any intermediaries, for example proxies, if it's available. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/error_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/error_attributes.py new file mode 100644 index 0000000000..43d1bd8944 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/error_attributes.py @@ -0,0 +1,41 @@ +# 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 + +ERROR_TYPE = "error.type" +""" +Describes a class of error the operation ended with. +Note: The `error.type` SHOULD be predictable and SHOULD have low cardinality. + Instrumentations SHOULD document the list of errors they report. + + The cardinality of `error.type` within one instrumentation library SHOULD be low. + Telemetry consumers that aggregate data from multiple instrumentation libraries and applications + should be prepared for `error.type` to have high cardinality at query time when no + additional filters are applied. + + If the operation has completed successfully, instrumentations SHOULD NOT set `error.type`. + + If a specific domain defines its own set of error identifiers (such as HTTP or gRPC status codes), + it's RECOMMENDED to: + + * Use a domain-specific attribute + * Set `error.type` to capture all errors, regardless of whether they are defined within the domain-specific set or not. +""" + + +class ErrorTypeValues(Enum): + OTHER = "_OTHER" + """A fallback error value to be used when the instrumentation doesn't define a custom value.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/exception_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/exception_attributes.py new file mode 100644 index 0000000000..2d6be1e2be --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/exception_attributes.py @@ -0,0 +1,50 @@ +# 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. + + +EXCEPTION_ESCAPED = "exception.escaped" +""" +SHOULD be set to true if the exception event is recorded at a point where it is known that the exception is escaping the scope of the span. +Note: An exception is considered to have escaped (or left) the scope of a span, + if that span is ended while the exception is still logically "in flight". + This may be actually "in flight" in some languages (e.g. if the exception + is passed to a Context manager's `__exit__` method in Python) but will + usually be caught at the point of recording the exception in most languages. + + It is usually not possible to determine at the point where an exception is thrown + 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). + + 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, + since the event might have been recorded at a time where it was not + clear whether the exception will escape. +""" + +EXCEPTION_MESSAGE = "exception.message" +""" +The exception message. +""" + +EXCEPTION_STACKTRACE = "exception.stacktrace" +""" +A stacktrace as a string in the natural representation for the language runtime. The representation is to be determined and documented by each language SIG. +""" + +EXCEPTION_TYPE = "exception.type" +""" +The type of the exception (its fully-qualified class name, if applicable). The dynamic type of the exception should be preferred over the static type in languages that support it. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/http_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/http_attributes.py new file mode 100644 index 0000000000..337dbf06e2 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/http_attributes.py @@ -0,0 +1,97 @@ +# 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 + +HTTP_REQUEST_HEADER_TEMPLATE = "http.request.header" +""" +HTTP request headers, `` being the normalized HTTP Header name (lowercase), the value being the header values. +Note: Instrumentations SHOULD require an explicit configuration of which headers are to be captured. Including all request headers can be a security risk - explicit configuration helps avoid leaking sensitive information. + The `User-Agent` header is already captured in the `user_agent.original` attribute. Users MAY explicitly configure instrumentations to capture them even though it is not recommended. + The attribute value MUST consist of either multiple header values as an array of strings or a single-item array containing a possibly comma-concatenated string, depending on the way the HTTP library provides access to headers. +""" + +HTTP_REQUEST_METHOD = "http.request.method" +""" +HTTP request method. +Note: HTTP request method value SHOULD be "known" to the instrumentation. + By default, this convention defines "known" methods as the ones listed in [RFC9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-methods) + and the PATCH method defined in [RFC5789](https://www.rfc-editor.org/rfc/rfc5789.html). + + If the HTTP request method is not known to instrumentation, it MUST set the `http.request.method` attribute to `_OTHER`. + + If the HTTP instrumentation could end up converting valid HTTP request methods to `_OTHER`, then it MUST provide a way to override + the list of known HTTP methods. If this override is done via environment variable, then the environment variable MUST be named + OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS and support a comma-separated list of case-sensitive known HTTP methods + (this list MUST be a full override of the default known method, it is not a list of known methods in addition to the defaults). + + HTTP method names are case-sensitive and `http.request.method` attribute value MUST match a known HTTP method name exactly. + Instrumentations for specific web frameworks that consider HTTP methods to be case insensitive, SHOULD populate a canonical equivalent. + Tracing instrumentations that do so, MUST also set `http.request.method_original` to the original value. +""" + +HTTP_REQUEST_METHOD_ORIGINAL = "http.request.method_original" +""" +Original HTTP method sent by the client in the request line. +""" + +HTTP_REQUEST_RESEND_COUNT = "http.request.resend_count" +""" +The ordinal number of request resending attempt (for any reason, including redirects). +Note: The resend count SHOULD be updated each time an HTTP request gets resent by the client, regardless of what was the cause of the resending (e.g. redirection, authorization failure, 503 Server Unavailable, network issues, or any other). +""" + +HTTP_RESPONSE_HEADER_TEMPLATE = "http.response.header" +""" +HTTP response headers, `` being the normalized HTTP Header name (lowercase), the value being the header values. +Note: Instrumentations SHOULD require an explicit configuration of which headers are to be captured. Including all response headers can be a security risk - explicit configuration helps avoid leaking sensitive information. + Users MAY explicitly configure instrumentations to capture them even though it is not recommended. + The attribute value MUST consist of either multiple header values as an array of strings or a single-item array containing a possibly comma-concatenated string, depending on the way the HTTP library provides access to headers. +""" + +HTTP_RESPONSE_STATUS_CODE = "http.response.status_code" +""" +[HTTP response status code](https://tools.ietf.org/html/rfc7231#section-6). +""" + +HTTP_ROUTE = "http.route" +""" +The matched route, that is, the path template in the format used by the respective server framework. +Note: MUST NOT be populated when this is not supported by the HTTP server framework as the route attribute should have low-cardinality and the URI path can NOT substitute it. + SHOULD include the [application root](/docs/http/http-spans.md#http-server-definitions) if there is one. +""" + + +class HttpRequestMethodValues(Enum): + CONNECT = "CONNECT" + """CONNECT method.""" + DELETE = "DELETE" + """DELETE method.""" + GET = "GET" + """GET method.""" + HEAD = "HEAD" + """HEAD method.""" + OPTIONS = "OPTIONS" + """OPTIONS method.""" + PATCH = "PATCH" + """PATCH method.""" + POST = "POST" + """POST method.""" + PUT = "PUT" + """PUT method.""" + TRACE = "TRACE" + """TRACE method.""" + OTHER = "_OTHER" + """Any HTTP method that the instrumentation has no prior knowledge of.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/network_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/network_attributes.py new file mode 100644 index 0000000000..fd256ee8a4 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/network_attributes.py @@ -0,0 +1,82 @@ +# 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 + +NETWORK_LOCAL_ADDRESS = "network.local.address" +""" +Local address of the network connection - IP address or Unix domain socket name. +""" + +NETWORK_LOCAL_PORT = "network.local.port" +""" +Local port number of the network connection. +""" + +NETWORK_PEER_ADDRESS = "network.peer.address" +""" +Peer address of the network connection - IP address or Unix domain socket name. +""" + +NETWORK_PEER_PORT = "network.peer.port" +""" +Peer port number of the network connection. +""" + +NETWORK_PROTOCOL_NAME = "network.protocol.name" +""" +[OSI application layer](https://osi-model.com/application-layer/) or non-OSI equivalent. +Note: The value SHOULD be normalized to lowercase. +""" + +NETWORK_PROTOCOL_VERSION = "network.protocol.version" +""" +The actual version of the protocol used for network communication. +Note: If protocol version is subject to negotiation (for example using [ALPN](https://www.rfc-editor.org/rfc/rfc7301.html)), this attribute SHOULD be set to the negotiated version. If the actual protocol version is not known, this attribute SHOULD NOT be set. +""" + +NETWORK_TRANSPORT = "network.transport" +""" +[OSI transport layer](https://osi-model.com/transport-layer/) or [inter-process communication method](https://wikipedia.org/wiki/Inter-process_communication). +Note: The value SHOULD be normalized to lowercase. + + Consider always setting the transport when setting a port number, since + a port number is ambiguous without knowing the transport. For example + different processes could be listening on TCP port 12345 and UDP port 12345. +""" + +NETWORK_TYPE = "network.type" +""" +[OSI network layer](https://osi-model.com/network-layer/) or non-OSI equivalent. +Note: The value SHOULD be normalized to lowercase. +""" + + +class NetworkTransportValues(Enum): + TCP = "tcp" + """TCP.""" + UDP = "udp" + """UDP.""" + PIPE = "pipe" + """Named or anonymous pipe.""" + UNIX = "unix" + """Unix domain socket.""" + + +class NetworkTypeValues(Enum): + IPV4 = "ipv4" + """IPv4.""" + IPV6 = "ipv6" + """IPv6.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/otel_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/otel_attributes.py new file mode 100644 index 0000000000..1ccb108c3e --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/otel_attributes.py @@ -0,0 +1,43 @@ +# 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 + +OTEL_SCOPE_NAME = "otel.scope.name" +""" +The name of the instrumentation scope - (`InstrumentationScope.Name` in OTLP). +""" + +OTEL_SCOPE_VERSION = "otel.scope.version" +""" +The version of the instrumentation scope - (`InstrumentationScope.Version` in OTLP). +""" + +OTEL_STATUS_CODE = "otel.status_code" +""" +Name of the code, either "OK" or "ERROR". MUST NOT be set if the status code is UNSET. +""" + +OTEL_STATUS_DESCRIPTION = "otel.status_description" +""" +Description of the Status if it has a value, otherwise not set. +""" + + +class OtelStatusCodeValues(Enum): + OK = "OK" + """The operation has been validated by an Application developer or Operator to have completed successfully.""" + ERROR = "ERROR" + """The operation contains an error.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/server_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/server_attributes.py new file mode 100644 index 0000000000..1b882a3fd4 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/server_attributes.py @@ -0,0 +1,26 @@ +# 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. + + +SERVER_ADDRESS = "server.address" +""" +Server domain name if available without reverse DNS lookup; otherwise, IP address or Unix domain socket name. +Note: When observed from the client side, and when communicating through an intermediary, `server.address` SHOULD represent the server address behind any intermediaries, for example proxies, if it's available. +""" + +SERVER_PORT = "server.port" +""" +Server port number. +Note: When observed from the client side, and when communicating through an intermediary, `server.port` SHOULD represent the server port behind any intermediaries, for example proxies, if it's available. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/service_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/service_attributes.py new file mode 100644 index 0000000000..4efd06f654 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/service_attributes.py @@ -0,0 +1,25 @@ +# 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. + + +SERVICE_NAME = "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`. +""" + +SERVICE_VERSION = "service.version" +""" +The version string of the service API or implementation. The format is not defined by these conventions. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/telemetry_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/telemetry_attributes.py new file mode 100644 index 0000000000..5909f5d2c4 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/telemetry_attributes.py @@ -0,0 +1,64 @@ +# 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 + +TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language" +""" +The language of the telemetry SDK. +""" + +TELEMETRY_SDK_NAME = "telemetry.sdk.name" +""" +The name of the telemetry SDK as defined above. +Note: The OpenTelemetry SDK MUST set the `telemetry.sdk.name` attribute to `opentelemetry`. + If another SDK, like a fork or a vendor-provided implementation, is used, this SDK MUST set the + `telemetry.sdk.name` attribute to the fully-qualified class or module name of this SDK's main entry point + or another suitable identifier depending on the language. + The identifier `opentelemetry` is reserved and MUST NOT be used in this case. + All custom identifiers SHOULD be stable across different versions of an implementation. +""" + +TELEMETRY_SDK_VERSION = "telemetry.sdk.version" +""" +The version string of the telemetry SDK. +""" + + +class TelemetrySdkLanguageValues(Enum): + CPP = "cpp" + """cpp.""" + DOTNET = "dotnet" + """dotnet.""" + ERLANG = "erlang" + """erlang.""" + GO = "go" + """go.""" + JAVA = "java" + """java.""" + NODEJS = "nodejs" + """nodejs.""" + PHP = "php" + """php.""" + PYTHON = "python" + """python.""" + RUBY = "ruby" + """ruby.""" + RUST = "rust" + """rust.""" + SWIFT = "swift" + """swift.""" + WEBJS = "webjs" + """webjs.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/url_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/url_attributes.py new file mode 100644 index 0000000000..feacc0746f --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/url_attributes.py @@ -0,0 +1,44 @@ +# 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. + + +URL_FRAGMENT = "url.fragment" +""" +The [URI fragment](https://www.rfc-editor.org/rfc/rfc3986#section-3.5) component. +""" + +URL_FULL = "url.full" +""" +Absolute URL describing a network resource according to [RFC3986](https://www.rfc-editor.org/rfc/rfc3986). +Note: For network calls, URL usually has `scheme://host[:port][path][?query][#fragment]` format, where the fragment is not transmitted over HTTP, but if it is known, it SHOULD be included nevertheless. + `url.full` MUST NOT contain credentials passed via URL in form of `https://username:password@www.example.com/`. In such case username and password SHOULD be redacted and attribute's value SHOULD be `https://REDACTED:REDACTED@www.example.com/`. + `url.full` SHOULD capture the absolute URL when it is available (or can be reconstructed). Sensitive content provided in `url.full` SHOULD be scrubbed when instrumentations can identify it. +""" + +URL_PATH = "url.path" +""" +The [URI path](https://www.rfc-editor.org/rfc/rfc3986#section-3.3) component. +Note: Sensitive content provided in `url.path` SHOULD be scrubbed when instrumentations can identify it. +""" + +URL_QUERY = "url.query" +""" +The [URI query](https://www.rfc-editor.org/rfc/rfc3986#section-3.4) component. +Note: Sensitive content provided in `url.query` SHOULD be scrubbed when instrumentations can identify it. +""" + +URL_SCHEME = "url.scheme" +""" +The [URI scheme](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) component identifying the used protocol. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/user_agent_attributes.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/user_agent_attributes.py new file mode 100644 index 0000000000..41ea48eeea --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes/user_agent_attributes.py @@ -0,0 +1,19 @@ +# 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. + + +USER_AGENT_ORIGINAL = "user_agent.original" +""" +Value of the [HTTP User-Agent](https://www.rfc-editor.org/rfc/rfc9110.html#field.user-agent) header sent by the client. +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/__init__.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/__init__.py index 9cd7cee94f..3dca9c209e 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/__init__.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/__init__.py @@ -12,7 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +from deprecated import deprecated + +@deprecated( + "1.25.0", + reason="Use metrics defined in the :py:const:`opentelemetry.semconv.metrics` and :py:const:`opentelemetry.semconv._incubating.metrics` modules instead.", +) class MetricInstruments: SCHEMA_URL = "https://opentelemetry.io/schemas/v1.21.0" """ diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/http_metrics.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/http_metrics.py new file mode 100644 index 0000000000..9006c83959 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/http_metrics.py @@ -0,0 +1,29 @@ +# 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. + + +HTTP_CLIENT_REQUEST_DURATION = "http.client.request.duration" +""" +Duration of HTTP client requests +Instrument: histogram +Unit: s +""" + + +HTTP_SERVER_REQUEST_DURATION = "http.server.request.duration" +""" +Duration of HTTP server requests +Instrument: histogram +Unit: s +""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/__init__.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/__init__.py index 590135934c..47428b7ff4 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/__init__.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/__init__.py @@ -16,7 +16,13 @@ from enum import Enum +from deprecated import deprecated + +@deprecated( + "1.25.0", + reason="Use attributes defined in the :py:const:`opentelemetry.semconv.attributes` and :py:const:`opentelemetry.semconv._incubating.attributes` modules instead.", +) class ResourceAttributes: SCHEMA_URL = "https://opentelemetry.io/schemas/v1.21.0" """ @@ -650,6 +656,10 @@ class ResourceAttributes: """ +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv._incubating.attributes.CloudProviderValues` instead.", +) class CloudProviderValues(Enum): ALIBABA_CLOUD = "alibaba_cloud" """Alibaba Cloud.""" @@ -673,6 +683,10 @@ class CloudProviderValues(Enum): """Tencent Cloud.""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv._incubating.attributes.CloudPlatformValues` instead.", +) class CloudPlatformValues(Enum): ALIBABA_CLOUD_ECS = "alibaba_cloud_ecs" """Alibaba Cloud Elastic Compute Service.""" @@ -756,6 +770,10 @@ class CloudPlatformValues(Enum): """Tencent Cloud Serverless Cloud Function (SCF).""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv._incubating.attributes.AwsEcsLaunchtypeValues` instead.", +) class AwsEcsLaunchtypeValues(Enum): EC2 = "ec2" """ec2.""" @@ -764,6 +782,10 @@ class AwsEcsLaunchtypeValues(Enum): """fargate.""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv._incubating.attributes.HostArchValues` instead.", +) class HostArchValues(Enum): AMD64 = "amd64" """AMD64.""" @@ -790,6 +812,10 @@ class HostArchValues(Enum): """32-bit x86.""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv._incubating.attributes.OsTypeValues` instead.", +) class OsTypeValues(Enum): WINDOWS = "windows" """Microsoft Windows.""" @@ -825,6 +851,10 @@ class OsTypeValues(Enum): """IBM z/OS.""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv.attributes.TelemetrySdkLanguageValues` instead.", +) class TelemetrySdkLanguageValues(Enum): CPP = "cpp" """cpp.""" diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/schemas.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/schemas.py new file mode 100644 index 0000000000..b409960774 --- /dev/null +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/schemas.py @@ -0,0 +1,30 @@ +# 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 + + +class Schemas(Enum): + V1_23_1 = "https://opentelemetry.io/schemas/1.23.1" + """ + The URL of the OpenTelemetry schema version 1.23.1. + """ + + V1_25_0 = "https://opentelemetry.io/schemas/v1.25.0" + """ + The URL of the OpenTelemetry schema version v1.25.0. + """ + + # when generating new semantic conventions, + # make sure to add new versions version here. diff --git a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/__init__.py b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/__init__.py index 48df586dc1..3057e0a374 100644 --- a/opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/__init__.py +++ b/opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/__init__.py @@ -19,6 +19,10 @@ from deprecated import deprecated +@deprecated( + "1.25.0", + reason="Use attributes defined in the :py:const:`opentelemetry.semconv.attributes` and :py:const:`opentelemetry.semconv._incubating.attributes` modules instead.", +) class SpanAttributes: SCHEMA_URL = "https://opentelemetry.io/schemas/v1.21.0" """ @@ -1519,6 +1523,10 @@ class NetHostConnectionSubtypeValues(Enum): """LTE CA.""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv.attributes.NetworkTransportValues` instead.", +) class NetTransportValues(Enum): IP_TCP = "ip_tcp" """ip_tcp.""" @@ -1536,6 +1544,10 @@ class NetTransportValues(Enum): """Something else (non IP-based).""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv.attributes.NetworkType` instead.", +) class NetSockFamilyValues(Enum): INET = "inet" """IPv4 address.""" @@ -1547,6 +1559,10 @@ class NetSockFamilyValues(Enum): """Unix domain socket path.""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv.attributes.HttpRequestMethodValues` instead.", +) class HttpRequestMethodValues(Enum): CONNECT = "CONNECT" """CONNECT method.""" @@ -1579,6 +1595,7 @@ class HttpRequestMethodValues(Enum): """Any HTTP method that the instrumentation has no prior knowledge of.""" +@deprecated("1.25.0", reason="Removed from the specification.") class EventDomainValues(Enum): BROWSER = "browser" """Events from browser apps.""" @@ -1590,6 +1607,10 @@ class EventDomainValues(Enum): """Events from Kubernetes.""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv._incubating.attributes.LogIostreamValues` instead.", +) class LogIostreamValues(Enum): STDOUT = "stdout" """Logs from stdout stream.""" @@ -1598,6 +1619,7 @@ class LogIostreamValues(Enum): """Events from stderr stream.""" +@deprecated("1.25.0", reason="Removed from the specification.") class TypeValues(Enum): HEAP = "heap" """Heap memory.""" @@ -1606,6 +1628,10 @@ class TypeValues(Enum): """Non-heap memory.""" +@deprecated( + "1.25.0", + reason="Use :py:const:`opentelemetry.semconv._incubating.attributes.OpentracingRefTypeValues` instead.", +) class OpentracingRefTypeValues(Enum): CHILD_OF = "child_of" """The parent Span depends on the child Span in some capacity.""" diff --git a/opentelemetry-semantic-conventions/test-requirements.txt b/opentelemetry-semantic-conventions/test-requirements.txt index 84629406b0..31353edec3 100644 --- a/opentelemetry-semantic-conventions/test-requirements.txt +++ b/opentelemetry-semantic-conventions/test-requirements.txt @@ -14,4 +14,5 @@ tomli==2.0.1 typing_extensions==4.10.0 wrapt==1.16.0 zipp==3.17.0 +-e opentelemetry-api -e opentelemetry-semantic-conventions diff --git a/scripts/semconv/generate.sh b/scripts/semconv/generate.sh index d4cf9a3393..57ae537bfe 100755 --- a/scripts/semconv/generate.sh +++ b/scripts/semconv/generate.sh @@ -5,10 +5,9 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ROOT_DIR="${SCRIPT_DIR}/../../" # freeze the spec version to make SemanticAttributes generation reproducible -SPEC_VERSION=v1.21.0 -SCHEMA_URL=https://opentelemetry.io/schemas/$SPEC_VERSION -OTEL_SEMCONV_GEN_IMG_VERSION=0.21.0 - +SEMCONV_VERSION=v1.25.0 +OTEL_SEMCONV_GEN_IMG_VERSION=0.24.0 +INCUBATING_DIR=_incubating cd ${SCRIPT_DIR} rm -rf semantic-conventions || true @@ -17,44 +16,55 @@ cd semantic-conventions git init git remote add origin https://github.com/open-telemetry/semantic-conventions.git -git fetch origin "$SPEC_VERSION" +git fetch origin "$SEMCONV_VERSION" git reset --hard FETCH_HEAD cd ${SCRIPT_DIR} -docker run --rm \ - -v ${SCRIPT_DIR}/semantic-conventions/model:/source \ - -v ${SCRIPT_DIR}/templates:/templates \ - -v ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv/trace/:/output \ - otel/semconvgen:$OTEL_SEMCONV_GEN_IMG_VERSION \ - --only span,event,attribute_group \ - -f /source code \ - --template /templates/semantic_attributes.j2 \ - --output /output/__init__.py \ - -Dclass=SpanAttributes \ - -DschemaUrl=$SCHEMA_URL - -docker run --rm \ - -v ${SCRIPT_DIR}/semantic-conventions/model:/source \ - -v ${SCRIPT_DIR}/templates:/templates \ - -v ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv/resource/:/output \ - otel/semconvgen:$OTEL_SEMCONV_GEN_IMG_VERSION \ - --only resource \ - -f /source code \ - --template /templates/semantic_attributes.j2 \ - --output /output/__init__.py \ - -Dclass=ResourceAttributes \ - -DschemaUrl=$SCHEMA_URL - -docker run --rm \ - -v ${SCRIPT_DIR}/semantic-conventions/model:/source \ - -v ${SCRIPT_DIR}/templates:/templates \ - -v ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics/:/output \ - otel/semconvgen:$OTEL_SEMCONV_GEN_IMG_VERSION \ - --only metric \ - -f /source code \ - --template /templates/semantic_metrics.j2 \ - --output /output/__init__.py \ - -Dclass=MetricInstruments \ - -DschemaUrl=$SCHEMA_URL +# Check new schema version was added to schemas.py manually +SCHEMAS_PY_PATH=${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv/schemas.py + +if ! grep -q $SEMCONV_VERSION "$SCHEMAS_PY_PATH"; then + echo "Error: schema version $SEMCONV_VERSION is not found in $SCHEMAS_PY_PATH. Please add it manually." + exit 1 +fi + +EXCLUDED_NAMESPACES="jvm aspnetcore dotnet signalr ios android" + +generate() { + TEMPLATE=$1 + OUTPUT_FILE=$2 + FILTER=$3 + STABLE_PACKAGE=$4 + docker run --rm \ + -v ${SCRIPT_DIR}/semantic-conventions/model:/source \ + -v ${SCRIPT_DIR}/templates:/templates \ + -v ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv/:/output \ + otel/semconvgen:$OTEL_SEMCONV_GEN_IMG_VERSION \ + -f /source \ + --continue-on-validation-errors \ + code \ + --template /templates/${TEMPLATE} \ + --output /output/${OUTPUT_FILE} \ + --file-per-group root_namespace \ + -Dfilter=${FILTER} \ + -Dstable_package=${STABLE_PACKAGE} \ + -Dexcluded_namespaces="$EXCLUDED_NAMESPACES" +} + +# stable attributes and metrics +mkdir -p ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv/attributes +generate "semantic_attributes.j2" "attributes/{{snake_prefix}}_attributes.py" "is_stable" "" + +mkdir -p ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv/metrics +generate "semantic_metrics.j2" "metrics/{{snake_prefix}}_metrics.py" "is_stable" "" + +# all attributes and metrics +mkdir -p ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv/$INCUBATING_DIR/attributes +generate "semantic_attributes.j2" "$INCUBATING_DIR/attributes/{{snake_prefix}}_attributes.py" "any" "opentelemetry.semconv.attributes" + +mkdir -p ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv/$INCUBATING_DIR/metrics +generate "semantic_metrics.j2" "$INCUBATING_DIR/metrics/{{snake_prefix}}_metrics.py" "any" "opentelemetry.semconv.metrics" cd "$ROOT_DIR" +${ROOT_DIR}/.tox/lint/bin/black --config pyproject.toml ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv +${ROOT_DIR}/.tox/lint/bin/isort ${ROOT_DIR}/opentelemetry-semantic-conventions/src/opentelemetry/semconv diff --git a/scripts/semconv/templates/common.j2 b/scripts/semconv/templates/common.j2 new file mode 100644 index 0000000000..8a1231f6e6 --- /dev/null +++ b/scripts/semconv/templates/common.j2 @@ -0,0 +1,26 @@ +{%- macro file_header() -%} +# 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. + +{% endmacro -%} + +{%- macro to_docstring(str) -%} +{{ str | to_doc_brief | replace("\\", "\\\\") }} +{%- endmacro -%} + +{%- macro import_deprecated(semconv) -%} + {%- if (semconv | select("is_deprecated") | list | count > 0) or (filter == "any" and semconv | select("is_stable") | list | count > 0) %} +from deprecated import deprecated + {%- endif %} +{%- endmacro-%} diff --git a/scripts/semconv/templates/semantic_attributes.j2 b/scripts/semconv/templates/semantic_attributes.j2 index 7e48d74768..11908009ba 100644 --- a/scripts/semconv/templates/semantic_attributes.j2 +++ b/scripts/semconv/templates/semantic_attributes.j2 @@ -1,5 +1,5 @@ +{# # 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 @@ -11,360 +11,79 @@ # 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. +#} -# pylint: disable=too-many-lines +{%- import 'common.j2' as common -%} -{%- macro print_value(type, value) -%} - {{ "\"" if type == "string"}}{{value}}{{ "\"" if type == "string"}} +{%- macro stable_class_ref(const_name, separator) -%} +{{stable_package}}.{{root_namespace}}_attributes{{separator}}{{const_name}} {%- endmacro %} -from enum import Enum -{%- if class == "SpanAttributes" %} - -from deprecated import deprecated - -{%- endif %} - - -class {{class}}: - SCHEMA_URL = "{{schemaUrl}}" - """ - The URL of the OpenTelemetry schema for these keys and values. - """ - {%- for attribute in attributes | unique(attribute="fqn") %} - {{attribute.fqn | to_const_name}} = "{{attribute.fqn}}" - """ - {{attribute.brief | to_doc_brief}}. - - {%- if attribute.note %} - Note: {{attribute.note | to_doc_brief | indent}}. +{%- macro attribute_name(attribute) -%} + {%- if attribute | is_template -%} + {{attribute.fqn | to_const_name}}_TEMPLATE + {%- else -%} + {{attribute.fqn | to_const_name}} + {%- endif -%} +{%- endmacro -%} + +{%- macro attribute_brief(attribute) -%} +""" + {%- if attribute | is_deprecated %} +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), '.')}}`. + {%- else %} +{{ common.to_docstring(attribute.brief) }}. + {%- if attribute.note %} +Note: {{ common.to_docstring(attribute.note | indent)}}. + {%- endif -%} {%- endif %} +""" +{%- endmacro -%} - {%- if attribute.deprecated %} - Deprecated: {{attribute.deprecated | to_doc_brief}}. - {%- endif %} - """ -{# Extra line #} - {%- endfor %} - - {%- if class == "SpanAttributes" %} - # Manually defined deprecated attributes - {# - Deprecated attributes and types are defined here for backward compatibility reasons. - They were removed from OpenTelemetry semantic conventions completely. - - Attributes that were deprecated in OpenTelemetry semantic conventions - (https://github.com/open-telemetry/semantic-conventions/tree/main/model/deprecated) - are auto-generated with comments indicating deprecated status, so they don't need - to be manually defined. - #} - - NET_PEER_IP = "net.peer.ip" - """ - Deprecated, use the `client.socket.address` attribute. - """ - - NET_HOST_IP = "net.host.ip" - """ - Deprecated, use the `server.socket.address` attribute. - """ - - HTTP_SERVER_NAME = "http.server_name" - """ - Deprecated, use the `server.address` attribute. - """ - - HTTP_HOST = "http.host" - """ - Deprecated, use the `server.address` and `server.port` attributes. - """ - - HTTP_RETRY_COUNT = "http.retry_count" - """ - Deprecated, use the `http.resend_count` attribute. - """ - - HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED = ( - "http.request_content_length_uncompressed" - ) - """ - Deprecated, use the `http.request.body.size` attribute. - """ - - HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED = ( - "http.response_content_length_uncompressed" - ) - """ - Deprecated, use the `http.response.body.size` attribute. - """ - - MESSAGING_DESTINATION = "messaging.destination" - """ - Deprecated, use the `messaging.destination.name` attribute. - """ - - MESSAGING_DESTINATION_KIND = "messaging.destination_kind" - """ - Deprecated. - """ - - MESSAGING_TEMP_DESTINATION = "messaging.temp_destination" - """ - Deprecated. Use `messaging.destination.temporary` attribute. - """ - - MESSAGING_PROTOCOL = "messaging.protocol" - """ - Deprecated. Use `network.protocol.name` attribute. - """ - - MESSAGING_PROTOCOL_VERSION = "messaging.protocol_version" - """ - Deprecated. Use `network.protocol.version` attribute. - """ - - MESSAGING_URL = "messaging.url" - """ - Deprecated. Use `server.address` and `server.port` attributes. - """ - - MESSAGING_CONVERSATION_ID = "messaging.conversation_id" - """ - Deprecated. Use `messaging.message.conversation.id` attribute. - """ - - MESSAGING_KAFKA_PARTITION = "messaging.kafka.partition" - """ - Deprecated. Use `messaging.kafka.destination.partition` attribute. - """ - - FAAS_EXECUTION = "faas.execution" - """ - Deprecated. Use `faas.invocation_id` attribute. - """ - - HTTP_USER_AGENT = "http.user_agent" - """ - Deprecated. Use `user_agent.original` attribute. - """ - - MESSAGING_RABBITMQ_ROUTING_KEY = "messaging.rabbitmq.routing_key" - """ - Deprecated. Use `messaging.rabbitmq.destination.routing_key` attribute. - """ - - MESSAGING_KAFKA_TOMBSTONE = "messaging.kafka.tombstone" - """ - Deprecated. Use `messaging.kafka.destination.tombstone` attribute. - """ - - NET_APP_PROTOCOL_NAME = "net.app.protocol.name" - """ - Deprecated. Use `network.protocol.name` attribute. - """ - - NET_APP_PROTOCOL_VERSION = "net.app.protocol.version" - """ - Deprecated. Use `network.protocol.version` attribute. - """ - - HTTP_CLIENT_IP = "http.client_ip" - """ - Deprecated. Use `client.address` attribute. - """ - - HTTP_FLAVOR = "http.flavor" - """ - Deprecated. Use `network.protocol.name` and `network.protocol.version` attributes. - """ - - NET_HOST_CONNECTION_TYPE = "net.host.connection.type" - """ - Deprecated. Use `network.connection.type` attribute. - """ - - NET_HOST_CONNECTION_SUBTYPE = "net.host.connection.subtype" - """ - Deprecated. Use `network.connection.subtype` attribute. - """ - - NET_HOST_CARRIER_NAME = "net.host.carrier.name" - """ - Deprecated. Use `network.carrier.name` attribute. - """ - - NET_HOST_CARRIER_MCC = "net.host.carrier.mcc" - """ - Deprecated. Use `network.carrier.mcc` attribute. - """ - - NET_HOST_CARRIER_MNC = "net.host.carrier.mnc" - """ - Deprecated. Use `network.carrier.mnc` attribute. - """ - - MESSAGING_CONSUMER_ID = "messaging.consumer_id" - """ - Deprecated. Use `messaging.client_id` attribute. - """ +{%- if root_namespace not in excluded_namespaces -%} +{%- if filter != 'any' -%} +{%- set filtered_attributes = attributes_and_templates | select(filter) | list -%} +{%- else -%} +{%- set filtered_attributes = attributes_and_templates | list %} +{%- endif -%} +{%- if filtered_attributes | count > 0 -%} - MESSAGING_KAFKA_CLIENT_ID = "messaging.kafka.client_id" - """ - Deprecated. Use `messaging.client_id` attribute. - """ +{{ common.file_header()}} - MESSAGING_ROCKETMQ_CLIENT_ID = "messaging.rocketmq.client_id" - """ - Deprecated. Use `messaging.client_id` attribute. - """ +{%- if filter != 'any' -%} +{%- set filtered_enum_attributes = enum_attributes | select(filter) | list %} +{%- else -%} +{%- set filtered_enum_attributes = enum_attributes | list %} +{%- endif -%} -@deprecated( - version="1.18.0", - reason="Removed from the specification in favor of `network.protocol.name` and `network.protocol.version` attributes", -) -class HttpFlavorValues(Enum): - HTTP_1_0 = "1.0" +{{common.import_deprecated(filtered_enum_attributes)}} - HTTP_1_1 = "1.1" +{% if filtered_enum_attributes | count > 0 %} - HTTP_2_0 = "2.0" - - HTTP_3_0 = "3.0" - - SPDY = "SPDY" - - QUIC = "QUIC" - -@deprecated( - version="1.18.0", - reason="Removed from the specification", -) -class MessagingDestinationKindValues(Enum): - QUEUE = "queue" - """A message sent to a queue.""" - - TOPIC = "topic" - """A message sent to a topic.""" - - -@deprecated( - version="1.21.0", - reason="Renamed to NetworkConnectionTypeValues", -) -class NetHostConnectionTypeValues(Enum): - WIFI = "wifi" - """wifi.""" - - WIRED = "wired" - """wired.""" - - CELL = "cell" - """cell.""" - - UNAVAILABLE = "unavailable" - """unavailable.""" - - UNKNOWN = "unknown" - """unknown.""" - - -@deprecated( - version="1.21.0", - reason="Renamed to NetworkConnectionSubtypeValues", -) -class NetHostConnectionSubtypeValues(Enum): - GPRS = "gprs" - """GPRS.""" - - EDGE = "edge" - """EDGE.""" - - UMTS = "umts" - """UMTS.""" - - CDMA = "cdma" - """CDMA.""" - - EVDO_0 = "evdo_0" - """EVDO Rel. 0.""" - - EVDO_A = "evdo_a" - """EVDO Rev. A.""" - - CDMA2000_1XRTT = "cdma2000_1xrtt" - """CDMA2000 1XRTT.""" - - HSDPA = "hsdpa" - """HSDPA.""" - - HSUPA = "hsupa" - """HSUPA.""" - - HSPA = "hspa" - """HSPA.""" - - IDEN = "iden" - """IDEN.""" - - EVDO_B = "evdo_b" - """EVDO Rev. B.""" - - LTE = "lte" - """LTE.""" - - EHRPD = "ehrpd" - """EHRPD.""" - - HSPAP = "hspap" - """HSPAP.""" - - GSM = "gsm" - """GSM.""" - - TD_SCDMA = "td_scdma" - """TD-SCDMA.""" - - IWLAN = "iwlan" - """IWLAN.""" - - NR = "nr" - """5G NR (New Radio).""" - - NRNSA = "nrnsa" - """5G NRNSA (New Radio Non-Standalone).""" - - LTE_CA = "lte_ca" - """LTE CA.""" - - {% endif %} - - {%- if class == "ResourceAttributes" %} - # Manually defined deprecated attributes - {# - Deprecated attributes and types are defined here for backward compatibility reasons. - They were removed from OpenTelemetry semantic conventions completely. - - Attributes that were deprecated in OpenTelemetry semantic conventions - (https://github.com/open-telemetry/semantic-conventions/tree/main/model/deprecated) - are auto-generated with comments indicating deprecated status, so they don't need - to be manually defined. - #} +from enum import Enum - FAAS_ID = "faas.id" - """ - Deprecated, use the `cloud.resource.id` attribute. - """ - {% endif %} +{% else %} -{%- for attribute in attributes | unique(attribute="fqn") %} -{%- if attribute.is_enum %} -{%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" %} -{%- set type = attribute.attr_type.enum_type %} +{% endif %} +{% for attribute in filtered_attributes -%} +{{attribute_name(attribute)}} = "{{attribute.fqn}}" +{{attribute_brief(attribute)}} + +{% endfor %} +{%- for attribute in filtered_enum_attributes -%} +{%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" -%} + {%- if attribute | is_deprecated %} +@deprecated(reason="The attribute {{attribute.fqn}} is deprecated - {{ common.to_docstring(attribute.deprecated) }}") + {%- elif attribute | is_stable and filter == "any" %} +@deprecated(reason="Deprecated in favor of stable :py:const:`{{stable_class_ref(class_name, '.')}}`.") + {%- endif %} class {{class_name}}(Enum): {%- for member in attribute.attr_type.members %} - {{ member.member_id | to_const_name }} = {{ print_value(type, member.value) }} - """{% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %}""" -{# Extra line #} + {{ member.member_id | to_const_name }} = {{ attribute | print_member_value(member) }} + """{{ common.to_docstring(member.brief) }}.""" {%- endfor %} -{% endif %} -{%- endfor %} +{%- endfor -%} +{%- endif -%} +{%- endif -%} diff --git a/scripts/semconv/templates/semantic_metrics.j2 b/scripts/semconv/templates/semantic_metrics.j2 index 4fa1260cb5..fed0e02c8f 100644 --- a/scripts/semconv/templates/semantic_metrics.j2 +++ b/scripts/semconv/templates/semantic_metrics.j2 @@ -1,5 +1,5 @@ +{# # 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 @@ -11,30 +11,118 @@ # 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. +#} + +{%- import 'common.j2' as common -%} + +{%- macro to_python_instrument_factory(instrument) -%} + {%- if instrument == "counter" -%} + counter + {%- elif instrument == "histogram" -%} + histogram + {%- elif instrument == "updowncounter" -%} + up_down_counter + {%- elif instrument == "gauge" -%} + observable_gauge + {%- endif -%} +{%- endmacro %} +{%- macro to_python_instrument_type(instrument) -%} + {%- if instrument == "counter" -%} + Counter + {%- elif instrument == "histogram" -%} + Histogram + {%- elif instrument == "updowncounter" -%} + UpDownCounter + {%- elif instrument == "gauge" -%} + ObservableGauge + {%- endif -%} +{%- endmacro %} + +{%- macro stable_class_ref(const_name, separator) -%} +{{stable_package}}.{{root_namespace}}_metrics{{separator}}{{const_name}} +{%- endmacro %} + +{%- macro metric_brief(metric, const_name) -%} +""" + {%- if metric | is_deprecated %} +Deprecated: {{ common.to_docstring(metric.deprecated)}}. + {%- elif metric | is_stable and filter == "any" %} +Deprecated in favor of stable :py:const:`{{stable_class_ref(const_name, '.')}}`. + {%- else -%} + {%- set brief = common.to_docstring(metric.brief) -%} + {%- if brief != "" %} +{{brief}} + {%- endif %} +Instrument: {{ metric.instrument }} +Unit: {{ metric.unit }} + {%- if metric.note %} +Note: {{ common.to_docstring(metric.note | indent) }}. + {%- endif -%} + {%- endif %} +""" +{%- endmacro -%} + +{%- macro import_instrument_classes(metrics) -%} + {% if filter == "any" %} +from opentelemetry.metrics import Meter + + {%- if metrics | selectattr("instrument", "equalto", "gauge") | list | count > 0 %} +from typing import Callable, Sequence +from opentelemetry.metrics import ObservableGauge + {%- endif %} + + {%- if metrics | selectattr("instrument", "equalto", "histogram") | list | count > 0 %} +from opentelemetry.metrics import Histogram + {%- endif %} + + {%- if metrics | selectattr("instrument", "equalto", "updowncounter") | list | count > 0 %} +from opentelemetry.metrics import UpDownCounter + {%- endif %} + + {%- if metrics | selectattr("instrument", "equalto", "counter") | list | count > 0 %} +from opentelemetry.metrics import Counter + {%- endif %} + {%- endif -%} +{%- endmacro-%} + +{%- if root_namespace not in excluded_namespaces -%} + {%- if filter != 'any' -%} +{%- set filtered_metrics = metrics | select(filter) | list -%} + {%- else -%} +{%- set filtered_metrics = metrics -%} + {%- endif -%} + + {%- if filtered_metrics | count > 0 -%} + +{{ common.file_header()}} + +{{ import_instrument_classes(filtered_metrics) }} + + {%- for metric in filtered_metrics %} + +{{metric.metric_name | to_const_name}} = "{{metric.metric_name}}" +{{metric_brief(metric, metric.metric_name | to_const_name) }} -class {{class}}: - SCHEMA_URL = "{{schemaUrl}}" - """ - The URL of the OpenTelemetry schema for these keys and values. - """ - {% for id in semconvs %}{%- if semconvs[id].GROUP_TYPE_NAME == 'metric' %}{% set metric = semconvs[id] %} - {{metric.metric_name | to_const_name}} = "{{metric.metric_name}}" - """ - {{metric.brief | to_doc_brief}} - Instrument: {{ metric.instrument }} - Unit: {{ metric.unit }} - """ -{# Extra line #} - {%- endif %}{% endfor %} - - # Manually defined metrics - {# - Metrics defined here manually were not yaml-ified in 1.21.0 release - and therefore are not auto-generated. - #} - DB_CLIENT_CONNECTIONS_USAGE = "db.client.connections.usage" - """ - The number of connections that are currently in state described by the `state` attribute - Instrument: UpDownCounter - Unit: {connection} - """ \ No newline at end of file + {% if filter == "any" %} + {% set metric_name = metric.metric_name | replace(".", "_") %} + {%- if metric.instrument == "gauge" %} +def create_{{ metric_name }}(meter: Meter, callback: Sequence[Callable]) -> {{to_python_instrument_type(metric.instrument)}}: + {%- else %} +def create_{{ metric_name }}(meter: Meter) -> {{to_python_instrument_type(metric.instrument)}}: + {%- endif %} + {%- set brief = common.to_docstring(metric.brief) -%} + {%- if brief != "" %} + """{{brief}}""" + {%- endif %} + return meter.create_{{to_python_instrument_factory(metric.instrument)}}( + name="{{ metric.metric_name }}", + {%- if metric.instrument == "gauge" %} + callback=callback, + {%- endif %} + description="{{ metric.brief }}", + unit="{{ metric.unit }}", + ) + {%- endif -%} + {%- endfor -%} + {%- endif -%} +{%- endif -%}