From 4661aee06c3ad33124d76d9fe11e3518bb84aba1 Mon Sep 17 00:00:00 2001 From: jkwatson Date: Tue, 8 Jun 2021 09:34:06 -0700 Subject: [PATCH 1/3] Update the semconv to spec v1.4.0 --- CHANGELOG.md | 4 ++ buildscripts/semantic-convention/generate.sh | 2 +- .../attributes/ResourceAttributes.java | 42 +++++++++++++++++++ .../trace/attributes/SemanticAttributes.java | 32 ++++++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf00ef2fe52..f826d2c949d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,10 @@ is published under the `io.opentelemetry.extension.noopapi` name. - The `io.opentelemetry.sdk.autoconfigure` module now supports the `OTEL_SERVICE_NAME`/`otel.service.name` environment variable/system property for configuring the SDK's `Resource` implementation. +### Semantic Conventions (alpha) +- The `SemanticAttributes` and `ResourceAttributes` classes have been updated to match the semantic conventions +as of specification release `1.4.0`. There are no breaking changes in this update, only additions. + --- ## Version 1.2.0 - 2021-05-07 diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh index 30a352895b5..094e991b1de 100755 --- a/buildscripts/semantic-convention/generate.sh +++ b/buildscripts/semantic-convention/generate.sh @@ -4,7 +4,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ROOT_DIR="${SCRIPT_DIR}/../../" # freeze the spec & generator tools versions to make SemanticAttributes generation reproducible -SPEC_VERSION=v1.3.0 +SPEC_VERSION=v1.4.0 GENERATOR_VERSION=0.3.1 cd ${SCRIPT_DIR} diff --git a/semconv/src/main/java/io/opentelemetry/semconv/resource/attributes/ResourceAttributes.java b/semconv/src/main/java/io/opentelemetry/semconv/resource/attributes/ResourceAttributes.java index f13378b5e65..15e9326964b 100644 --- a/semconv/src/main/java/io/opentelemetry/semconv/resource/attributes/ResourceAttributes.java +++ b/semconv/src/main/java/io/opentelemetry/semconv/resource/attributes/ResourceAttributes.java @@ -142,6 +142,39 @@ public final class ResourceAttributes { public static final AttributeKey DEPLOYMENT_ENVIRONMENT = stringKey("deployment.environment"); + /** + * A unique identifier representing the device. + * + *

