Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the semconv to spec v1.4.0 #3298

Merged
merged 4 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased:

### Semantic Conventions (alpha)
- The `SemanticAttributes` and `ResourceAttributes` classes have been updated to match the semantic conventions
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.

---
## Version 1.3.0 - 2021-06-09

Expand Down
6 changes: 5 additions & 1 deletion buildscripts/semantic-convention/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.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}
Expand All @@ -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 \
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> CLOUD_PROVIDER = stringKey("cloud.provider");
Expand Down Expand Up @@ -142,6 +144,39 @@ public final class ResourceAttributes {
public static final AttributeKey<String> DEPLOYMENT_ENVIRONMENT =
stringKey("deployment.environment");

/**
* A unique identifier representing the device.
*
* <p>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<String> DEVICE_ID = stringKey("device.id");

/**
* The model identifier for the device.
*
* <p>Note: It&#39;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<String> DEVICE_MODEL_IDENTIFIER =
stringKey("device.model.identifier");

/**
* The marketing name for the device model.
*
* <p>Note: It&#39;s recommended this value represents a human readable version of the device
* model rather than a machine readable alternative.
*/
public static final AttributeKey<String> DEVICE_MODEL_NAME = stringKey("device.model.name");

/** The name of the function being executed. */
public static final AttributeKey<String> FAAS_NAME = stringKey("faas.name");

Expand Down Expand Up @@ -267,6 +302,15 @@ public final class ResourceAttributes {
*/
public static final AttributeKey<String> OS_DESCRIPTION = stringKey("os.description");

/** Human readable operating system name. */
public static final AttributeKey<String> 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<String> OS_VERSION = stringKey("os.version");

/** Process identifier (PID). */
public static final AttributeKey<Long> PROCESS_PID = longKey("process.pid");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -638,6 +640,34 @@ public final class SemanticAttributes {
*/
public static final AttributeKey<Long> 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<String> 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<String> RPC_JSONRPC_METHOD = stringKey("rpc.jsonrpc.method");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That new attribute is a bit unfortunate, I opened a spec PR: open-telemetry/opentelemetry-specification#1748 to remove it / clarify that rpc.method can be used instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Oberon00 do you think we should just wait for that to settle before merging this, then?

Copy link
Member

@Oberon00 Oberon00 Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it's better to have this one potentially bad attribute than not to update at all. The module is alpha anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just cut the 1.3.0 release, so we'll get what we get in the next version. :)


/**
* `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<String> RPC_JSONRPC_REQUEST_ID =
stringKey("rpc.jsonrpc.request_id");

/** `error.code` property of response if it is an error response. */
public static final AttributeKey<Long> RPC_JSONRPC_ERROR_CODE = longKey("rpc.jsonrpc.error_code");

/** `error.message` property of response if it is an error response. */
public static final AttributeKey<String> RPC_JSONRPC_ERROR_MESSAGE =
stringKey("rpc.jsonrpc.error_message");

// Enum definitions
public static final class DbSystemValues {
/** Some other SQL database. Fallback only. See notes. */
Expand Down Expand Up @@ -730,6 +760,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() {}
}
Expand Down