From 9eaa73ae1103a9c52fd0d959199bacd95ac70a6a Mon Sep 17 00:00:00 2001 From: crossoverJie Date: Tue, 2 Jul 2024 06:22:18 +0800 Subject: [PATCH] Update to semantic-conventions 1.26.0 (#73) * Update to semantic-conventions 1.26.0 * Manually remove conflicting fields * Manually remove conflicting fields * Update to semantic-conventions 1.26.0 * Update to semantic-conventions 1.26.0 * ./gradlew generateSemanticConventions spotlessApply * drop messaging.client_id --------- Co-authored-by: Liudmila Molkova --- build.gradle.kts | 8 +- .../templates/SemanticAttributes.java.j2 | 5 +- .../AndroidIncubatingAttributes.java | 4 +- .../ContainerIncubatingAttributes.java | 2 +- .../incubating/DbIncubatingAttributes.java | 193 ++++++++++++------ .../incubating/ErrorIncubatingAttributes.java | 6 +- .../incubating/EventIncubatingAttributes.java | 2 +- .../ExceptionIncubatingAttributes.java | 4 +- .../incubating/GenAiIncubatingAttributes.java | 104 ++++++++++ .../incubating/HttpIncubatingAttributes.java | 42 ++++ .../incubating/K8sIncubatingAttributes.java | 4 + .../MessageIncubatingAttributes.java | 41 ++-- .../MessagingIncubatingAttributes.java | 52 ++++- .../incubating/NetIncubatingAttributes.java | 14 ++ .../incubating/OtherIncubatingAttributes.java | 15 +- .../incubating/PoolIncubatingAttributes.java | 9 +- .../ProcessIncubatingAttributes.java | 62 +++++- .../incubating/RpcIncubatingAttributes.java | 35 ++++ .../ServiceIncubatingAttributes.java | 6 +- .../SystemIncubatingAttributes.java | 6 +- .../incubating/UrlIncubatingAttributes.java | 6 + .../semconv/ErrorAttributes.java | 6 +- .../semconv/ExceptionAttributes.java | 4 +- .../io/opentelemetry/semconv/SchemaUrls.java | 1 + .../semconv/ServiceAttributes.java | 6 +- 25 files changed, 514 insertions(+), 123 deletions(-) create mode 100644 semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/GenAiIncubatingAttributes.java diff --git a/build.gradle.kts b/build.gradle.kts index 6fde053..f182e00 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,9 +11,10 @@ val snapshot = true // end // The release version of https://github.com/open-telemetry/semantic-conventions used to generate classes -var semanticConventionsVersion = "1.25.0" +var semanticConventionsVersion = "1.26.0" val schemaUrlVersions = listOf( semanticConventionsVersion, + "1.25.0", "1.24.0", "1.23.1", "1.22.0") @@ -95,13 +96,14 @@ fun generateTask(taskName: String, incubating: Boolean) { "-v", "$projectDir/$outputDir:/output", "otel/semconvgen:$generatorVersion", "--yaml-root", "/source", - "--continue-on-validation-errors", "compatibility", + "--continue-on-validation-errors", "code", "--template", "/templates/SemanticAttributes.java.j2", "--output", "/output/{{pascal_prefix}}${classPrefix}Attributes.java", "--file-per-group", "root_namespace", // Space delimited list of root namespaces to excluded (i.e. "foo bar") - "-Dexcluded_namespaces=\"ios aspnetcore signalr\"", + "-Dexcluded_namespaces=ios aspnetcore signalr", + "-Dexcluded_attributes=messaging.client_id", "-Dfilter=${filter}", "-DclassPrefix=${classPrefix}", "-Dpkg=$packageNameArg", diff --git a/buildscripts/templates/SemanticAttributes.java.j2 b/buildscripts/templates/SemanticAttributes.java.j2 index af1e515..2e3b310 100644 --- a/buildscripts/templates/SemanticAttributes.java.j2 +++ b/buildscripts/templates/SemanticAttributes.java.j2 @@ -31,10 +31,11 @@ {%- macro stable_class_ref(const_name, separator) -%} {{stablePkg}}.{{ root_namespace | to_camelcase(True) }}Attributes{{separator}}{{const_name}} {%- endmacro %} +{%- set excluded_attributes_list = excluded_attributes.replace("\"", "").split(' ') %} {%- if filter != 'any' %} -{%- set filtered_attributes = attributes_and_templates | select(filter) | list %} +{%- set filtered_attributes = attributes_and_templates | rejectattr("fqn", "in", excluded_attributes) | select(filter) | list %} {%- else %} -{%- set filtered_attributes = attributes_and_templates | list %} +{%- set filtered_attributes = attributes_and_templates | rejectattr("fqn", "in", excluded_attributes) | list %} {%- endif %} {%- set filtered_enums = filtered_attributes | selectattr('is_enum', 'equalto', true) | list %} {%- set excluded_namespaces_list = excluded_namespaces.replace("\"", "").split(' ') %} diff --git a/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/AndroidIncubatingAttributes.java b/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/AndroidIncubatingAttributes.java index 7d94f28..adb86bb 100644 --- a/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/AndroidIncubatingAttributes.java +++ b/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/AndroidIncubatingAttributes.java @@ -22,8 +22,8 @@ public final class AndroidIncubatingAttributes { public static final AttributeKey ANDROID_OS_API_LEVEL = stringKey("android.os.api_level"); /** - * This attribute represents the state the application has transitioned into at the occurrence of - * the event. + * Deprecated use the {@code device.app.lifecycle} event definition including {@code + * android.state} as a payload field instead. * *

Notes: * diff --git a/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/ContainerIncubatingAttributes.java b/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/ContainerIncubatingAttributes.java index 7436ae3..a3b2016 100644 --- a/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/ContainerIncubatingAttributes.java +++ b/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/ContainerIncubatingAttributes.java @@ -62,7 +62,7 @@ public final class ContainerIncubatingAttributes { * endpoint. K8s defines a link to the container registry repository with digest {@code * "imageID": "registry.azurecr.io * /namespace/service/dockerfile@sha256:bdeabd40c3a8a492eaf9e8e44d0ebbb84bac7ee25ac0cf8a7159d25f62555625"}. - * The ID is assinged by the container runtime and can vary in different environments. + * The ID is assigned by the container runtime and can vary in different environments. * Consider using {@code oci.manifest.digest} if it is important to identify the same image * in different environments/runtimes. * diff --git a/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/DbIncubatingAttributes.java b/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/DbIncubatingAttributes.java index 51dec42..d6b14a2 100644 --- a/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/DbIncubatingAttributes.java +++ b/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/DbIncubatingAttributes.java @@ -49,20 +49,39 @@ public final class DbIncubatingAttributes { longKey("db.cassandra.speculative_execution_count"); /** - * The name of the primary Cassandra table that the operation is acting upon, including the - * keyspace name (if applicable). + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. + */ + @Deprecated + public static final AttributeKey DB_CASSANDRA_TABLE = stringKey("db.cassandra.table"); + + /** + * The name of the connection pool; unique within the instrumented application. In case the + * connection pool implementation doesn't provide a name, instrumentation should use a combination + * of {@code server.address} and {@code server.port} attributes formatted as {@code + * server.address:server.port}. + */ + public static final AttributeKey DB_CLIENT_CONNECTIONS_POOL_NAME = + stringKey("db.client.connections.pool.name"); + + /** The state of a connection in the pool */ + public static final AttributeKey DB_CLIENT_CONNECTIONS_STATE = + stringKey("db.client.connections.state"); + + /** + * The name of a collection (table, container) within the database. * *

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. + *
  • If the collection name is parsed from the query, it SHOULD match the value provided in + * the query and may be qualified with the schema and database name. It is RECOMMENDED to + * capture the value as provided by the application without attempting to do any case + * normalization. *
*/ - public static final AttributeKey DB_CASSANDRA_TABLE = stringKey("db.cassandra.table"); + public static final AttributeKey DB_COLLECTION_NAME = stringKey("db.collection.name"); /** * Deprecated, use {@code server.address}, {@code server.port} attributes instead. @@ -80,7 +99,12 @@ public final class DbIncubatingAttributes { public static final AttributeKey DB_COSMOSDB_CONNECTION_MODE = stringKey("db.cosmosdb.connection_mode"); - /** Cosmos DB container name. */ + /** + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. + */ + @Deprecated public static final AttributeKey DB_COSMOSDB_CONTAINER = stringKey("db.cosmosdb.container"); @@ -109,11 +133,8 @@ public final class DbIncubatingAttributes { stringKey("db.elasticsearch.cluster.name"); /** - * Deprecated, use {@code db.instance.id} instead. - * - * @deprecated Deprecated, use `db.instance.id` instead. + * Represents the human-readable identifier of the node/instance to which a request was routed. */ - @Deprecated public static final AttributeKey DB_ELASTICSEARCH_NODE_NAME = stringKey("db.elasticsearch.node.name"); @@ -134,13 +155,13 @@ public final class DbIncubatingAttributes { stringKeyTemplate("db.elasticsearch.path_parts"); /** - * An identifier (address, unique name, or any other identifier) of the database instance that is - * executing queries or mutations on the current connection. This is useful in cases where the - * database is running in a clustered environment and the instrumentation is able to record the - * node executing the query. The client may obtain this value in databases like MySQL using - * queries like {@code select @@hostname}. + * Deprecated, no general replacement at this time. For Elasticsearch, use {@code + * db.elasticsearch.node.name} instead. + * + * @deprecated Deprecated, no general replacement at this time. For Elasticsearch, use + * `db.elasticsearch.node.name` instead. */ - public static final AttributeKey DB_INSTANCE_ID = stringKey("db.instance.id"); + @Deprecated public static final AttributeKey DB_INSTANCE_ID = stringKey("db.instance.id"); /** * Removed, no replacement at this time. @@ -151,90 +172,129 @@ public final class DbIncubatingAttributes { public static final AttributeKey DB_JDBC_DRIVER_CLASSNAME = stringKey("db.jdbc.driver_classname"); - /** The MongoDB collection being accessed within the database stated in {@code db.name}. */ + /** + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. + */ + @Deprecated public static final AttributeKey DB_MONGODB_COLLECTION = stringKey("db.mongodb.collection"); /** - * The Microsoft SQL Server instance - * name connecting to. This name is used to determine the port of a named instance. + * Deprecated, SQL Server instance is now populated as a part of {@code db.namespace} attribute. + * + * @deprecated Deprecated, SQL Server instance is now populated as a part of `db.namespace` + * attribute. + */ + @Deprecated + public static final AttributeKey DB_MSSQL_INSTANCE_NAME = + stringKey("db.mssql.instance_name"); + + /** + * Deprecated, use {@code db.namespace} instead. + * + * @deprecated Deprecated, use `db.namespace` instead. + */ + @Deprecated public static final AttributeKey DB_NAME = stringKey("db.name"); + + /** + * The name of the database, fully qualified within the server address and port. * *

Notes: * *

    - *
  • If setting a {@code db.mssql.instance_name}, {@code server.port} is no longer required - * (but still recommended if non-standard). + *
  • If a database system has multiple namespace components, they SHOULD be concatenated + * (potentially using database system specific conventions) from most general to most + * specific namespace component, and more specific namespaces SHOULD NOT be captured without + * the more general namespaces, to ensure that "startswith" queries for the more + * general namespaces will be valid. Semantic conventions for individual database systems + * SHOULD document what {@code db.namespace} means in the context of that system. It is + * RECOMMENDED to capture the value as provided by the application without attempting to do + * any case normalization. *
*/ - public static final AttributeKey DB_MSSQL_INSTANCE_NAME = - stringKey("db.mssql.instance_name"); + public static final AttributeKey DB_NAMESPACE = stringKey("db.namespace"); /** - * 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). + * Deprecated, use {@code db.operation.name} instead. + * + * @deprecated Deprecated, use `db.operation.name` instead. + */ + @Deprecated public static final AttributeKey DB_OPERATION = stringKey("db.operation"); + + /** + * The name of the operation or command being executed. * *

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). + *
  • It is RECOMMENDED to capture the value as provided by the application without attempting + * to do any case normalization. *
*/ - public static final AttributeKey DB_NAME = stringKey("db.name"); + public static final AttributeKey DB_OPERATION_NAME = stringKey("db.operation.name"); /** - * The name of the operation being executed, e.g. the MongoDB command - * name such as {@code findAndModify}, or the SQL keyword. + * The query parameters used in {@code db.query.text}, with {@code } being the parameter + * name, and the attribute value being the parameter value. * *

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. + *
  • Query parameters should only be captured when {@code db.query.text} is parameterized with + * placeholders. If a parameter has no name and instead is referenced only by index, then + * {@code } SHOULD be the 0-based index. *
*/ - public static final AttributeKey DB_OPERATION = stringKey("db.operation"); + public static final AttributeKeyTemplate DB_QUERY_PARAMETER = + stringKeyTemplate("db.query.parameter"); + + /** The database query being executed. */ + public static final AttributeKey DB_QUERY_TEXT = stringKey("db.query.text"); /** - * 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. + * Deprecated, use {@code db.namespace} instead. + * + * @deprecated Deprecated, use `db.namespace` instead. */ + @Deprecated public static final AttributeKey DB_REDIS_DATABASE_INDEX = longKey("db.redis.database_index"); /** - * The name of the primary table that the operation is acting upon, including the database name - * (if applicable). + * Deprecated, use {@code db.collection.name} instead. + * + * @deprecated Deprecated, use `db.collection.name` instead. + */ + @Deprecated public static final AttributeKey DB_SQL_TABLE = stringKey("db.sql.table"); + + /** + * The database statement being executed. + * + * @deprecated The database statement being executed. + */ + @Deprecated public static final AttributeKey DB_STATEMENT = stringKey("db.statement"); + + /** + * The database management system (DBMS) product as identified by the client instrumentation. * *

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. + *
  • The actual DBMS may differ from the one identified by the client. For example, when using + * PostgreSQL client libraries to connect to a CockroachDB, the {@code db.system} is set to + * {@code postgresql} based on the instrumentation's best knowledge. *
*/ - public static final AttributeKey DB_SQL_TABLE = stringKey("db.sql.table"); - - /** The database statement being executed. */ - public static final AttributeKey DB_STATEMENT = stringKey("db.statement"); + public static final AttributeKey DB_SYSTEM = stringKey("db.system"); /** - * An identifier for the database management system (DBMS) product being used. See below for a - * list of well-known identifiers. + * Deprecated, no replacement at this time. + * + * @deprecated Deprecated, no replacement at this time. */ - public static final AttributeKey DB_SYSTEM = stringKey("db.system"); - - /** Username for accessing the database. */ - public static final AttributeKey DB_USER = stringKey("db.user"); + @Deprecated public static final AttributeKey DB_USER = stringKey("db.user"); // Enum definitions /** Values for {@link #DB_CASSANDRA_CONSISTENCY_LEVEL}. */ @@ -275,6 +335,17 @@ public static final class DbCassandraConsistencyLevelValues { private DbCassandraConsistencyLevelValues() {} } + /** Values for {@link #DB_CLIENT_CONNECTIONS_STATE}. */ + public static final class DbClientConnectionsStateValues { + /** idle. */ + public static final String IDLE = "idle"; + + /** used. */ + public static final String USED = "used"; + + private DbClientConnectionsStateValues() {} + } + /** Values for {@link #DB_COSMOSDB_CONNECTION_MODE}. */ public static final class DbCosmosdbConnectionModeValues { /** Gateway (HTTP) connections mode. */ diff --git a/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/ErrorIncubatingAttributes.java b/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/ErrorIncubatingAttributes.java index b26c46d..21ad81e 100644 --- a/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/ErrorIncubatingAttributes.java +++ b/semconv-incubating/src/main/java/io/opentelemetry/semconv/incubating/ErrorIncubatingAttributes.java @@ -20,8 +20,10 @@ public final class ErrorIncubatingAttributes { *

Notes: * *