Note: The device identifier MUST only be defined using the values outlined below. This value + * is not an advertising identifier and MUST NOT be used as such. On iOS (Swift or Objective-C), + * this value MUST be equal to the [vendor + * identifier](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor). + * On Android (Java or Kotlin), this value MUST be equal to the Firebase Installation ID or a + * globally unique UUID which is persisted across sessions in your application. More information + * can be found [here](https://developer.android.com/training/articles/user-data-ids) on best + * practices and exact implementation details. Caution should be taken when storing personal data + * or anything which can identify a user. GDPR and data protection laws may apply, ensure you do + * your own due diligence. + */ + public static final AttributeKey DEVICE_ID = stringKey("device.id"); + + /** + * The model identifier for the device. + * + *

Note: It's recommended this value represents a machine readable version of the model + * identifier rather than the market or consumer-friendly name of the device. + */ + public static final AttributeKey DEVICE_MODEL_IDENTIFIER = + stringKey("device.model.identifier"); + + /** + * The marketing name for the device model. + * + *

Note: It's recommended this value represents a human readable version of the device + * model rather than a machine readable alternative. + */ + public static final AttributeKey DEVICE_MODEL_NAME = stringKey("device.model.name"); + /** The name of the function being executed. */ public static final AttributeKey FAAS_NAME = stringKey("faas.name"); @@ -267,6 +300,15 @@ public final class ResourceAttributes { */ public static final AttributeKey OS_DESCRIPTION = stringKey("os.description"); + /** Human readable operating system name. */ + public static final AttributeKey OS_NAME = stringKey("os.name"); + + /** + * The version string of the operating system as defined in [Version + * Attributes](../../resource/semantic_conventions/README.md#version-attributes). + */ + public static final AttributeKey OS_VERSION = stringKey("os.version"); + /** Process identifier (PID). */ public static final AttributeKey PROCESS_PID = longKey("process.pid"); diff --git a/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/SemanticAttributes.java b/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/SemanticAttributes.java index c844ec3ee6f..af9fc3da51f 100644 --- a/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/SemanticAttributes.java +++ b/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/SemanticAttributes.java @@ -638,6 +638,34 @@ public final class SemanticAttributes { */ public static final AttributeKey RPC_GRPC_STATUS_CODE = longKey("rpc.grpc.status_code"); + /** + * Protocol version as in `jsonrpc` property of request/response. Since JSON-RPC 1.0 does not + * specify this, the value can be omitted. + */ + public static final AttributeKey RPC_JSONRPC_VERSION = stringKey("rpc.jsonrpc.version"); + + /** + * `method` property from request. Unlike `rpc.method`, this may not relate to the actual method + * being called. Useful for client-side traces since client does not know what will be called on + * the server. + */ + public static final AttributeKey RPC_JSONRPC_METHOD = stringKey("rpc.jsonrpc.method"); + + /** + * `id` property of request or response. Since protocol allows id to be int, string, `null` or + * missing (for notifications), value is expected to be cast to string for simplicity. Use empty + * string in case of `null` value. Omit entirely if this is a notification. + */ + public static final AttributeKey RPC_JSONRPC_REQUEST_ID = + stringKey("rpc.jsonrpc.request_id"); + + /** `error.code` property of response if it is an error response. */ + public static final AttributeKey RPC_JSONRPC_ERROR_CODE = longKey("rpc.jsonrpc.error_code"); + + /** `error.message` property of response if it is an error response. */ + public static final AttributeKey RPC_JSONRPC_ERROR_MESSAGE = + stringKey("rpc.jsonrpc.error_message"); + // Enum definitions public static final class DbSystemValues { /** Some other SQL database. Fallback only. See notes. */ @@ -730,6 +758,10 @@ public static final class DbSystemValues { public static final String GEODE = "geode"; /** Elasticsearch. */ public static final String ELASTICSEARCH = "elasticsearch"; + /** Memcached. */ + public static final String MEMCACHED = "memcached"; + /** CockroachDB. */ + public static final String COCKROACHDB = "cockroachdb"; private DbSystemValues() {} } From 1b872b06a1c7c19f1470b0bf020a75e8b31a6af8 Mon Sep 17 00:00:00 2001 From: jkwatson Date: Wed, 9 Jun 2021 09:53:12 -0700 Subject: [PATCH 2/3] Add the schema URL to the generated files. --- buildscripts/semantic-convention/generate.sh | 6 +++++- .../templates/SemanticAttributes.java.j2 | 4 ++++ .../semconv/resource/attributes/ResourceAttributes.java | 2 ++ .../semconv/trace/attributes/SemanticAttributes.java | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh index 094e991b1de..17703174670 100755 --- a/buildscripts/semantic-convention/generate.sh +++ b/buildscripts/semantic-convention/generate.sh @@ -4,7 +4,9 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ROOT_DIR="${SCRIPT_DIR}/../../" # freeze the spec & generator tools versions to make SemanticAttributes generation reproducible -SPEC_VERSION=v1.4.0 +SEMCONV_VERSION=1.4.0 +SPEC_VERSION=v$SEMCONV_VERSION +SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION GENERATOR_VERSION=0.3.1 cd ${SCRIPT_DIR} @@ -28,6 +30,7 @@ docker run --rm \ --template /templates/SemanticAttributes.java.j2 \ --output /output/SemanticAttributes.java \ -Dclass=SemanticAttributes \ + -DschemaUrl=$SCHEMA_URL \ -Dpkg=io.opentelemetry.semconv.trace.attributes docker run --rm \ @@ -39,6 +42,7 @@ docker run --rm \ --template /templates/SemanticAttributes.java.j2 \ --output /output/ResourceAttributes.java \ -Dclass=ResourceAttributes \ + -DschemaUrl=$SCHEMA_URL \ -Dpkg=io.opentelemetry.semconv.resource.attributes cd "$ROOT_DIR" diff --git a/buildscripts/semantic-convention/templates/SemanticAttributes.java.j2 b/buildscripts/semantic-convention/templates/SemanticAttributes.java.j2 index e2834f3917e..c38adbc3a26 100644 --- a/buildscripts/semantic-convention/templates/SemanticAttributes.java.j2 +++ b/buildscripts/semantic-convention/templates/SemanticAttributes.java.j2 @@ -57,6 +57,10 @@ import java.util.List; // DO NOT EDIT, this is an Auto-generated file from buildscripts/semantic-convention{{template}} public final class {{class}} { + /** + * The URL of the OpenTelemetry schema for these keys and values. + */ + public static final String SCHEMA_URL = "{{schemaUrl}}"; {%- for attribute in attributes if attribute.is_local and not attribute.ref %} /** diff --git a/semconv/src/main/java/io/opentelemetry/semconv/resource/attributes/ResourceAttributes.java b/semconv/src/main/java/io/opentelemetry/semconv/resource/attributes/ResourceAttributes.java index 15e9326964b..74133d002f2 100644 --- a/semconv/src/main/java/io/opentelemetry/semconv/resource/attributes/ResourceAttributes.java +++ b/semconv/src/main/java/io/opentelemetry/semconv/resource/attributes/ResourceAttributes.java @@ -15,6 +15,8 @@ // DO NOT EDIT, this is an Auto-generated file from // buildscripts/semantic-convention/templates/SemanticAttributes.java.j2 public final class ResourceAttributes { + /** The URL of the OpenTelemetry schema for these keys and values. */ + public static final String SCHEMA_URL = "https://opentelemetry.io/schemas/1.4.0"; /** Name of the cloud provider. */ public static final AttributeKey CLOUD_PROVIDER = stringKey("cloud.provider"); diff --git a/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/SemanticAttributes.java b/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/SemanticAttributes.java index af9fc3da51f..fef5cf5bb70 100644 --- a/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/SemanticAttributes.java +++ b/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/SemanticAttributes.java @@ -17,6 +17,8 @@ // DO NOT EDIT, this is an Auto-generated file from // buildscripts/semantic-convention/templates/SemanticAttributes.java.j2 public final class SemanticAttributes { + /** The URL of the OpenTelemetry schema for these keys and values. */ + public static final String SCHEMA_URL = "https://opentelemetry.io/schemas/1.4.0"; /** * An identifier for the database management system (DBMS) product being used. See below for a From 617da9e30e229a0e7fc88feb04dbda672a467e9c Mon Sep 17 00:00:00 2001 From: jkwatson Date: Wed, 9 Jun 2021 10:03:29 -0700 Subject: [PATCH 3/3] amend the CHANGELOG.md entry to add the schema url addition --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f826d2c949d..5b4c05e88ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,8 @@ environment variable/system property for configuring the SDK's `Resource` implem ### Semantic Conventions (alpha) - The `SemanticAttributes` and `ResourceAttributes` classes have been updated to match the semantic conventions -as of specification release `1.4.0`. There are no breaking changes in this update, only additions. +as of specification release `1.4.0`. These classes also now expose a `SCHEMA_URL` field which points at the +version of the OpenTelemetry schema the files were generated from. There are no breaking changes in this update, only additions. ---