Skip to content

Commit

Permalink
Update semconv to 1.19.0 and related build tool changes (#5311)
Browse files Browse the repository at this point in the history
* Generate semconv 1.19.0 with new build-tools

* update code to use new user agentattribute name

* changelog

* add deprecated attributes

* add old deprecated attributes

* cleanup
  • Loading branch information
lmolkova committed Mar 30, 2023
1 parent 0b6a6b9 commit 188210b
Show file tree
Hide file tree
Showing 7 changed files with 394 additions and 139 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
* Fix case of bug label in open issue workflow
([#5268](https://github.com/open-telemetry/opentelemetry-java/pull/5268))

### Semantic Conventions

* Update semconv to 1.19.0
([#5311](https://github.com/open-telemetry/opentelemetry-java/pull/5311))

## Version 1.23.1 (2023-02-15)

* Fix bug that broke `AutoConfiguredOpenTelemetrySdk`'s shutdown hook.
Expand Down
9 changes: 5 additions & 4 deletions buildscripts/semantic-convention/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ 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.18.0
SEMCONV_VERSION=1.19.0
SPEC_VERSION=v$SEMCONV_VERSION
SCHEMA_URL=https://opentelemetry.io/schemas/$SEMCONV_VERSION
GENERATOR_VERSION=0.14.0
GENERATOR_VERSION=0.18.0

cd ${SCRIPT_DIR}

Expand All @@ -26,7 +26,7 @@ docker run --rm \
-v ${SCRIPT_DIR}/templates:/templates \
-v ${ROOT_DIR}/semconv/src/main/java/io/opentelemetry/semconv/trace/attributes/:/output \
otel/semconvgen:$GENERATOR_VERSION \
--exclude resource/** \
--only span,event,attribute_group,scope \
-f /source code \
--template /templates/SemanticAttributes.java.j2 \
--output /output/SemanticAttributes.java \
Expand All @@ -36,10 +36,11 @@ docker run --rm \
-Dpkg=io.opentelemetry.semconv.trace.attributes

docker run --rm \
-v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions/resource:/source \
-v ${SCRIPT_DIR}/opentelemetry-specification/semantic_conventions:/source \
-v ${SCRIPT_DIR}/templates:/templates \
-v ${ROOT_DIR}/semconv/src/main/java/io/opentelemetry/semconv/resource/attributes/:/output \
otel/semconvgen:$GENERATOR_VERSION \
--only resource \
-f /source code \
--template /templates/SemanticAttributes.java.j2 \
--output /output/ResourceAttributes.java \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,53 @@ public final class {{class}} {
public static final AttributeKey<Long> MESSAGING_ROCKETMQ_DELAY_TIME_LEVEL =
longKey("messaging.rocketmq.delay_time_level");

/**
* The name of the instrumentation scope - ({@code InstrumentationScope.Name} in OTLP).
* @deprecated This item has been moved, use {@link io.opentelemetry.semconv.resource.attributes.ResourceAttributes#OTEL_SCOPE_NAME} instead.
*/
@Deprecated
public static final AttributeKey<String> OTEL_SCOPE_NAME = stringKey("otel.scope.name");

/**
* The version of the instrumentation scope - ({@code InstrumentationScope.Version} in OTLP).
* @deprecated This item has been moved, use {@link io.opentelemetry.semconv.resource.attributes.ResourceAttributes#OTEL_SCOPE_VERSION} instead.
*/
@Deprecated
public static final AttributeKey<String> OTEL_SCOPE_VERSION = stringKey("otel.scope.version");;

/**
* The execution ID of the current function execution.
* @deprecated This item has been renamed in 1.19.0 version of the semantic conventions.
* Use {@link SemanticAttributes#FAAS_INVOCATION_ID} instead.
*/
@Deprecated
public static final AttributeKey<String> FAAS_EXECUTION = stringKey("faas.execution");

/**
* Value of the <a href="https://www.rfc-editor.org/rfc/rfc9110.html#field.user-agent">HTTP
* User-Agent</a> header sent by the client.
* @deprecated This item has been renamed in 1.19.0 version of the semantic conventions.
* Use {@link SemanticAttributes#USER_AGENT_ORIGINAL} instead.
*/
@Deprecated
public static final AttributeKey<String> HTTP_USER_AGENT = stringKey("http.user_agent");

/**
* Deprecated.
*
* @deprecated Deprecated, use the {@link io.opentelemetry.semconv.resource.attributes.ResourceAttributes#OTEL_SCOPE_NAME} attribute.
*/
@Deprecated
public static final AttributeKey<String> OTEL_LIBRARY_NAME = stringKey("otel.library.name");

/**
* Deprecated.
*
* @deprecated Deprecated, use the {@link io.opentelemetry.semconv.resource.attributes.ResourceAttributes#OTEL_SCOPE_VERSION} attribute.
*/
@Deprecated
public static final AttributeKey<String> OTEL_LIBRARY_VERSION = stringKey("otel.library.version");

{% endif %}

{%- if class == "ResourceAttributes" %}
Expand All @@ -285,6 +332,51 @@ public final class {{class}} {
@Deprecated
public static final String GCP_OPENSHIFT = "gcp_openshift";

/**
* Full user-agent string provided by the browser
*
* <p>Notes:
*
* <ul>
* <li>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.
* </ul>
* @deprecated This item has been renamed in 1.19.0 version of the semantic conventions. Use {@link io.opentelemetry.semconv.trace.attributes.SemanticAttributes#USER_AGENT_ORIGINAL} instead.
*/
@Deprecated
public static final AttributeKey<String> BROWSER_USER_AGENT = stringKey("browser.user_agent");

/**
* The unique ID of the single function that this runtime instance executes.
*
* <p>Notes:
*
* <ul>
* <li>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.
* <li>The exact value to use for {@code faas.id} depends on the cloud provider:
* <li><strong>AWS Lambda:</strong> The function <a
* href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">ARN</a>.
* Take care not to use the &quot;invoked ARN&quot; directly but replace any <a
* href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html">alias
* suffix</a> with the resolved function version, as the same runtime instance may be
* invokable with multiple different aliases.
* <li><strong>GCP:</strong> The <a
* href="https://cloud.google.com/iam/docs/full-resource-names">URI of the resource</a>
* <li><strong>Azure:</strong> The <a
* href="https://docs.microsoft.com/en-us/rest/api/resources/resources/get-by-id">Fully
* Qualified Resource ID</a> of the invoked function, <em>not</em> the function app, having
* the form {@code
* /subscriptions/<SUBSCIPTION_GUID>/resourceGroups/<RG>/providers/Microsoft.Web/sites/<FUNCAPP>/functions/<FUNC>}.
* This means that a span attribute MUST be used, as an Azure function app can host multiple
* functions that would usually share a TracerProvider.
* </ul>
* @deprecated This item has been removed in 1.19.0 version of the semantic conventions. Use {@link ResourceAttributes#CLOUD_RESOURCE_ID} instead.
*/
@Deprecated
public static final AttributeKey<String> FAAS_ID = stringKey("faas.id");

{% endif %}

private {{class}}() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* // SpanDataWithClientType(SpanData delegate) {
* // super(delegate);
* // String clientType = ClientConfig.parseUserAgent(
* // delegate.getAttributes().get(SemanticAttributes.HTTP_USER_AGENT).getStringValue());
* // delegate.getAttributes().get(SemanticAttributes.USER_AGENT_ORIGINAL).getStringValue());
* // Attributes.Builder newAttributes = Attributes.builder(delegate.getAttributes());
* // newAttributes.setAttribute("client_type", clientType);
* // attributes = newAttributes.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static final class SpanDataWithClientType extends DelegatingSpanData {
private SpanDataWithClientType(SpanData delegate) {
super(delegate);
String clientType;
String userAgent = delegate.getAttributes().get(SemanticAttributes.HTTP_USER_AGENT);
String userAgent = delegate.getAttributes().get(SemanticAttributes.USER_AGENT_ORIGINAL);
if (userAgent != null) {
clientType = parseUserAgent(userAgent);
} else {
Expand Down
Loading

0 comments on commit 188210b

Please sign in to comment.