From 09480544c8f1d595f228ee7d58cf2884485010d3 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 21 Jul 2022 19:57:34 +0200 Subject: [PATCH] Add automatically semantic conventions from the spec (#873) (#1497) --- CHANGELOG.md | 1 + RELEASING.md | 11 +- .../trace/experimental_semantic_conventions.h | 2 + .../trace/semantic_conventions.h | 1328 +++++++++++++++++ buildscripts/semantic-convention/.gitignore | 1 + buildscripts/semantic-convention/generate.sh | 57 + .../templates/SemanticAttributes.h.j2 | 120 ++ docs/semantic-conventions.md | 76 + examples/grpc/client.cc | 17 +- examples/grpc/server.cc | 17 +- examples/http/client.cc | 10 +- examples/http/server.cc | 14 +- exporters/jaeger/src/recordable.cc | 2 +- .../otlp/test/otlp_log_recordable_test.cc | 11 +- exporters/zipkin/src/recordable.cc | 6 +- .../experimental_semantic_conventions.h | 4 +- .../sdk/resource/semantic_conventions.h | 793 ++++++++++ sdk/src/resource/resource.cc | 21 +- sdk/test/resource/resource_test.cc | 26 +- 19 files changed, 2445 insertions(+), 72 deletions(-) create mode 100644 api/include/opentelemetry/trace/semantic_conventions.h create mode 100644 buildscripts/semantic-convention/.gitignore create mode 100755 buildscripts/semantic-convention/generate.sh create mode 100644 buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 create mode 100644 docs/semantic-conventions.md create mode 100644 sdk/include/opentelemetry/sdk/resource/semantic_conventions.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 60ab34e4c2..1a71aa5d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Increment the: * [EXPORTER] OTLP http exporter allow concurrency session ([#1209](https://github.com/open-telemetry/opentelemetry-cpp/pull/1209)) * [EXT] `curl::HttpClient` use `curl_multi_handle` instead of creating a thread for every request and it's able to reuse connections now. ([#1317](https://github.com/open-telemetry/opentelemetry-cpp/pull/1317)) +* [SEMANTIC CONVENTIONS] Upgrade to version 1.12.0 [#873](https://github.com/open-telemetry/opentelemetry-cpp/pull/873) ## [1.4.1] 2022-06-19 diff --git a/RELEASING.md b/RELEASING.md index 2725298a7f..8246e8fe44 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -2,24 +2,27 @@ ## Pre Release -1: Make sure all relevant changes for this release are included under +1: Upgrade to latest [semantic-conventions](docs/semantic-conventions.md) +if required. + +2: Make sure all relevant changes for this release are included under `Unreleased` section in `CHANGELOG.md` and are in language that non-contributors to the project can understand. -2: Run the pre-release script. It creates a branch `pre_release_` and +3: Run the pre-release script. It creates a branch `pre_release_` and updates `CHANGELOG.md` with the ``: ```sh ./buildscripts/pre_release.sh -t ``` -3: Verify that CHANGELOG.md is updated properly: +4: Verify that CHANGELOG.md is updated properly: ```sh git diff main ``` -4: Push the changes to upstream and create a Pull Request on GitHub. Be sure to +5: Push the changes to upstream and create a Pull Request on GitHub. Be sure to include the curated changes from the [Changelog](./CHANGELOG.md) in the description. diff --git a/api/include/opentelemetry/trace/experimental_semantic_conventions.h b/api/include/opentelemetry/trace/experimental_semantic_conventions.h index dd320e20d9..a3eed553f2 100644 --- a/api/include/opentelemetry/trace/experimental_semantic_conventions.h +++ b/api/include/opentelemetry/trace/experimental_semantic_conventions.h @@ -7,6 +7,8 @@ // https://github.com/open-telemetry/opentelemetry-specification/tree/v1.0.0/specification/trace/semantic_conventions // and MAY will change in future. +// "This file is deprecated. Use opentelemetry/trace/semantic_conventions.h" + #pragma once #include "opentelemetry/common/string_util.h" diff --git a/api/include/opentelemetry/trace/semantic_conventions.h b/api/include/opentelemetry/trace/semantic_conventions.h new file mode 100644 index 0000000000..2334ced67b --- /dev/null +++ b/api/include/opentelemetry/trace/semantic_conventions.h @@ -0,0 +1,1328 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + DO NOT EDIT, this is an Auto-generated file + from buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 +*/ + +#pragma once + +#include "opentelemetry/version.h" +/* + * Special considerations for FaasDocumentOperationValues::DELETE. + * + * The winnt.h header file is known to define a DELETE symbol, + * which collides with FaasDocumentOperationValues::DELETE. + */ +#ifdef _WIN32 +# ifdef DELETE +# pragma message(__FILE__ ": removing define on DELETE") +# undef DELETE +# endif +#endif + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace trace +{ + +namespace SemanticConventions +{ +/** + * The URL of the OpenTelemetry schema for these keys and values. + */ +static constexpr const char *SCHEMA_URL = "https://opentelemetry.io/schemas/1.12.0"; + +/** + * The full invoked ARN as provided on the {@code Context} passed to the function ({@code + Lambda-Runtime-Invoked-Function-Arn} header on the {@code /runtime/invocation/next} applicable). + * + *

Notes: +

  • This may be different from {@code faas.id} if an alias is involved.
+ */ +static constexpr const char *AWS_LAMBDA_INVOKED_ARN = "aws.lambda.invoked_arn"; + +/** + * The event_id + * uniquely identifies the event. + */ +static constexpr const char *CLOUDEVENTS_EVENT_ID = "cloudevents.event_id"; + +/** + * The source + * identifies the context in which an event happened. + */ +static constexpr const char *CLOUDEVENTS_EVENT_SOURCE = "cloudevents.event_source"; + +/** + * The version of + * the CloudEvents specification which the event uses. + */ +static constexpr const char *CLOUDEVENTS_EVENT_SPEC_VERSION = "cloudevents.event_spec_version"; + +/** + * The event_type + * contains a value describing the type of event related to the originating occurrence. + */ +static constexpr const char *CLOUDEVENTS_EVENT_TYPE = "cloudevents.event_type"; + +/** + * The subject of + * the event in the context of the event producer (identified by source). + */ +static constexpr const char *CLOUDEVENTS_EVENT_SUBJECT = "cloudevents.event_subject"; + +/** + * Parent-child Reference type + * + *

Notes: +

  • The causal relationship between a child Span and a parent Span.
+ */ +static constexpr const char *OPENTRACING_REF_TYPE = "opentracing.ref_type"; + +/** + * An identifier for the database management system (DBMS) product being used. See below for a list + * of well-known identifiers. + */ +static constexpr const char *DB_SYSTEM = "db.system"; + +/** + * The connection string used to connect to the database. It is recommended to remove embedded + * credentials. + */ +static constexpr const char *DB_CONNECTION_STRING = "db.connection_string"; + +/** + * Username for accessing the database. + */ +static constexpr const char *DB_USER = "db.user"; + +/** + * The fully-qualified class name of the Java Database Connectivity + * (JDBC) driver used to connect. + */ +static constexpr const char *DB_JDBC_DRIVER_CLASSNAME = "db.jdbc.driver_classname"; + +/** + * 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). + * + *

Notes: +

  • 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).
+ */ +static constexpr const char *DB_NAME = "db.name"; + +/** + * The database statement being executed. + * + *

Notes: +

  • The value may be sanitized to exclude sensitive information.
+ */ +static constexpr const char *DB_STATEMENT = "db.statement"; + +/** + * The name of the operation being executed, e.g. the MongoDB command + name such as {@code findAndModify}, or the SQL keyword. + * + *

Notes: +

  • When setting this to an SQL keyword, it is not recommended to attempt any client-side + parsing of {@code 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.
+ */ +static constexpr const char *DB_OPERATION = "db.operation"; + +/** + * The Microsoft SQL Server instance + name connecting to. This name is used to determine the port of a named instance. + * + *

Notes: +

  • If setting a {@code db.mssql.instance_name}, {@code net.peer.port} is no longer required + (but still recommended if non-standard).
+ */ +static constexpr const char *DB_MSSQL_INSTANCE_NAME = "db.mssql.instance_name"; + +/** + * The fetch size used for paging, i.e. how many rows will be returned at once. + */ +static constexpr const char *DB_CASSANDRA_PAGE_SIZE = "db.cassandra.page_size"; + +/** + * The consistency level of the query. Based on consistency values from CQL. + */ +static constexpr const char *DB_CASSANDRA_CONSISTENCY_LEVEL = "db.cassandra.consistency_level"; + +/** + * The name of the primary table that the operation is acting upon, including the keyspace name (if + applicable). + * + *

Notes: +

  • This mirrors the db.sql.table attribute but references cassandra rather than sql. It is + not recommended to attempt any client-side parsing of {@code 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.
+ */ +static constexpr const char *DB_CASSANDRA_TABLE = "db.cassandra.table"; + +/** + * Whether or not the query is idempotent. + */ +static constexpr const char *DB_CASSANDRA_IDEMPOTENCE = "db.cassandra.idempotence"; + +/** + * The number of times a query was speculatively executed. Not set or {@code 0} if the query was not + * executed speculatively. + */ +static constexpr const char *DB_CASSANDRA_SPECULATIVE_EXECUTION_COUNT = + "db.cassandra.speculative_execution_count"; + +/** + * The ID of the coordinating node for a query. + */ +static constexpr const char *DB_CASSANDRA_COORDINATOR_ID = "db.cassandra.coordinator.id"; + +/** + * The data center of the coordinating node for a query. + */ +static constexpr const char *DB_CASSANDRA_COORDINATOR_DC = "db.cassandra.coordinator.dc"; + +/** + * The index of the database being accessed as used in the {@code SELECT} command, provided as an integer. To be + * used instead of the generic {@code db.name} attribute. + */ +static constexpr const char *DB_REDIS_DATABASE_INDEX = "db.redis.database_index"; + +/** + * The collection being accessed within the database stated in {@code db.name}. + */ +static constexpr const char *DB_MONGODB_COLLECTION = "db.mongodb.collection"; + +/** + * The name of the primary table that the operation is acting upon, including the database name (if + applicable). + * + *

Notes: +

  • It is not recommended to attempt any client-side parsing of {@code 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.
+ */ +static constexpr const char *DB_SQL_TABLE = "db.sql.table"; + +/** + * 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. + */ +static constexpr const char *EXCEPTION_TYPE = "exception.type"; + +/** + * The exception message. + */ +static constexpr const char *EXCEPTION_MESSAGE = "exception.message"; + +/** + * 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. + */ +static constexpr const char *EXCEPTION_STACKTRACE = "exception.stacktrace"; + +/** + * 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. + * + *

Notes: +

  • 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 {@code __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 +above.
  • It follows that an exception may still escape the scope of the span even if the +{@code 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.
+ */ +static constexpr const char *EXCEPTION_ESCAPED = "exception.escaped"; + +/** + * Type of the trigger which caused this function execution. + * + *

Notes: +

  • For the server/consumer span on the incoming side, +{@code faas.trigger} MUST be set.
  • Clients invoking FaaS instances usually cannot set {@code +faas.trigger}, since they would typically need to look in the payload to determine the event type. +If clients set it, it should be the same as the trigger that corresponding incoming would have +(i.e., this has nothing to do with the underlying transport used to make the API call to invoke the +lambda, which is often HTTP).
+ */ +static constexpr const char *FAAS_TRIGGER = "faas.trigger"; + +/** + * The execution ID of the current function execution. + */ +static constexpr const char *FAAS_EXECUTION = "faas.execution"; + +/** + * 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. + */ +static constexpr const char *FAAS_DOCUMENT_COLLECTION = "faas.document.collection"; + +/** + * Describes the type of the operation that was performed on the data. + */ +static constexpr const char *FAAS_DOCUMENT_OPERATION = "faas.document.operation"; + +/** + * A string containing the time when the data was accessed in the ISO 8601 format expressed in UTC. + */ +static constexpr const char *FAAS_DOCUMENT_TIME = "faas.document.time"; + +/** + * 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. + */ +static constexpr const char *FAAS_DOCUMENT_NAME = "faas.document.name"; + +/** + * A string containing the function invocation time in the ISO 8601 format expressed in UTC. + */ +static constexpr const char *FAAS_TIME = "faas.time"; + +/** + * A string containing the schedule period as Cron + * Expression. + */ +static constexpr const char *FAAS_CRON = "faas.cron"; + +/** + * A boolean that is true if the serverless function is executed for the first time (aka + * cold-start). + */ +static constexpr const char *FAAS_COLDSTART = "faas.coldstart"; + +/** + * The name of the invoked function. + * + *

Notes: +

  • SHOULD be equal to the {@code faas.name} resource attribute of the invoked function.
  • +
+ */ +static constexpr const char *FAAS_INVOKED_NAME = "faas.invoked_name"; + +/** + * The cloud provider of the invoked function. + * + *

Notes: +

  • SHOULD be equal to the {@code cloud.provider} resource attribute of the invoked + function.
+ */ +static constexpr const char *FAAS_INVOKED_PROVIDER = "faas.invoked_provider"; + +/** + * The cloud region of the invoked function. + * + *

Notes: +

  • SHOULD be equal to the {@code cloud.region} resource attribute of the invoked + function.
+ */ +static constexpr const char *FAAS_INVOKED_REGION = "faas.invoked_region"; + +/** + * Transport protocol used. See note below. + */ +static constexpr const char *NET_TRANSPORT = "net.transport"; + +/** + * Remote address of the peer (dotted decimal for IPv4 or RFC5952 for IPv6) + */ +static constexpr const char *NET_PEER_IP = "net.peer.ip"; + +/** + * Remote port number. + */ +static constexpr const char *NET_PEER_PORT = "net.peer.port"; + +/** + * Remote hostname or similar, see note below. + * + *

Notes: +

  • {@code net.peer.name} SHOULD NOT be set if capturing it would require an extra DNS + lookup.
+ */ +static constexpr const char *NET_PEER_NAME = "net.peer.name"; + +/** + * Like {@code net.peer.ip} but for the host IP. Useful in case of a multi-IP host. + */ +static constexpr const char *NET_HOST_IP = "net.host.ip"; + +/** + * Like {@code net.peer.port} but for the host port. + */ +static constexpr const char *NET_HOST_PORT = "net.host.port"; + +/** + * Local hostname or similar, see note below. + */ +static constexpr const char *NET_HOST_NAME = "net.host.name"; + +/** + * The internet connection type currently being used by the host. + */ +static constexpr const char *NET_HOST_CONNECTION_TYPE = "net.host.connection.type"; + +/** + * 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. + */ +static constexpr const char *NET_HOST_CONNECTION_SUBTYPE = "net.host.connection.subtype"; + +/** + * The name of the mobile carrier. + */ +static constexpr const char *NET_HOST_CARRIER_NAME = "net.host.carrier.name"; + +/** + * The mobile carrier country code. + */ +static constexpr const char *NET_HOST_CARRIER_MCC = "net.host.carrier.mcc"; + +/** + * The mobile carrier network code. + */ +static constexpr const char *NET_HOST_CARRIER_MNC = "net.host.carrier.mnc"; + +/** + * The ISO 3166-1 alpha-2 2-character country code associated with the mobile carrier network. + */ +static constexpr const char *NET_HOST_CARRIER_ICC = "net.host.carrier.icc"; + +/** + * The {@code service.name} of + * the remote service. SHOULD be equal to the actual {@code service.name} resource attribute of the + * remote service if any. + */ +static constexpr const char *PEER_SERVICE = "peer.service"; + +/** + * Username or client_id extracted from the access token or Authorization header in the inbound + * request from outside the system. + */ +static constexpr const char *ENDUSER_ID = "enduser.id"; + +/** + * Actual/assumed role the client is making the request under extracted from token or application + * security context. + */ +static constexpr const char *ENDUSER_ROLE = "enduser.role"; + +/** + * 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 or an attribute + * value in a SAML 2.0 + * Assertion. + */ +static constexpr const char *ENDUSER_SCOPE = "enduser.scope"; + +/** + * Current "managed" thread ID (as opposed to OS thread ID). + */ +static constexpr const char *THREAD_ID = "thread.id"; + +/** + * Current thread name. + */ +static constexpr const char *THREAD_NAME = "thread.name"; + +/** + * The method or function name, or equivalent (usually rightmost part of the code unit's name). + */ +static constexpr const char *CODE_FUNCTION = "code.function"; + +/** + * The "namespace" within which {@code code.function} is defined. Usually the qualified + * class or module name, such that {@code code.namespace} + some separator + {@code code.function} + * form a unique identifier for the code unit. + */ +static constexpr const char *CODE_NAMESPACE = "code.namespace"; + +/** + * The source code file name that identifies the code unit as uniquely as possible (preferably an + * absolute file path). + */ +static constexpr const char *CODE_FILEPATH = "code.filepath"; + +/** + * The line number in {@code code.filepath} best representing the operation. It SHOULD point within + * the code unit named in {@code code.function}. + */ +static constexpr const char *CODE_LINENO = "code.lineno"; + +/** + * HTTP request method. + */ +static constexpr const char *HTTP_METHOD = "http.method"; + +/** + * Full HTTP request URL in the form {@code scheme://host[:port]/path?query[#fragment]}. Usually the + fragment is not transmitted over HTTP, but if it is known, it should be included nevertheless. + * + *

Notes: +

  • {@code http.url} MUST NOT contain credentials passed via URL in form of {@code + https://username:password@www.example.com/}. In such case the attribute's value should be {@code + https://www.example.com/}.
+ */ +static constexpr const char *HTTP_URL = "http.url"; + +/** + * The full request target as passed in a HTTP request line or equivalent. + */ +static constexpr const char *HTTP_TARGET = "http.target"; + +/** + * The value of the HTTP host header. + An empty Host header should also be reported, see note. + * + *

Notes: +

  • When the header is present but empty the attribute SHOULD be set to the empty string. + Note that this is a valid situation that is expected in certain cases, according the aforementioned + section of RFC 7230. When the header + is not set the attribute MUST NOT be set.
+ */ +static constexpr const char *HTTP_HOST = "http.host"; + +/** + * The URI scheme identifying the used protocol. + */ +static constexpr const char *HTTP_SCHEME = "http.scheme"; + +/** + * HTTP response status code. + */ +static constexpr const char *HTTP_STATUS_CODE = "http.status_code"; + +/** + * Kind of HTTP protocol used. + * + *

Notes: +

  • If {@code net.transport} is not specified, it can be assumed to be {@code IP.TCP} except + if {@code http.flavor} is {@code QUIC}, in which case {@code IP.UDP} is assumed.
+ */ +static constexpr const char *HTTP_FLAVOR = "http.flavor"; + +/** + * Value of the HTTP User-Agent + * header sent by the client. + */ +static constexpr const char *HTTP_USER_AGENT = "http.user_agent"; + +/** + * 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 header. For requests + * using transport encoding, this should be the compressed size. + */ +static constexpr const char *HTTP_REQUEST_CONTENT_LENGTH = "http.request_content_length"; + +/** + * The size of the uncompressed request payload body after transport decoding. Not set if transport + * encoding not used. + */ +static constexpr const char *HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED = + "http.request_content_length_uncompressed"; + +/** + * 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 header. For requests + * using transport encoding, this should be the compressed size. + */ +static constexpr const char *HTTP_RESPONSE_CONTENT_LENGTH = "http.response_content_length"; + +/** + * The size of the uncompressed response payload body after transport decoding. Not set if transport + * encoding not used. + */ +static constexpr const char *HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED = + "http.response_content_length_uncompressed"; + +/** + * The ordinal number of request re-sending attempt. + */ +static constexpr const char *HTTP_RETRY_COUNT = "http.retry_count"; + +/** + * The primary server name of the matched virtual host. This should be obtained via configuration. + If no such configuration can be obtained, this attribute MUST NOT be set ( {@code net.host.name} + should be used instead). + * + *

Notes: +

  • {@code http.url} is usually not readily available on the server side but would have to be + assembled in a cumbersome and sometimes lossy process from other information (see e.g. + open-telemetry/opentelemetry-python/pull/148). It is thus preferred to supply the raw data that is + available.
+ */ +static constexpr const char *HTTP_SERVER_NAME = "http.server_name"; + +/** + * The matched route (path template). + */ +static constexpr const char *HTTP_ROUTE = "http.route"; + +/** + * The IP address of the original client behind all proxies, if known (e.g. from X-Forwarded-For). + * + *

Notes: +

  • This is not necessarily the same as {@code net.peer.ip}, which would +identify the network-level peer, which may be a proxy.
  • This attribute should be set when a +source of information different from the one used for {@code net.peer.ip}, is available even if that +other source just confirms the same value as {@code net.peer.ip}. Rationale: For {@code +net.peer.ip}, one typically does not know if it comes from a proxy, reverse proxy, or the actual +client. Setting +{@code http.client_ip} when it's the same as {@code net.peer.ip} means that +one is at least somewhat confident that the address is not that of +the closest proxy.
+ */ +static constexpr const char *HTTP_CLIENT_IP = "http.client_ip"; + +/** + * The keys in the {@code RequestItems} object field. + */ +static constexpr const char *AWS_DYNAMODB_TABLE_NAMES = "aws.dynamodb.table_names"; + +/** + * The JSON-serialized value of each item in the {@code ConsumedCapacity} response field. + */ +static constexpr const char *AWS_DYNAMODB_CONSUMED_CAPACITY = "aws.dynamodb.consumed_capacity"; + +/** + * The JSON-serialized value of the {@code ItemCollectionMetrics} response field. + */ +static constexpr const char *AWS_DYNAMODB_ITEM_COLLECTION_METRICS = + "aws.dynamodb.item_collection_metrics"; + +/** + * The value of the {@code ProvisionedThroughput.ReadCapacityUnits} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_PROVISIONED_READ_CAPACITY = + "aws.dynamodb.provisioned_read_capacity"; + +/** + * The value of the {@code ProvisionedThroughput.WriteCapacityUnits} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_PROVISIONED_WRITE_CAPACITY = + "aws.dynamodb.provisioned_write_capacity"; + +/** + * The value of the {@code ConsistentRead} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_CONSISTENT_READ = "aws.dynamodb.consistent_read"; + +/** + * The value of the {@code ProjectionExpression} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_PROJECTION = "aws.dynamodb.projection"; + +/** + * The value of the {@code Limit} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_LIMIT = "aws.dynamodb.limit"; + +/** + * The value of the {@code AttributesToGet} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_ATTRIBUTES_TO_GET = "aws.dynamodb.attributes_to_get"; + +/** + * The value of the {@code IndexName} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_INDEX_NAME = "aws.dynamodb.index_name"; + +/** + * The value of the {@code Select} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_SELECT = "aws.dynamodb.select"; + +/** + * The JSON-serialized value of each item of the {@code GlobalSecondaryIndexes} request field + */ +static constexpr const char *AWS_DYNAMODB_GLOBAL_SECONDARY_INDEXES = + "aws.dynamodb.global_secondary_indexes"; + +/** + * The JSON-serialized value of each item of the {@code LocalSecondaryIndexes} request field. + */ +static constexpr const char *AWS_DYNAMODB_LOCAL_SECONDARY_INDEXES = + "aws.dynamodb.local_secondary_indexes"; + +/** + * The value of the {@code ExclusiveStartTableName} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_EXCLUSIVE_START_TABLE = + "aws.dynamodb.exclusive_start_table"; + +/** + * The the number of items in the {@code TableNames} response parameter. + */ +static constexpr const char *AWS_DYNAMODB_TABLE_COUNT = "aws.dynamodb.table_count"; + +/** + * The value of the {@code ScanIndexForward} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_SCAN_FORWARD = "aws.dynamodb.scan_forward"; + +/** + * The value of the {@code Segment} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_SEGMENT = "aws.dynamodb.segment"; + +/** + * The value of the {@code TotalSegments} request parameter. + */ +static constexpr const char *AWS_DYNAMODB_TOTAL_SEGMENTS = "aws.dynamodb.total_segments"; + +/** + * The value of the {@code Count} response parameter. + */ +static constexpr const char *AWS_DYNAMODB_COUNT = "aws.dynamodb.count"; + +/** + * The value of the {@code ScannedCount} response parameter. + */ +static constexpr const char *AWS_DYNAMODB_SCANNED_COUNT = "aws.dynamodb.scanned_count"; + +/** + * The JSON-serialized value of each item in the {@code AttributeDefinitions} request field. + */ +static constexpr const char *AWS_DYNAMODB_ATTRIBUTE_DEFINITIONS = + "aws.dynamodb.attribute_definitions"; + +/** + * The JSON-serialized value of each item in the the {@code GlobalSecondaryIndexUpdates} request + * field. + */ +static constexpr const char *AWS_DYNAMODB_GLOBAL_SECONDARY_INDEX_UPDATES = + "aws.dynamodb.global_secondary_index_updates"; + +/** + * A string identifying the messaging system. + */ +static constexpr const char *MESSAGING_SYSTEM = "messaging.system"; + +/** + * The message destination name. This might be equal to the span name but is required nevertheless. + */ +static constexpr const char *MESSAGING_DESTINATION = "messaging.destination"; + +/** + * The kind of message destination + */ +static constexpr const char *MESSAGING_DESTINATION_KIND = "messaging.destination_kind"; + +/** + * A boolean that is true if the message destination is temporary. + */ +static constexpr const char *MESSAGING_TEMP_DESTINATION = "messaging.temp_destination"; + +/** + * The name of the transport protocol. + */ +static constexpr const char *MESSAGING_PROTOCOL = "messaging.protocol"; + +/** + * The version of the transport protocol. + */ +static constexpr const char *MESSAGING_PROTOCOL_VERSION = "messaging.protocol_version"; + +/** + * Connection string. + */ +static constexpr const char *MESSAGING_URL = "messaging.url"; + +/** + * A value used by the messaging system as an identifier for the message, represented as a string. + */ +static constexpr const char *MESSAGING_MESSAGE_ID = "messaging.message_id"; + +/** + * The conversation ID identifying the conversation to which the + * message belongs, represented as a string. Sometimes called "Correlation ID". + */ +static constexpr const char *MESSAGING_CONVERSATION_ID = "messaging.conversation_id"; + +/** + * The (uncompressed) size of the message payload in bytes. Also use this attribute if it is unknown + * whether the compressed or uncompressed payload size is reported. + */ +static constexpr const char *MESSAGING_MESSAGE_PAYLOAD_SIZE_BYTES = + "messaging.message_payload_size_bytes"; + +/** + * The compressed size of the message payload in bytes. + */ +static constexpr const char *MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES = + "messaging.message_payload_compressed_size_bytes"; + +/** + * A string identifying the kind of message consumption as defined in the Operation names section above. If the operation is "send", + * this attribute MUST NOT be set, since the operation can be inferred from the span kind in that + * case. + */ +static constexpr const char *MESSAGING_OPERATION = "messaging.operation"; + +/** + * The identifier for the consumer receiving a message. For Kafka, set it to {@code + * {messaging.kafka.consumer_group} - {messaging.kafka.client_id}}, if both are present, or only + * {@code messaging.kafka.consumer_group}. For brokers, such as RabbitMQ and Artemis, set it to the + * {@code client_id} of the client consuming the message. + */ +static constexpr const char *MESSAGING_CONSUMER_ID = "messaging.consumer_id"; + +/** + * RabbitMQ message routing key. + */ +static constexpr const char *MESSAGING_RABBITMQ_ROUTING_KEY = "messaging.rabbitmq.routing_key"; + +/** + * Message keys in Kafka are used for grouping alike messages to ensure they're processed on the + same partition. They differ from {@code messaging.message_id} in that they're not unique. If the + key is {@code null}, the attribute MUST NOT be set. + * + *

Notes: +

  • 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.
  • +
+ */ +static constexpr const char *MESSAGING_KAFKA_MESSAGE_KEY = "messaging.kafka.message_key"; + +/** + * Name of the Kafka Consumer Group that is handling the message. Only applies to consumers, not + * producers. + */ +static constexpr const char *MESSAGING_KAFKA_CONSUMER_GROUP = "messaging.kafka.consumer_group"; + +/** + * Client Id for the Consumer or Producer that is handling the message. + */ +static constexpr const char *MESSAGING_KAFKA_CLIENT_ID = "messaging.kafka.client_id"; + +/** + * Partition the message is sent to. + */ +static constexpr const char *MESSAGING_KAFKA_PARTITION = "messaging.kafka.partition"; + +/** + * A boolean that is true if the message is a tombstone. + */ +static constexpr const char *MESSAGING_KAFKA_TOMBSTONE = "messaging.kafka.tombstone"; + +/** + * Namespace of RocketMQ resources, resources in different namespaces are individual. + */ +static constexpr const char *MESSAGING_ROCKETMQ_NAMESPACE = "messaging.rocketmq.namespace"; + +/** + * Name of the RocketMQ producer/consumer group that is handling the message. The client type is + * identified by the SpanKind. + */ +static constexpr const char *MESSAGING_ROCKETMQ_CLIENT_GROUP = "messaging.rocketmq.client_group"; + +/** + * The unique identifier for each client. + */ +static constexpr const char *MESSAGING_ROCKETMQ_CLIENT_ID = "messaging.rocketmq.client_id"; + +/** + * Type of message. + */ +static constexpr const char *MESSAGING_ROCKETMQ_MESSAGE_TYPE = "messaging.rocketmq.message_type"; + +/** + * The secondary classifier of message besides topic. + */ +static constexpr const char *MESSAGING_ROCKETMQ_MESSAGE_TAG = "messaging.rocketmq.message_tag"; + +/** + * Key(s) of message, another way to mark message besides message id. + */ +static constexpr const char *MESSAGING_ROCKETMQ_MESSAGE_KEYS = "messaging.rocketmq.message_keys"; + +/** + * Model of message consumption. This only applies to consumer spans. + */ +static constexpr const char *MESSAGING_ROCKETMQ_CONSUMPTION_MODEL = + "messaging.rocketmq.consumption_model"; + +/** + * A string identifying the remoting system. See below for a list of well-known identifiers. + */ +static constexpr const char *RPC_SYSTEM = "rpc.system"; + +/** + * The full (logical) name of the service being called, including its package name, if applicable. + * + *

Notes: +

  • 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 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).
+ */ +static constexpr const char *RPC_SERVICE = "rpc.service"; + +/** + * The name of the (logical) method being called, must be equal to the $method part in the span + name. + * + *

Notes: +

  • 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 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).
+ */ +static constexpr const char *RPC_METHOD = "rpc.method"; + +/** + * The numeric status + * code of the gRPC request. + */ +static constexpr const char *RPC_GRPC_STATUS_CODE = "rpc.grpc.status_code"; + +/** + * Protocol version as in {@code jsonrpc} property of request/response. Since JSON-RPC 1.0 does not + * specify this, the value can be omitted. + */ +static constexpr const char *RPC_JSONRPC_VERSION = "rpc.jsonrpc.version"; + +/** + * {@code id} property of request or response. Since protocol allows id to be int, string, {@code + * null} or missing (for notifications), value is expected to be cast to string for simplicity. Use + * empty string in case of {@code null} value. Omit entirely if this is a notification. + */ +static constexpr const char *RPC_JSONRPC_REQUEST_ID = "rpc.jsonrpc.request_id"; + +/** + * {@code error.code} property of response if it is an error response. + */ +static constexpr const char *RPC_JSONRPC_ERROR_CODE = "rpc.jsonrpc.error_code"; + +/** + * {@code error.message} property of response if it is an error response. + */ +static constexpr const char *RPC_JSONRPC_ERROR_MESSAGE = "rpc.jsonrpc.error_message"; + +/** + * Whether this is a received or sent message. + */ +static constexpr const char *MESSAGE_TYPE = "message.type"; + +/** + * MUST be calculated as two different counters starting from {@code 1} one for sent messages and + one for received message. + * + *

Notes: +

  • This way we guarantee that the values will be consistent between different + implementations.
+ */ +static constexpr const char *MESSAGE_ID = "message.id"; + +/** + * Compressed size of the message in bytes. + */ +static constexpr const char *MESSAGE_COMPRESSED_SIZE = "message.compressed_size"; + +/** + * Uncompressed size of the message in bytes. + */ +static constexpr const char *MESSAGE_UNCOMPRESSED_SIZE = "message.uncompressed_size"; + +// Enum definitions +namespace OpentracingRefTypeValues +{ +/** The parent Span depends on the child Span in some capacity. */ +static constexpr const char *CHILD_OF = "child_of"; +/** The parent Span does not depend in any way on the result of the child Span. */ +static constexpr const char *FOLLOWS_FROM = "follows_from"; +} // namespace OpentracingRefTypeValues + +namespace DbSystemValues +{ +/** Some other SQL database. Fallback only. See notes. */ +static constexpr const char *OTHER_SQL = "other_sql"; +/** Microsoft SQL Server. */ +static constexpr const char *MSSQL = "mssql"; +/** MySQL. */ +static constexpr const char *MYSQL = "mysql"; +/** Oracle Database. */ +static constexpr const char *ORACLE = "oracle"; +/** IBM Db2. */ +static constexpr const char *DB2 = "db2"; +/** PostgreSQL. */ +static constexpr const char *POSTGRESQL = "postgresql"; +/** Amazon Redshift. */ +static constexpr const char *REDSHIFT = "redshift"; +/** Apache Hive. */ +static constexpr const char *HIVE = "hive"; +/** Cloudscape. */ +static constexpr const char *CLOUDSCAPE = "cloudscape"; +/** HyperSQL DataBase. */ +static constexpr const char *HSQLDB = "hsqldb"; +/** Progress Database. */ +static constexpr const char *PROGRESS = "progress"; +/** SAP MaxDB. */ +static constexpr const char *MAXDB = "maxdb"; +/** SAP HANA. */ +static constexpr const char *HANADB = "hanadb"; +/** Ingres. */ +static constexpr const char *INGRES = "ingres"; +/** FirstSQL. */ +static constexpr const char *FIRSTSQL = "firstsql"; +/** EnterpriseDB. */ +static constexpr const char *EDB = "edb"; +/** InterSystems Caché. */ +static constexpr const char *CACHE = "cache"; +/** Adabas (Adaptable Database System). */ +static constexpr const char *ADABAS = "adabas"; +/** Firebird. */ +static constexpr const char *FIREBIRD = "firebird"; +/** Apache Derby. */ +static constexpr const char *DERBY = "derby"; +/** FileMaker. */ +static constexpr const char *FILEMAKER = "filemaker"; +/** Informix. */ +static constexpr const char *INFORMIX = "informix"; +/** InstantDB. */ +static constexpr const char *INSTANTDB = "instantdb"; +/** InterBase. */ +static constexpr const char *INTERBASE = "interbase"; +/** MariaDB. */ +static constexpr const char *MARIADB = "mariadb"; +/** Netezza. */ +static constexpr const char *NETEZZA = "netezza"; +/** Pervasive PSQL. */ +static constexpr const char *PERVASIVE = "pervasive"; +/** PointBase. */ +static constexpr const char *POINTBASE = "pointbase"; +/** SQLite. */ +static constexpr const char *SQLITE = "sqlite"; +/** Sybase. */ +static constexpr const char *SYBASE = "sybase"; +/** Teradata. */ +static constexpr const char *TERADATA = "teradata"; +/** Vertica. */ +static constexpr const char *VERTICA = "vertica"; +/** H2. */ +static constexpr const char *H2 = "h2"; +/** ColdFusion IMQ. */ +static constexpr const char *COLDFUSION = "coldfusion"; +/** Apache Cassandra. */ +static constexpr const char *CASSANDRA = "cassandra"; +/** Apache HBase. */ +static constexpr const char *HBASE = "hbase"; +/** MongoDB. */ +static constexpr const char *MONGODB = "mongodb"; +/** Redis. */ +static constexpr const char *REDIS = "redis"; +/** Couchbase. */ +static constexpr const char *COUCHBASE = "couchbase"; +/** CouchDB. */ +static constexpr const char *COUCHDB = "couchdb"; +/** Microsoft Azure Cosmos DB. */ +static constexpr const char *COSMOSDB = "cosmosdb"; +/** Amazon DynamoDB. */ +static constexpr const char *DYNAMODB = "dynamodb"; +/** Neo4j. */ +static constexpr const char *NEO4J = "neo4j"; +/** Apache Geode. */ +static constexpr const char *GEODE = "geode"; +/** Elasticsearch. */ +static constexpr const char *ELASTICSEARCH = "elasticsearch"; +/** Memcached. */ +static constexpr const char *MEMCACHED = "memcached"; +/** CockroachDB. */ +static constexpr const char *COCKROACHDB = "cockroachdb"; +} // namespace DbSystemValues + +namespace DbCassandraConsistencyLevelValues +{ +/** all. */ +static constexpr const char *ALL = "all"; +/** each_quorum. */ +static constexpr const char *EACH_QUORUM = "each_quorum"; +/** quorum. */ +static constexpr const char *QUORUM = "quorum"; +/** local_quorum. */ +static constexpr const char *LOCAL_QUORUM = "local_quorum"; +/** one. */ +static constexpr const char *ONE = "one"; +/** two. */ +static constexpr const char *TWO = "two"; +/** three. */ +static constexpr const char *THREE = "three"; +/** local_one. */ +static constexpr const char *LOCAL_ONE = "local_one"; +/** any. */ +static constexpr const char *ANY = "any"; +/** serial. */ +static constexpr const char *SERIAL = "serial"; +/** local_serial. */ +static constexpr const char *LOCAL_SERIAL = "local_serial"; +} // namespace DbCassandraConsistencyLevelValues + +namespace FaasTriggerValues +{ +/** A response to some data source operation such as a database or filesystem read/write. */ +static constexpr const char *DATASOURCE = "datasource"; +/** To provide an answer to an inbound HTTP request. */ +static constexpr const char *HTTP = "http"; +/** A function is set to be executed when messages are sent to a messaging system. */ +static constexpr const char *PUBSUB = "pubsub"; +/** A function is scheduled to be executed regularly. */ +static constexpr const char *TIMER = "timer"; +/** If none of the others apply. */ +static constexpr const char *OTHER = "other"; +} // namespace FaasTriggerValues + +namespace FaasDocumentOperationValues +{ +/** When a new object is created. */ +static constexpr const char *INSERT = "insert"; +/** When an object is modified. */ +static constexpr const char *EDIT = "edit"; +/** When an object is deleted. */ +static constexpr const char *DELETE = "delete"; +} // namespace FaasDocumentOperationValues + +namespace FaasInvokedProviderValues +{ +/** Alibaba Cloud. */ +static constexpr const char *ALIBABA_CLOUD = "alibaba_cloud"; +/** Amazon Web Services. */ +static constexpr const char *AWS = "aws"; +/** Microsoft Azure. */ +static constexpr const char *AZURE = "azure"; +/** Google Cloud Platform. */ +static constexpr const char *GCP = "gcp"; +/** Tencent Cloud. */ +static constexpr const char *TENCENT_CLOUD = "tencent_cloud"; +} // namespace FaasInvokedProviderValues + +namespace NetTransportValues +{ +/** ip_tcp. */ +static constexpr const char *IP_TCP = "ip_tcp"; +/** ip_udp. */ +static constexpr const char *IP_UDP = "ip_udp"; +/** Another IP-based protocol. */ +static constexpr const char *IP = "ip"; +/** Unix Domain socket. See below. */ +static constexpr const char *UNIX = "unix"; +/** Named or anonymous pipe. See note below. */ +static constexpr const char *PIPE = "pipe"; +/** In-process communication. */ +static constexpr const char *INPROC = "inproc"; +/** Something else (non IP-based). */ +static constexpr const char *OTHER = "other"; +} // namespace NetTransportValues + +namespace NetHostConnectionTypeValues +{ +/** wifi. */ +static constexpr const char *WIFI = "wifi"; +/** wired. */ +static constexpr const char *WIRED = "wired"; +/** cell. */ +static constexpr const char *CELL = "cell"; +/** unavailable. */ +static constexpr const char *UNAVAILABLE = "unavailable"; +/** unknown. */ +static constexpr const char *UNKNOWN = "unknown"; +} // namespace NetHostConnectionTypeValues + +namespace NetHostConnectionSubtypeValues +{ +/** GPRS. */ +static constexpr const char *GPRS = "gprs"; +/** EDGE. */ +static constexpr const char *EDGE = "edge"; +/** UMTS. */ +static constexpr const char *UMTS = "umts"; +/** CDMA. */ +static constexpr const char *CDMA = "cdma"; +/** EVDO Rel. 0. */ +static constexpr const char *EVDO_0 = "evdo_0"; +/** EVDO Rev. A. */ +static constexpr const char *EVDO_A = "evdo_a"; +/** CDMA2000 1XRTT. */ +static constexpr const char *CDMA2000_1XRTT = "cdma2000_1xrtt"; +/** HSDPA. */ +static constexpr const char *HSDPA = "hsdpa"; +/** HSUPA. */ +static constexpr const char *HSUPA = "hsupa"; +/** HSPA. */ +static constexpr const char *HSPA = "hspa"; +/** IDEN. */ +static constexpr const char *IDEN = "iden"; +/** EVDO Rev. B. */ +static constexpr const char *EVDO_B = "evdo_b"; +/** LTE. */ +static constexpr const char *LTE = "lte"; +/** EHRPD. */ +static constexpr const char *EHRPD = "ehrpd"; +/** HSPAP. */ +static constexpr const char *HSPAP = "hspap"; +/** GSM. */ +static constexpr const char *GSM = "gsm"; +/** TD-SCDMA. */ +static constexpr const char *TD_SCDMA = "td_scdma"; +/** IWLAN. */ +static constexpr const char *IWLAN = "iwlan"; +/** 5G NR (New Radio). */ +static constexpr const char *NR = "nr"; +/** 5G NRNSA (New Radio Non-Standalone). */ +static constexpr const char *NRNSA = "nrnsa"; +/** LTE CA. */ +static constexpr const char *LTE_CA = "lte_ca"; +} // namespace NetHostConnectionSubtypeValues + +namespace HttpFlavorValues +{ +/** HTTP/1.0. */ +static constexpr const char *HTTP_1_0 = "1.0"; +/** HTTP/1.1. */ +static constexpr const char *HTTP_1_1 = "1.1"; +/** HTTP/2. */ +static constexpr const char *HTTP_2_0 = "2.0"; +/** HTTP/3. */ +static constexpr const char *HTTP_3_0 = "3.0"; +/** SPDY protocol. */ +static constexpr const char *SPDY = "SPDY"; +/** QUIC protocol. */ +static constexpr const char *QUIC = "QUIC"; +} // namespace HttpFlavorValues + +namespace MessagingDestinationKindValues +{ +/** A message sent to a queue. */ +static constexpr const char *QUEUE = "queue"; +/** A message sent to a topic. */ +static constexpr const char *TOPIC = "topic"; +} // namespace MessagingDestinationKindValues + +namespace MessagingOperationValues +{ +/** receive. */ +static constexpr const char *RECEIVE = "receive"; +/** process. */ +static constexpr const char *PROCESS = "process"; +} // namespace MessagingOperationValues + +namespace MessagingRocketmqMessageTypeValues +{ +/** Normal message. */ +static constexpr const char *NORMAL = "normal"; +/** FIFO message. */ +static constexpr const char *FIFO = "fifo"; +/** Delay message. */ +static constexpr const char *DELAY = "delay"; +/** Transaction message. */ +static constexpr const char *TRANSACTION = "transaction"; +} // namespace MessagingRocketmqMessageTypeValues + +namespace MessagingRocketmqConsumptionModelValues +{ +/** Clustering consumption model. */ +static constexpr const char *CLUSTERING = "clustering"; +/** Broadcasting consumption model. */ +static constexpr const char *BROADCASTING = "broadcasting"; +} // namespace MessagingRocketmqConsumptionModelValues + +namespace RpcSystemValues +{ +/** gRPC. */ +static constexpr const char *GRPC = "grpc"; +/** Java RMI. */ +static constexpr const char *JAVA_RMI = "java_rmi"; +/** .NET WCF. */ +static constexpr const char *DOTNET_WCF = "dotnet_wcf"; +/** Apache Dubbo. */ +static constexpr const char *APACHE_DUBBO = "apache_dubbo"; +} // namespace RpcSystemValues + +namespace RpcGrpcStatusCodeValues +{ +/** OK. */ +static constexpr const int OK = 0; +/** CANCELLED. */ +static constexpr const int CANCELLED = 1; +/** UNKNOWN. */ +static constexpr const int UNKNOWN = 2; +/** INVALID_ARGUMENT. */ +static constexpr const int INVALID_ARGUMENT = 3; +/** DEADLINE_EXCEEDED. */ +static constexpr const int DEADLINE_EXCEEDED = 4; +/** NOT_FOUND. */ +static constexpr const int NOT_FOUND = 5; +/** ALREADY_EXISTS. */ +static constexpr const int ALREADY_EXISTS = 6; +/** PERMISSION_DENIED. */ +static constexpr const int PERMISSION_DENIED = 7; +/** RESOURCE_EXHAUSTED. */ +static constexpr const int RESOURCE_EXHAUSTED = 8; +/** FAILED_PRECONDITION. */ +static constexpr const int FAILED_PRECONDITION = 9; +/** ABORTED. */ +static constexpr const int ABORTED = 10; +/** OUT_OF_RANGE. */ +static constexpr const int OUT_OF_RANGE = 11; +/** UNIMPLEMENTED. */ +static constexpr const int UNIMPLEMENTED = 12; +/** INTERNAL. */ +static constexpr const int INTERNAL = 13; +/** UNAVAILABLE. */ +static constexpr const int UNAVAILABLE = 14; +/** DATA_LOSS. */ +static constexpr const int DATA_LOSS = 15; +/** UNAUTHENTICATED. */ +static constexpr const int UNAUTHENTICATED = 16; +} // namespace RpcGrpcStatusCodeValues + +namespace MessageTypeValues +{ +/** sent. */ +static constexpr const char *SENT = "SENT"; +/** received. */ +static constexpr const char *RECEIVED = "RECEIVED"; +} // namespace MessageTypeValues + +} // namespace SemanticConventions +} // namespace trace +OPENTELEMETRY_END_NAMESPACE diff --git a/buildscripts/semantic-convention/.gitignore b/buildscripts/semantic-convention/.gitignore new file mode 100644 index 0000000000..a93b221beb --- /dev/null +++ b/buildscripts/semantic-convention/.gitignore @@ -0,0 +1 @@ +opentelemetry-specification/ diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh new file mode 100755 index 0000000000..9410c72eb6 --- /dev/null +++ b/buildscripts/semantic-convention/generate.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# +# Adapted from: +# opentelemetry-java/buildscripts/semantic-convention/generate.sh +# for opentelemetry-cpp +# + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOT_DIR="${SCRIPT_DIR}/../../" + +# freeze the spec & generator tools versions to make SemanticAttributes generation reproducible +SEMCONV_VERSION=1.12.0 +SPEC_VERSION=v$SEMCONV_VERSION +SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION +GENERATOR_VERSION=0.7.0 + +cd ${SCRIPT_DIR} + +rm -rf opentelemetry-specification || true +mkdir opentelemetry-specification +cd opentelemetry-specification + +git init +git remote add origin https://github.com/open-telemetry/opentelemetry-specification.git +git fetch origin "$SPEC_VERSION" +git reset --hard FETCH_HEAD +cd ${SCRIPT_DIR} + +docker run --rm \ + -v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions/trace:/source \ + -v ${SCRIPT_DIR}/templates:/templates \ + -v ${ROOT_DIR}/api/include/opentelemetry/trace/:/output \ + otel/semconvgen:$GENERATOR_VERSION \ + -f /source code \ + --template /templates/SemanticAttributes.h.j2 \ + --output /output/semantic_conventions.h \ + -Dsemconv=trace \ + -Dclass=SemanticConventions \ + -DschemaUrl=$SCHEMA_URL \ + -Dnamespace_open="namespace trace {" \ + -Dnamespace_close="}" + +docker run --rm \ + -v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions/resource:/source \ + -v ${SCRIPT_DIR}/templates:/templates \ + -v ${ROOT_DIR}/sdk/include/opentelemetry/sdk/resource/:/output \ + otel/semconvgen:$GENERATOR_VERSION \ + -f /source code \ + --template /templates/SemanticAttributes.h.j2 \ + --output /output/semantic_conventions.h \ + -Dsemconv=resource \ + -Dclass=SemanticConventions \ + -DschemaUrl=$SCHEMA_URL \ + -Dnamespace_open="namespace sdk { namespace resource {" \ + -Dnamespace_close="} }" + diff --git a/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 b/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 new file mode 100644 index 0000000000..c1bdd4afb4 --- /dev/null +++ b/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 @@ -0,0 +1,120 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ +{# + Adapted from: + opentelemetry-java/buildscripts/semantic-convention/templates/SemanticAttributes.java.j2 + for opentelemetry-cpp +#} +{%- macro to_cpp_return_type(type) -%} + {%- if type == "string" -%} + char * + {%- elif type == "string[]" -%} + char *[] + {%- elif type == "boolean" -%} + bool + {%- elif type == "int" -%} + int + {%- elif type == "double" -%} + double + {%- else -%} + {{type}} + {%- endif -%} +{%- endmacro %} +{%- macro print_value(type, value) -%} + {{ "\"" if type == "char *"}}{{value}}{{ "\"" if type == "char *"}} +{%- endmacro %} +{%- macro upFirst(text) -%} + {{ text[0]|upper}}{{text[1:] }} +{%- endmacro %} +{%- macro lowerFirst(text) -%} + {{ text[0]|lower}}{{text[1:] }} +{%- endmacro %} + +/* + DO NOT EDIT, this is an Auto-generated file + from buildscripts/semantic-convention{{template}} +*/ + +#pragma once + +#include "opentelemetry/version.h" + +{%- if semconv == "trace" %} +/* + * Special considerations for FaasDocumentOperationValues::DELETE. + * + * The winnt.h header file is known to define a DELETE symbol, + * which collides with FaasDocumentOperationValues::DELETE. + */ +#ifdef _WIN32 +# ifdef DELETE +# pragma message(__FILE__ ": removing define on DELETE") +# undef DELETE +# endif +#endif +{% endif %} + +OPENTELEMETRY_BEGIN_NAMESPACE +{{namespace_open}} + +namespace {{class}} +{ +/** + * The URL of the OpenTelemetry schema for these keys and values. + */ +static constexpr const char *SCHEMA_URL = "{{schemaUrl}}"; + {%- for attribute in attributes if attribute.is_local and not attribute.ref %} + +/** + * {{attribute.brief | render_markdown(code="{{@code {0}}}", paragraph="{0}")}} + {%- if attribute.note %} + * + *

Notes: +

    {{attribute.note | render_markdown(code="{{@code {0}}}", paragraph="
  • {0}
  • ", list="{0}")}}
+ {%- endif %} +{%- if attribute.deprecated %} + * + * @deprecated {{attribute.deprecated | to_doc_brief}}. + {%- endif %} + */ + {%- if attribute.deprecated %} +@Deprecated + {%- endif %} +static constexpr const char *{{attribute.fqn | to_const_name}} = "{{attribute.fqn}}"; +{%- endfor %} + +// Enum definitions +{%- for attribute in attributes if attribute.is_local and not attribute.ref %} +{%- if attribute.is_enum %} +{%- set enum_name = attribute.fqn | to_camelcase(True) ~ "Values" %} +{%- set type = to_cpp_return_type(attribute.attr_type.enum_type) %} +namespace {{enum_name}} +{ + {%- for member in attribute.attr_type.members %} + /** {% filter escape %}{{member.brief | to_doc_brief}}.{% endfilter %} */ + static constexpr const {{ type }} {{ member.member_id | to_const_name }} = {{ print_value(type, member.value) }}; + {%- endfor %} +} +{% endif %} +{%- endfor %} + +{# + {%- if class == "SemanticAttributes" %} + // Manually defined and not YET in the YAML + /** + * The name of an event describing an exception. + * + *

Typically an event with that name should not be manually created. Instead {@link + * io.opentelemetry.api.trace.Span#recordException(Throwable)} should be used. + */ + static constexpr const char *EXCEPTION_EVENT_NAME = "exception"; + + {% endif %} +#} + +} // namespace {{class}} +{{namespace_close}} +OPENTELEMETRY_END_NAMESPACE + diff --git a/docs/semantic-conventions.md b/docs/semantic-conventions.md new file mode 100644 index 0000000000..01695c3e67 --- /dev/null +++ b/docs/semantic-conventions.md @@ -0,0 +1,76 @@ +# Semantic Conventions + +## Tooling + +The following files + +* [trace/semantic_conventions.h](/api/include/opentelemetry/trace/semantic_conventions.h) +* [sdk/resource/semantic_conventions.h](/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h) + +are generated automatically. + +The source data is in YAML format, located in the +[specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/semantic_conventions/README.md). + +A code [generator](https://github.com/open-telemetry/build-tools/blob/main/semantic-conventions/README.md) +parses the YAML data from the specs, +and generate code for various languages using a template engine. + +For opentelemetry-cpp, the templates are located in +[buildscripts](/buildscripts/semantic-convention/templates/SemanticAttributes.h.j2). + +A [generate.sh](/buildscripts/semantic-convention/generate.sh) script +downloads the specs, invokes the generator using Docker, +and generates code for opentelemetry-cpp. + +## Instructions + +### Find latest specifications + +Check for the latest +[specification](https://github.com/open-telemetry/opentelemetry-specification/releases) +release, and note the release tag number. + +For example, tag v1.12.0 + +### Use latest specifications + +Set the `SEMCONV_VERSION` number in the +[generate.sh](/buildscripts/semantic-convention/generate.sh) script. + +For example, + +```shell +SEMCONV_VERSION=1.12.0 +``` + +### Generate code + +Run the generate.sh script. + +Inspect the generated files, +to verify they were updated (check the version number in SCHEMA_URL). + +For example, + +```cpp +static constexpr const char *SCHEMA_URL = "https://opentelemetry.io/schemas/1.12.0"; +``` + +### Format code + +Apply clang-format. + +### Update CHANGELOG + +Add a `CHANGELOG` entry for the semantic conventions. + +For example, + +```md +* [SEMANTIC CONVENTIONS] Upgrade to version 1.12.0 +``` + +### Commit + +Commit and file a pull request. diff --git a/examples/grpc/client.cc b/examples/grpc/client.cc index 5a182f19a3..ea7c5053f9 100644 --- a/examples/grpc/client.cc +++ b/examples/grpc/client.cc @@ -11,7 +11,8 @@ #include #include #include -#include "opentelemetry/trace/experimental_semantic_conventions.h" + +#include "opentelemetry/trace/semantic_conventions.h" #include "tracer_common.h" using grpc::Channel; @@ -46,11 +47,11 @@ class GreeterClient std::string span_name = "GreeterClient/Greet"; auto span = get_tracer("grpc")->StartSpan( span_name, - {{OTEL_GET_TRACE_ATTR(AttrRpcSystem), "grpc"}, - {OTEL_GET_TRACE_ATTR(AttrRpcService), "grpc-example.GreetService"}, - {OTEL_GET_TRACE_ATTR(AttrRpcMethod), "Greet"}, - {OTEL_GET_TRACE_ATTR(AttrNetPeerIp), ip}, - {OTEL_GET_TRACE_ATTR(AttrNetPeerPort), port}}, + {{SemanticConventions::RPC_SYSTEM, "grpc"}, + {SemanticConventions::RPC_SERVICE, "grpc-example.GreetService"}, + {SemanticConventions::RPC_METHOD, "Greet"}, + {SemanticConventions::NET_PEER_IP, ip}, + {SemanticConventions::NET_PEER_PORT, port}}, options); auto scope = get_tracer("grpc-client")->WithActiveSpan(span); @@ -66,7 +67,7 @@ class GreeterClient if (status.ok()) { span->SetStatus(StatusCode::kOk); - span->SetAttribute(OTEL_GET_TRACE_ATTR(AttrRpcGrpcStatusCode), status.error_code()); + span->SetAttribute(SemanticConventions::RPC_GRPC_STATUS_CODE, status.error_code()); // Make sure to end your spans! span->End(); return response.response(); @@ -75,7 +76,7 @@ class GreeterClient { std::cout << status.error_code() << ": " << status.error_message() << std::endl; span->SetStatus(StatusCode::kError); - span->SetAttribute(OTEL_GET_TRACE_ATTR(AttrRpcGrpcStatusCode), status.error_code()); + span->SetAttribute(SemanticConventions::RPC_GRPC_STATUS_CODE, status.error_code()); // Make sure to end your spans! span->End(); return "RPC failed"; diff --git a/examples/grpc/server.cc b/examples/grpc/server.cc index 2671cc0b68..ee96edac4e 100644 --- a/examples/grpc/server.cc +++ b/examples/grpc/server.cc @@ -5,7 +5,7 @@ #endif #include "opentelemetry/trace/context.h" -#include "opentelemetry/trace/experimental_semantic_conventions.h" +#include "opentelemetry/trace/semantic_conventions.h" #include "opentelemetry/trace/span_context_kv_iterable_view.h" #include "tracer_common.h" @@ -64,14 +64,13 @@ class GreeterServer final : public Greeter::Service options.parent = GetSpan(new_context)->GetContext(); std::string span_name = "GreeterService/Greet"; - auto span = - get_tracer("grpc")->StartSpan(span_name, - {{OTEL_GET_TRACE_ATTR(AttrRpcSystem), "grpc"}, - {OTEL_GET_TRACE_ATTR(AttrRpcService), "GreeterService"}, - {OTEL_GET_TRACE_ATTR(AttrRpcMethod), "Greet"}, - {OTEL_GET_TRACE_ATTR(AttrRpcGrpcStatusCode), 0}}, - options); - auto scope = get_tracer("grpc")->WithActiveSpan(span); + auto span = get_tracer("grpc")->StartSpan(span_name, + {{SemanticConventions::RPC_SYSTEM, "grpc"}, + {SemanticConventions::RPC_SERVICE, "GreeterService"}, + {SemanticConventions::RPC_METHOD, "Greet"}, + {SemanticConventions::RPC_GRPC_STATUS_CODE, 0}}, + options); + auto scope = get_tracer("grpc")->WithActiveSpan(span); // Fetch and parse whatever HTTP headers we can from the gRPC request. span->AddEvent("Processing client attributes"); diff --git a/examples/http/client.cc b/examples/http/client.cc index 91161e2215..18763c241f 100644 --- a/examples/http/client.cc +++ b/examples/http/client.cc @@ -3,7 +3,7 @@ #include "opentelemetry/ext/http/client/http_client_factory.h" #include "opentelemetry/ext/http/common/url_parser.h" -#include "opentelemetry/trace/experimental_semantic_conventions.h" +#include "opentelemetry/trace/semantic_conventions.h" #include "tracer_common.h" namespace @@ -26,9 +26,9 @@ void sendRequest(const std::string &url) std::string span_name = url_parser.path_; auto span = get_tracer("http-client") ->StartSpan(span_name, - {{OTEL_GET_TRACE_ATTR(AttrHttpUrl), url_parser.url_}, - {OTEL_GET_TRACE_ATTR(AttrHttpScheme), url_parser.scheme_}, - {OTEL_GET_TRACE_ATTR(AttrHttpMethod), "GET"}}, + {{SemanticConventions::HTTP_URL, url_parser.url_}, + {SemanticConventions::HTTP_SCHEME, url_parser.scheme_}, + {SemanticConventions::HTTP_METHOD, "GET"}}, options); auto scope = get_tracer("http-client")->WithActiveSpan(span); @@ -44,7 +44,7 @@ void sendRequest(const std::string &url) { // set span attributes auto status_code = result.GetResponse().GetStatusCode(); - span->SetAttribute(OTEL_GET_TRACE_ATTR(AttrHttpStatusCode), status_code); + span->SetAttribute(SemanticConventions::HTTP_STATUS_CODE, status_code); result.GetResponse().ForEachHeader( [&span](nostd::string_view header_name, nostd::string_view header_value) { span->SetAttribute("http.header." + std::string(header_name.data()), header_value); diff --git a/examples/http/server.cc b/examples/http/server.cc index 46772dc05e..cf7e6bba51 100644 --- a/examples/http/server.cc +++ b/examples/http/server.cc @@ -3,7 +3,7 @@ #include "server.h" #include "opentelemetry/trace/context.h" -#include "opentelemetry/trace/experimental_semantic_conventions.h" +#include "opentelemetry/trace/semantic_conventions.h" #include "tracer_common.h" #include @@ -39,13 +39,13 @@ class RequestHandler : public HTTP_SERVER_NS::HttpRequestCallback // start span with parent context extracted from http header auto span = get_tracer("http-server") ->StartSpan(span_name, - {{OTEL_GET_TRACE_ATTR(AttrHttpServerName), server_name}, - {OTEL_GET_TRACE_ATTR(AttrNetHostPort), server_port}, - {OTEL_GET_TRACE_ATTR(AttrHttpMethod), request.method}, - {OTEL_GET_TRACE_ATTR(AttrHttpScheme), "http"}, - {OTEL_GET_TRACE_ATTR(AttrHttpRequestContentLength), + {{SemanticConventions::HTTP_SERVER_NAME, server_name}, + {SemanticConventions::NET_HOST_PORT, server_port}, + {SemanticConventions::HTTP_METHOD, request.method}, + {SemanticConventions::HTTP_SCHEME, "http"}, + {SemanticConventions::HTTP_REQUEST_CONTENT_LENGTH, static_cast(request.content.length())}, - {OTEL_GET_TRACE_ATTR(AttrHttpClientIp), request.client}}, + {SemanticConventions::HTTP_CLIENT_IP, request.client}}, options); auto scope = get_tracer("http_server")->WithActiveSpan(span); diff --git a/exporters/jaeger/src/recordable.cc b/exporters/jaeger/src/recordable.cc index c4a61a5d22..1cbb7da94f 100644 --- a/exporters/jaeger/src/recordable.cc +++ b/exporters/jaeger/src/recordable.cc @@ -3,7 +3,7 @@ #include "opentelemetry/exporters/jaeger/recordable.h" #include "opentelemetry/sdk/common/global_log_handler.h" -#include "opentelemetry/sdk/resource/experimental_semantic_conventions.h" +#include "opentelemetry/sdk/resource/semantic_conventions.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/exporters/otlp/test/otlp_log_recordable_test.cc b/exporters/otlp/test/otlp_log_recordable_test.cc index bb48fd54e9..774c5e8cec 100644 --- a/exporters/otlp/test/otlp_log_recordable_test.cc +++ b/exporters/otlp/test/otlp_log_recordable_test.cc @@ -6,8 +6,8 @@ # include # include "opentelemetry/exporters/otlp/otlp_log_recordable.h" -# include "opentelemetry/sdk/resource/experimental_semantic_conventions.h" # include "opentelemetry/sdk/resource/resource.h" +# include "opentelemetry/sdk/resource/semantic_conventions.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter @@ -104,20 +104,17 @@ TEST(OtlpLogRecordable, DefaultResource) for (int i = 0; i < proto_resource.attributes_size(); i++) { auto attr = proto_resource.attributes(static_cast(i)); - if (attr.key() == - opentelemetry::sdk::resource::attr(OTEL_CPP_CONST_HASHCODE(AttrTelemetrySdkLanguage))) + if (attr.key() == resource::SemanticConventions::TELEMETRY_SDK_LANGUAGE) { EXPECT_EQ(attr.value().string_value(), "cpp"); ++found_resource_count; } - else if (attr.key() == - opentelemetry::sdk::resource::attr(OTEL_CPP_CONST_HASHCODE(AttrTelemetrySdkName))) + else if (attr.key() == resource::SemanticConventions::TELEMETRY_SDK_NAME) { EXPECT_EQ(attr.value().string_value(), "opentelemetry"); ++found_resource_count; } - else if (attr.key() == - opentelemetry::sdk::resource::attr(OTEL_CPP_CONST_HASHCODE(AttrTelemetrySdkVersion))) + else if (attr.key() == resource::SemanticConventions::TELEMETRY_SDK_VERSION) { EXPECT_EQ(attr.value().string_value(), OPENTELEMETRY_SDK_VERSION); ++found_resource_count; diff --git a/exporters/zipkin/src/recordable.cc b/exporters/zipkin/src/recordable.cc index 700d6a964c..1f4f6d5a90 100644 --- a/exporters/zipkin/src/recordable.cc +++ b/exporters/zipkin/src/recordable.cc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "opentelemetry/exporters/zipkin/recordable.h" -#include "opentelemetry/sdk/resource/experimental_semantic_conventions.h" +#include "opentelemetry/sdk/resource/semantic_conventions.h" #include #include @@ -216,9 +216,9 @@ void Recordable::SetResource(const sdk::resource::Resource &resource) noexcept { // only service.name attribute is supported by specs as of now. auto attributes = resource.GetAttributes(); - if (attributes.find(OTEL_GET_RESOURCE_ATTR(AttrServiceName)) != attributes.end()) + if (attributes.find(SemanticConventions::SERVICE_NAME) != attributes.end()) { - service_name_ = nostd::get(attributes[OTEL_GET_RESOURCE_ATTR(AttrServiceName)]); + service_name_ = nostd::get(attributes[SemanticConventions::SERVICE_NAME]); } } diff --git a/sdk/include/opentelemetry/sdk/resource/experimental_semantic_conventions.h b/sdk/include/opentelemetry/sdk/resource/experimental_semantic_conventions.h index d9dc3630fa..93f0f4e384 100644 --- a/sdk/include/opentelemetry/sdk/resource/experimental_semantic_conventions.h +++ b/sdk/include/opentelemetry/sdk/resource/experimental_semantic_conventions.h @@ -7,6 +7,8 @@ // https://github.com/open-telemetry/opentelemetry-specification/tree/v1.0.0/specification/resource/semantic_conventions // and MAY will change in future. +// "This file is deprecated. Use opentelemetry/sdk/resource/semantic_conventions.h" + #pragma once #include @@ -138,4 +140,4 @@ inline const char *attr(uint32_t attr) } } // namespace resource } // namespace sdk -OPENTELEMETRY_END_NAMESPACE \ No newline at end of file +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h new file mode 100644 index 0000000000..28d5438653 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/resource/semantic_conventions.h @@ -0,0 +1,793 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + DO NOT EDIT, this is an Auto-generated file + from buildscripts/semantic-convention/templates/SemanticAttributes.h.j2 +*/ + +#pragma once + +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace resource +{ + +namespace SemanticConventions +{ +/** + * The URL of the OpenTelemetry schema for these keys and values. + */ +static constexpr const char *SCHEMA_URL = "https://opentelemetry.io/schemas/1.12.0"; + +/** + * Array of brand name and version separated by a space + * + *

Notes: +

  • This value is intended to be taken from the UA client hints API + (navigator.userAgentData.brands).
+ */ +static constexpr const char *BROWSER_BRANDS = "browser.brands"; + +/** + * The platform on which the browser is running + * + *

Notes: +

  • This value is intended to be taken from the UA client hints API +(navigator.userAgentData.platform). If unavailable, the legacy {@code 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. Note that some (but not all) of these values can overlap with values in the os.type and os.name attributes. However, for consistency, the values in the +{@code browser.platform} attribute should capture the exact value that the user agent provides.
  • +
+ */ +static constexpr const char *BROWSER_PLATFORM = "browser.platform"; + +/** + * Full user-agent string provided by the browser + * + *

Notes: +

  • The user-agent value SHOULD be provided only from browsers that do not have a mechanism + to retrieve brands and platform individually from the User-Agent Client Hints API. To retrieve the + value, the legacy {@code navigator.userAgent} API can be used.
+ */ +static constexpr const char *BROWSER_USER_AGENT = "browser.user_agent"; + +/** + * Name of the cloud provider. + */ +static constexpr const char *CLOUD_PROVIDER = "cloud.provider"; + +/** + * The cloud account ID the resource is assigned to. + */ +static constexpr const char *CLOUD_ACCOUNT_ID = "cloud.account.id"; + +/** + * The geographical region the resource is running. + * + *

Notes: +

+ */ +static constexpr const char *CLOUD_REGION = "cloud.region"; + +/** + * Cloud regions often have multiple, isolated locations known as zones to increase availability. + Availability zone represents the zone where the resource is running. + * + *

Notes: +

  • Availability zones are called "zones" on Alibaba Cloud and Google Cloud.
  • +
+ */ +static constexpr const char *CLOUD_AVAILABILITY_ZONE = "cloud.availability_zone"; + +/** + * The cloud platform in use. + * + *

Notes: +

  • The prefix of the service SHOULD match the one specified in {@code cloud.provider}.
  • +
+ */ +static constexpr const char *CLOUD_PLATFORM = "cloud.platform"; + +/** + * The Amazon Resource Name (ARN) of an ECS + * container instance. + */ +static constexpr const char *AWS_ECS_CONTAINER_ARN = "aws.ecs.container.arn"; + +/** + * The ARN of an ECS cluster. + */ +static constexpr const char *AWS_ECS_CLUSTER_ARN = "aws.ecs.cluster.arn"; + +/** + * The launch + * type for an ECS task. + */ +static constexpr const char *AWS_ECS_LAUNCHTYPE = "aws.ecs.launchtype"; + +/** + * The ARN of an ECS task + * definition. + */ +static constexpr const char *AWS_ECS_TASK_ARN = "aws.ecs.task.arn"; + +/** + * The task definition family this task definition is a member of. + */ +static constexpr const char *AWS_ECS_TASK_FAMILY = "aws.ecs.task.family"; + +/** + * The revision for this task definition. + */ +static constexpr const char *AWS_ECS_TASK_REVISION = "aws.ecs.task.revision"; + +/** + * The ARN of an EKS cluster. + */ +static constexpr const char *AWS_EKS_CLUSTER_ARN = "aws.eks.cluster.arn"; + +/** + * The name(s) of the AWS log group(s) an application is writing to. + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *AWS_LOG_GROUP_NAMES = "aws.log.group.names"; + +/** + * The Amazon Resource Name(s) (ARN) of the AWS log group(s). + * + *

Notes: +

+ */ +static constexpr const char *AWS_LOG_GROUP_ARNS = "aws.log.group.arns"; + +/** + * The name(s) of the AWS log stream(s) an application is writing to. + */ +static constexpr const char *AWS_LOG_STREAM_NAMES = "aws.log.stream.names"; + +/** + * The ARN(s) of the AWS log stream(s). + * + *

Notes: +

+ */ +static constexpr const char *AWS_LOG_STREAM_ARNS = "aws.log.stream.arns"; + +/** + * Container name used by container runtime. + */ +static constexpr const char *CONTAINER_NAME = "container.name"; + +/** + * Container ID. Usually a UUID, as for example used to identify Docker + * containers. The UUID might be abbreviated. + */ +static constexpr const char *CONTAINER_ID = "container.id"; + +/** + * The container runtime managing this container. + */ +static constexpr const char *CONTAINER_RUNTIME = "container.runtime"; + +/** + * Name of the image the container was built on. + */ +static constexpr const char *CONTAINER_IMAGE_NAME = "container.image.name"; + +/** + * Container image tag. + */ +static constexpr const char *CONTAINER_IMAGE_TAG = "container.image.tag"; + +/** + * Name of the deployment + * environment (aka deployment tier). + */ +static constexpr const char *DEPLOYMENT_ENVIRONMENT = "deployment.environment"; + +/** + * A unique identifier representing the device + * + *

Notes: +

  • 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. 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 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.
+ */ +static constexpr const char *DEVICE_ID = "device.id"; + +/** + * The model identifier for the device + * + *

Notes: +

  • 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.
+ */ +static constexpr const char *DEVICE_MODEL_IDENTIFIER = "device.model.identifier"; + +/** + * The marketing name for the device model + * + *

Notes: +

  • It's recommended this value represents a human readable version of the device model + rather than a machine readable alternative.
+ */ +static constexpr const char *DEVICE_MODEL_NAME = "device.model.name"; + +/** + * The name of the device manufacturer + * + *

Notes: +

  • The Android OS provides this field via Build. iOS apps + SHOULD hardcode the value {@code Apple}.
+ */ +static constexpr const char *DEVICE_MANUFACTURER = "device.manufacturer"; + +/** + * The name of the single function that this runtime instance executes. + * + *

Notes: +

  • 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 +code.namespace}/{@code code.function} 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 {@code /}, 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 {@code faas.id} attribute).
  • +
+ */ +static constexpr const char *FAAS_NAME = "faas.name"; + +/** + * The unique ID of the single function that this runtime instance executes. + * + *

Notes: +

  • On some cloud providers, it may not be possible to determine the full ID at startup, +so consider setting {@code faas.id} as a span attribute instead.
  • The exact value to use for +{@code faas.id} depends on the cloud provider:
  • AWS Lambda: The function ARN. Take care +not to use the "invoked ARN" directly but replace any alias suffix with +the resolved function version, as the same runtime instance may be invokable with multiple different +aliases.
  • GCP: The URI of the resource
  • +
  • Azure: The Fully Qualified +Resource ID of the invoked function, not the function app, having the form +{@code +/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.
  • +
+ */ +static constexpr const char *FAAS_ID = "faas.id"; + +/** + * The immutable version of the function being executed. + * + *

Notes: +

  • Depending on the cloud provider and platform, use:
  • AWS Lambda: +The function +version (an integer represented as a decimal string).
  • Google Cloud +Run: The revision (i.e., +the function name plus the revision suffix).
  • Google Cloud Functions: The +value of the {@code +K_REVISION} environment variable.
  • Azure Functions: Not applicable. Do +not set this attribute.
  • +
+ */ +static constexpr const char *FAAS_VERSION = "faas.version"; + +/** + * The execution environment ID as a string, that will be potentially reused for other invocations + to the same function/function version. + * + *

Notes: +

  • AWS Lambda: Use the (full) log stream name.
  • +
+ */ +static constexpr const char *FAAS_INSTANCE = "faas.instance"; + +/** + * The amount of memory available to the serverless function in MiB. + * + *

Notes: +

  • 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 {@code + AWS_LAMBDA_FUNCTION_MEMORY_SIZE} provides this information.
+ */ +static constexpr const char *FAAS_MAX_MEMORY = "faas.max_memory"; + +/** + * Unique host ID. For Cloud, this must be the instance_id assigned by the cloud provider. + */ +static constexpr const char *HOST_ID = "host.id"; + +/** + * 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. + */ +static constexpr const char *HOST_NAME = "host.name"; + +/** + * Type of host. For Cloud, this must be the machine type. + */ +static constexpr const char *HOST_TYPE = "host.type"; + +/** + * The CPU architecture the host system is running on. + */ +static constexpr const char *HOST_ARCH = "host.arch"; + +/** + * Name of the VM image or OS install the host was instantiated from. + */ +static constexpr const char *HOST_IMAGE_NAME = "host.image.name"; + +/** + * VM image ID. For Cloud, this value is from the provider. + */ +static constexpr const char *HOST_IMAGE_ID = "host.image.id"; + +/** + * The version string of the VM image as defined in Version + * Attributes. + */ +static constexpr const char *HOST_IMAGE_VERSION = "host.image.version"; + +/** + * The name of the cluster. + */ +static constexpr const char *K8S_CLUSTER_NAME = "k8s.cluster.name"; + +/** + * The name of the Node. + */ +static constexpr const char *K8S_NODE_NAME = "k8s.node.name"; + +/** + * The UID of the Node. + */ +static constexpr const char *K8S_NODE_UID = "k8s.node.uid"; + +/** + * The name of the namespace that the pod is running in. + */ +static constexpr const char *K8S_NAMESPACE_NAME = "k8s.namespace.name"; + +/** + * The UID of the Pod. + */ +static constexpr const char *K8S_POD_UID = "k8s.pod.uid"; + +/** + * The name of the Pod. + */ +static constexpr const char *K8S_POD_NAME = "k8s.pod.name"; + +/** + * The name of the Container from Pod specification, must be unique within a Pod. Container runtime + * usually uses different globally unique name ({@code container.name}). + */ +static constexpr const char *K8S_CONTAINER_NAME = "k8s.container.name"; + +/** + * Number of times the container was restarted. This attribute can be used to identify a particular + * container (running or stopped) within a container spec. + */ +static constexpr const char *K8S_CONTAINER_RESTART_COUNT = "k8s.container.restart_count"; + +/** + * The UID of the ReplicaSet. + */ +static constexpr const char *K8S_REPLICASET_UID = "k8s.replicaset.uid"; + +/** + * The name of the ReplicaSet. + */ +static constexpr const char *K8S_REPLICASET_NAME = "k8s.replicaset.name"; + +/** + * The UID of the Deployment. + */ +static constexpr const char *K8S_DEPLOYMENT_UID = "k8s.deployment.uid"; + +/** + * The name of the Deployment. + */ +static constexpr const char *K8S_DEPLOYMENT_NAME = "k8s.deployment.name"; + +/** + * The UID of the StatefulSet. + */ +static constexpr const char *K8S_STATEFULSET_UID = "k8s.statefulset.uid"; + +/** + * The name of the StatefulSet. + */ +static constexpr const char *K8S_STATEFULSET_NAME = "k8s.statefulset.name"; + +/** + * The UID of the DaemonSet. + */ +static constexpr const char *K8S_DAEMONSET_UID = "k8s.daemonset.uid"; + +/** + * The name of the DaemonSet. + */ +static constexpr const char *K8S_DAEMONSET_NAME = "k8s.daemonset.name"; + +/** + * The UID of the Job. + */ +static constexpr const char *K8S_JOB_UID = "k8s.job.uid"; + +/** + * The name of the Job. + */ +static constexpr const char *K8S_JOB_NAME = "k8s.job.name"; + +/** + * The UID of the CronJob. + */ +static constexpr const char *K8S_CRONJOB_UID = "k8s.cronjob.uid"; + +/** + * The name of the CronJob. + */ +static constexpr const char *K8S_CRONJOB_NAME = "k8s.cronjob.name"; + +/** + * The operating system type. + */ +static constexpr const char *OS_TYPE = "os.type"; + +/** + * Human readable (not intended to be parsed) OS version information, like e.g. reported by {@code + * ver} or {@code lsb_release -a} commands. + */ +static constexpr const char *OS_DESCRIPTION = "os.description"; + +/** + * Human readable operating system name. + */ +static constexpr const char *OS_NAME = "os.name"; + +/** + * The version string of the operating system as defined in Version Attributes. + */ +static constexpr const char *OS_VERSION = "os.version"; + +/** + * Process identifier (PID). + */ +static constexpr const char *PROCESS_PID = "process.pid"; + +/** + * The name of the process executable. On Linux based systems, can be set to the {@code Name} in + * {@code proc/[pid]/status}. On Windows, can be set to the base name of {@code + * GetProcessImageFileNameW}. + */ +static constexpr const char *PROCESS_EXECUTABLE_NAME = "process.executable.name"; + +/** + * The full path to the process executable. On Linux based systems, can be set to the target of + * {@code proc/[pid]/exe}. On Windows, can be set to the result of {@code GetProcessImageFileNameW}. + */ +static constexpr const char *PROCESS_EXECUTABLE_PATH = "process.executable.path"; + +/** + * The command used to launch the process (i.e. the command name). On Linux based systems, can be + * set to the zeroth string in {@code proc/[pid]/cmdline}. On Windows, can be set to the first + * parameter extracted from {@code GetCommandLineW}. + */ +static constexpr const char *PROCESS_COMMAND = "process.command"; + +/** + * 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 {@code GetCommandLineW}. Do not set this if you have to + * assemble it just for monitoring; use {@code process.command_args} instead. + */ +static constexpr const char *PROCESS_COMMAND_LINE = "process.command_line"; + +/** + * 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 {@code proc/[pid]/cmdline}. For libc-based + * executables, this would be the full argv vector passed to {@code main}. + */ +static constexpr const char *PROCESS_COMMAND_ARGS = "process.command_args"; + +/** + * The username of the user that owns the process. + */ +static constexpr const char *PROCESS_OWNER = "process.owner"; + +/** + * The name of the runtime of this process. For compiled native binaries, this SHOULD be the name of + * the compiler. + */ +static constexpr const char *PROCESS_RUNTIME_NAME = "process.runtime.name"; + +/** + * The version of the runtime of this process, as returned by the runtime without modification. + */ +static constexpr const char *PROCESS_RUNTIME_VERSION = "process.runtime.version"; + +/** + * An additional description about the runtime of the process, for example a specific vendor + * customization of the runtime environment. + */ +static constexpr const char *PROCESS_RUNTIME_DESCRIPTION = "process.runtime.description"; + +/** + * Logical name of the service. + * + *

Notes: +

  • MUST be the same for all instances of horizontally scaled services. If the value was not + specified, SDKs MUST fallback to {@code unknown_service:} concatenated with {@code process.executable.name}, e.g. {@code unknown_service:bash}. + If {@code process.executable.name} is not available, the value MUST be set to {@code + unknown_service}.
+ */ +static constexpr const char *SERVICE_NAME = "service.name"; + +/** + * A namespace for {@code service.name}. + * + *

Notes: +

  • 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. {@code service.name} is expected to be unique + within the same namespace. If {@code service.namespace} is not specified in the Resource then + {@code 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.
+ */ +static constexpr const char *SERVICE_NAMESPACE = "service.namespace"; + +/** + * The string ID of the service instance. + * + *

Notes: +

  • MUST be unique for each instance of the same {@code service.namespace,service.name} pair + (in other words {@code 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). It is preferable for the ID to be persistent and + stay the same for the lifetime of the service instance, however it is acceptable that the ID is + ephemeral and changes during important lifetime events for the service (e.g. service restarts). If + the service has no inherent unique ID that can be used as the value of this attribute it is + recommended to generate a random Version 1 or Version 4 RFC 4122 UUID (services aiming for + reproducible UUIDs may also use Version 5, see RFC 4122 for more recommendations).
+ */ +static constexpr const char *SERVICE_INSTANCE_ID = "service.instance.id"; + +/** + * The version string of the service API or implementation. + */ +static constexpr const char *SERVICE_VERSION = "service.version"; + +/** + * The name of the telemetry SDK as defined above. + */ +static constexpr const char *TELEMETRY_SDK_NAME = "telemetry.sdk.name"; + +/** + * The language of the telemetry SDK. + */ +static constexpr const char *TELEMETRY_SDK_LANGUAGE = "telemetry.sdk.language"; + +/** + * The version string of the telemetry SDK. + */ +static constexpr const char *TELEMETRY_SDK_VERSION = "telemetry.sdk.version"; + +/** + * The version string of the auto instrumentation agent, if used. + */ +static constexpr const char *TELEMETRY_AUTO_VERSION = "telemetry.auto.version"; + +/** + * The name of the web engine. + */ +static constexpr const char *WEBENGINE_NAME = "webengine.name"; + +/** + * The version of the web engine. + */ +static constexpr const char *WEBENGINE_VERSION = "webengine.version"; + +/** + * Additional description of the web engine (e.g. detailed version and edition information). + */ +static constexpr const char *WEBENGINE_DESCRIPTION = "webengine.description"; + +// Enum definitions +namespace CloudProviderValues +{ +/** Alibaba Cloud. */ +static constexpr const char *ALIBABA_CLOUD = "alibaba_cloud"; +/** Amazon Web Services. */ +static constexpr const char *AWS = "aws"; +/** Microsoft Azure. */ +static constexpr const char *AZURE = "azure"; +/** Google Cloud Platform. */ +static constexpr const char *GCP = "gcp"; +/** Tencent Cloud. */ +static constexpr const char *TENCENT_CLOUD = "tencent_cloud"; +} // namespace CloudProviderValues + +namespace CloudPlatformValues +{ +/** Alibaba Cloud Elastic Compute Service. */ +static constexpr const char *ALIBABA_CLOUD_ECS = "alibaba_cloud_ecs"; +/** Alibaba Cloud Function Compute. */ +static constexpr const char *ALIBABA_CLOUD_FC = "alibaba_cloud_fc"; +/** AWS Elastic Compute Cloud. */ +static constexpr const char *AWS_EC2 = "aws_ec2"; +/** AWS Elastic Container Service. */ +static constexpr const char *AWS_ECS = "aws_ecs"; +/** AWS Elastic Kubernetes Service. */ +static constexpr const char *AWS_EKS = "aws_eks"; +/** AWS Lambda. */ +static constexpr const char *AWS_LAMBDA = "aws_lambda"; +/** AWS Elastic Beanstalk. */ +static constexpr const char *AWS_ELASTIC_BEANSTALK = "aws_elastic_beanstalk"; +/** AWS App Runner. */ +static constexpr const char *AWS_APP_RUNNER = "aws_app_runner"; +/** Azure Virtual Machines. */ +static constexpr const char *AZURE_VM = "azure_vm"; +/** Azure Container Instances. */ +static constexpr const char *AZURE_CONTAINER_INSTANCES = "azure_container_instances"; +/** Azure Kubernetes Service. */ +static constexpr const char *AZURE_AKS = "azure_aks"; +/** Azure Functions. */ +static constexpr const char *AZURE_FUNCTIONS = "azure_functions"; +/** Azure App Service. */ +static constexpr const char *AZURE_APP_SERVICE = "azure_app_service"; +/** Google Cloud Compute Engine (GCE). */ +static constexpr const char *GCP_COMPUTE_ENGINE = "gcp_compute_engine"; +/** Google Cloud Run. */ +static constexpr const char *GCP_CLOUD_RUN = "gcp_cloud_run"; +/** Google Cloud Kubernetes Engine (GKE). */ +static constexpr const char *GCP_KUBERNETES_ENGINE = "gcp_kubernetes_engine"; +/** Google Cloud Functions (GCF). */ +static constexpr const char *GCP_CLOUD_FUNCTIONS = "gcp_cloud_functions"; +/** Google Cloud App Engine (GAE). */ +static constexpr const char *GCP_APP_ENGINE = "gcp_app_engine"; +/** Tencent Cloud Cloud Virtual Machine (CVM). */ +static constexpr const char *TENCENT_CLOUD_CVM = "tencent_cloud_cvm"; +/** Tencent Cloud Elastic Kubernetes Service (EKS). */ +static constexpr const char *TENCENT_CLOUD_EKS = "tencent_cloud_eks"; +/** Tencent Cloud Serverless Cloud Function (SCF). */ +static constexpr const char *TENCENT_CLOUD_SCF = "tencent_cloud_scf"; +} // namespace CloudPlatformValues + +namespace AwsEcsLaunchtypeValues +{ +/** ec2. */ +static constexpr const char *EC2 = "ec2"; +/** fargate. */ +static constexpr const char *FARGATE = "fargate"; +} // namespace AwsEcsLaunchtypeValues + +namespace HostArchValues +{ +/** AMD64. */ +static constexpr const char *AMD64 = "amd64"; +/** ARM32. */ +static constexpr const char *ARM32 = "arm32"; +/** ARM64. */ +static constexpr const char *ARM64 = "arm64"; +/** Itanium. */ +static constexpr const char *IA64 = "ia64"; +/** 32-bit PowerPC. */ +static constexpr const char *PPC32 = "ppc32"; +/** 64-bit PowerPC. */ +static constexpr const char *PPC64 = "ppc64"; +/** IBM z/Architecture. */ +static constexpr const char *S390X = "s390x"; +/** 32-bit x86. */ +static constexpr const char *X86 = "x86"; +} // namespace HostArchValues + +namespace OsTypeValues +{ +/** Microsoft Windows. */ +static constexpr const char *WINDOWS = "windows"; +/** Linux. */ +static constexpr const char *LINUX = "linux"; +/** Apple Darwin. */ +static constexpr const char *DARWIN = "darwin"; +/** FreeBSD. */ +static constexpr const char *FREEBSD = "freebsd"; +/** NetBSD. */ +static constexpr const char *NETBSD = "netbsd"; +/** OpenBSD. */ +static constexpr const char *OPENBSD = "openbsd"; +/** DragonFly BSD. */ +static constexpr const char *DRAGONFLYBSD = "dragonflybsd"; +/** HP-UX (Hewlett Packard Unix). */ +static constexpr const char *HPUX = "hpux"; +/** AIX (Advanced Interactive eXecutive). */ +static constexpr const char *AIX = "aix"; +/** SunOS, Oracle Solaris. */ +static constexpr const char *SOLARIS = "solaris"; +/** IBM z/OS. */ +static constexpr const char *Z_OS = "z_os"; +} // namespace OsTypeValues + +namespace TelemetrySdkLanguageValues +{ +/** cpp. */ +static constexpr const char *CPP = "cpp"; +/** dotnet. */ +static constexpr const char *DOTNET = "dotnet"; +/** erlang. */ +static constexpr const char *ERLANG = "erlang"; +/** go. */ +static constexpr const char *GO = "go"; +/** java. */ +static constexpr const char *JAVA = "java"; +/** nodejs. */ +static constexpr const char *NODEJS = "nodejs"; +/** php. */ +static constexpr const char *PHP = "php"; +/** python. */ +static constexpr const char *PYTHON = "python"; +/** ruby. */ +static constexpr const char *RUBY = "ruby"; +/** webjs. */ +static constexpr const char *WEBJS = "webjs"; +/** swift. */ +static constexpr const char *SWIFT = "swift"; +} // namespace TelemetrySdkLanguageValues + +} // namespace SemanticConventions +} // namespace resource +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/resource/resource.cc b/sdk/src/resource/resource.cc index ae71aefebf..dd751bd162 100644 --- a/sdk/src/resource/resource.cc +++ b/sdk/src/resource/resource.cc @@ -3,8 +3,8 @@ #include "opentelemetry/sdk/resource/resource.h" #include "opentelemetry/nostd/span.h" -#include "opentelemetry/sdk/resource/experimental_semantic_conventions.h" #include "opentelemetry/sdk/resource/resource_detector.h" +#include "opentelemetry/sdk/resource/semantic_conventions.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -13,12 +13,6 @@ namespace sdk namespace resource { -const std::string kTelemetrySdkLanguage = "telemetry.sdk.language"; -const std::string kTelemetrySdkName = "telemetry.sdk.name"; -const std::string kTelemetrySdkVersion = "telemetry.sdk.version"; -const std::string kServiceName = "service.name"; -const std::string kProcessExecutableName = "process.executable.name"; - Resource::Resource(const ResourceAttributes &attributes, const std::string &schema_url) noexcept : attributes_(attributes), schema_url_(schema_url) {} @@ -36,17 +30,16 @@ Resource Resource::Create(const ResourceAttributes &attributes, const std::strin auto resource = Resource::GetDefault().Merge(otel_resource).Merge(Resource{attributes, schema_url}); - if (resource.attributes_.find(OTEL_GET_RESOURCE_ATTR(AttrServiceName)) == - resource.attributes_.end()) + if (resource.attributes_.find(SemanticConventions::SERVICE_NAME) == resource.attributes_.end()) { std::string default_service_name = "unknown_service"; auto it_process_executable_name = - resource.attributes_.find(OTEL_GET_RESOURCE_ATTR(AttrProcessExecutableName)); + resource.attributes_.find(SemanticConventions::PROCESS_EXECUTABLE_NAME); if (it_process_executable_name != resource.attributes_.end()) { default_service_name += ":" + nostd::get(it_process_executable_name->second); } - resource.attributes_[OTEL_GET_RESOURCE_ATTR(AttrServiceName)] = default_service_name; + resource.attributes_[SemanticConventions::SERVICE_NAME] = default_service_name; } return resource; } @@ -60,9 +53,9 @@ Resource &Resource::GetEmpty() Resource &Resource::GetDefault() { static Resource default_resource( - {{OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkLanguage), "cpp"}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkName), "opentelemetry"}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkVersion), OPENTELEMETRY_SDK_VERSION}}, + {{SemanticConventions::TELEMETRY_SDK_LANGUAGE, "cpp"}, + {SemanticConventions::TELEMETRY_SDK_NAME, "opentelemetry"}, + {SemanticConventions::TELEMETRY_SDK_VERSION, OPENTELEMETRY_SDK_VERSION}}, std::string{}); return default_resource; } diff --git a/sdk/test/resource/resource_test.cc b/sdk/test/resource/resource_test.cc index 5f058eafb1..37084432f8 100644 --- a/sdk/test/resource/resource_test.cc +++ b/sdk/test/resource/resource_test.cc @@ -5,8 +5,8 @@ #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/attribute_utils.h" -#include "opentelemetry/sdk/resource/experimental_semantic_conventions.h" #include "opentelemetry/sdk/resource/resource_detector.h" +#include "opentelemetry/sdk/resource/semantic_conventions.h" #include #include @@ -35,10 +35,10 @@ TEST(ResourceTest, create_without_servicename) {"service", "backend"}, {"version", (uint32_t)1}, {"cost", 234.23}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkLanguage), "cpp"}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkName), "opentelemetry"}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkVersion), OPENTELEMETRY_SDK_VERSION}, - {OTEL_GET_RESOURCE_ATTR(AttrServiceName), "unknown_service"}}; + {SemanticConventions::TELEMETRY_SDK_LANGUAGE, "cpp"}, + {SemanticConventions::TELEMETRY_SDK_NAME, "opentelemetry"}, + {SemanticConventions::TELEMETRY_SDK_VERSION, OPENTELEMETRY_SDK_VERSION}, + {SemanticConventions::SERVICE_NAME, "unknown_service"}}; ResourceAttributes attributes = { {"service", "backend"}, {"version", (uint32_t)1}, {"cost", 234.23}}; @@ -68,10 +68,10 @@ TEST(ResourceTest, create_with_servicename) ResourceAttributes expected_attributes = { {"version", (uint32_t)1}, {"cost", 234.23}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkLanguage), "cpp"}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkName), "opentelemetry"}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkVersion), OPENTELEMETRY_SDK_VERSION}, - {OTEL_GET_RESOURCE_ATTR(AttrServiceName), "backend"}, + {SemanticConventions::TELEMETRY_SDK_LANGUAGE, "cpp"}, + {SemanticConventions::TELEMETRY_SDK_NAME, "opentelemetry"}, + {SemanticConventions::TELEMETRY_SDK_VERSION, OPENTELEMETRY_SDK_VERSION}, + {SemanticConventions::SERVICE_NAME, "backend"}, }; ResourceAttributes attributes = { {"service.name", "backend"}, {"version", (uint32_t)1}, {"cost", 234.23}}; @@ -99,10 +99,10 @@ TEST(ResourceTest, create_with_servicename) TEST(ResourceTest, create_with_emptyatrributes) { ResourceAttributes expected_attributes = { - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkLanguage), "cpp"}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkName), "opentelemetry"}, - {OTEL_GET_RESOURCE_ATTR(AttrTelemetrySdkVersion), OPENTELEMETRY_SDK_VERSION}, - {OTEL_GET_RESOURCE_ATTR(AttrServiceName), "unknown_service"}, + {SemanticConventions::TELEMETRY_SDK_LANGUAGE, "cpp"}, + {SemanticConventions::TELEMETRY_SDK_NAME, "opentelemetry"}, + {SemanticConventions::TELEMETRY_SDK_VERSION, OPENTELEMETRY_SDK_VERSION}, + {SemanticConventions::SERVICE_NAME, "unknown_service"}, }; ResourceAttributes attributes = {}; auto resource = Resource::Create(attributes);