Skip to content

Commit

Permalink
Semconv 1.21 (#9408)
Browse files Browse the repository at this point in the history
Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
  • Loading branch information
trask and laurit committed Sep 13, 2023
1 parent 1ad203a commit 3b77cc4
Show file tree
Hide file tree
Showing 395 changed files with 806 additions and 811 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ plugins {
val latestReleasedVersion: String by lazy {
// hack to find the current released version of the project
val temp: Configuration = configurations.create("tempConfig")
// pick the agent, since it's always there.
dependencies.add(temp.name, "io.opentelemetry.javaagent:opentelemetry-javaagent:latest.release")
// pick the bom, since we don't use dependency substitution on it.
dependencies.add(temp.name, "io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:latest.release")
val moduleVersion = configurations["tempConfig"].resolvedConfiguration.firstLevelModuleDependencies.elementAt(0).moduleVersion

configurations.remove(temp)
Expand Down
7 changes: 1 addition & 6 deletions conventions/src/main/kotlin/otel.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ configurations.configureEach {
substitute(module("io.opentelemetry.javaagent:opentelemetry-agent-for-testing")).using(project(":testing:agent-for-testing"))
substitute(module("io.opentelemetry.javaagent:opentelemetry-testing-common")).using(project(":testing-common"))
substitute(module("io.opentelemetry.javaagent:opentelemetry-muzzle")).using(project(":muzzle"))
substitute(module("io.opentelemetry.javaagent:opentelemetry-javaagent")).using(project(":javaagent"))
}

// The above substitutions ensure dependencies managed by this BOM for external projects refer to this repo's projects here.
Expand All @@ -420,9 +421,3 @@ configurations.configureEach {
exclude("io.opentelemetry.instrumentation", "opentelemetry-instrumentation-bom-alpha")
}
}

// Pin opentelemetry-semconv to last version where io.opentelemetry.semconv.trace.attributes.SemanticAttributes
// isn't deprecated.
configurations.configureEach {
resolutionStrategy.force("io.opentelemetry:opentelemetry-semconv:1.29.0-alpha")
}
1 change: 1 addition & 0 deletions dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ val mockitoVersion = "4.11.0"
val slf4jVersion = "2.0.9"

val CORE_DEPENDENCIES = listOf(
"io.opentelemetry.semconv:opentelemetry-semconv:1.21.0-alpha",
"com.google.auto.service:auto-service:${autoServiceVersion}",
"com.google.auto.service:auto-service-annotations:${autoServiceVersion}",
"com.google.auto.value:auto-value:${autoValueVersion}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import static io.opentelemetry.api.common.AttributeKey.booleanKey;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.CODE_FUNCTION;
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.CODE_NAMESPACE;
import static io.opentelemetry.semconv.SemanticAttributes.CODE_FUNCTION;
import static io.opentelemetry.semconv.SemanticAttributes.CODE_NAMESPACE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;

Expand Down
2 changes: 1 addition & 1 deletion instrumentation-annotations-support/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
implementation(project(":instrumentation-api"))

api("io.opentelemetry:opentelemetry-api")
api("io.opentelemetry:opentelemetry-semconv")
api("io.opentelemetry.semconv:opentelemetry-semconv")

compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")
Expand Down
2 changes: 1 addition & 1 deletion instrumentation-api-semconv/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
group = "io.opentelemetry.instrumentation"

dependencies {
api("io.opentelemetry:opentelemetry-semconv")
api("io.opentelemetry.semconv:opentelemetry-semconv")
api(project(":instrumentation-api"))
implementation("io.opentelemetry:opentelemetry-extension-incubator")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import javax.annotation.Nullable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;

/**
* Extractor of <a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.internal.SpanKey;
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import javax.annotation.Nullable;

abstract class DbClientCommonAttributesExtractor<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import io.opentelemetry.instrumentation.api.db.SqlStatementInfo;
import io.opentelemetry.instrumentation.api.db.SqlStatementSanitizer;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;

/**
* Extractor of <a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.instrumentation.api.db.SqlStatementSanitizer;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;

/** A builder of {@link SqlClientAttributesExtractor}. */
public final class SqlClientAttributesExtractorBuilder<REQUEST, RESPONSE> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.instrumentation.api.internal.SpanKey;
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.function.ToIntFunction;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -101,6 +101,7 @@ public static <REQUEST, RESPONSE> HttpClientAttributesExtractorBuilder<REQUEST,
}

@Override
@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
super.onStart(attributes, parentContext, request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -48,6 +48,7 @@ abstract class HttpCommonAttributesExtractor<
}

@Override
@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
String method = getter.getHttpRequestMethod(request);
if (SemconvStability.emitStableHttpSemconv()) {
Expand All @@ -72,6 +73,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST
}

@Override
@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
public void onEnd(
AttributesBuilder attributes,
Context context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import javax.annotation.Nullable;

final class HttpMessageBodySizeUtil {

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
private static final AttributeKey<Long> HTTP_REQUEST_BODY_SIZE =
SemconvStability.emitOldHttpSemconv()
? SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH
: HttpAttributes.HTTP_REQUEST_BODY_SIZE;

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
private static final AttributeKey<Long> HTTP_RESPONSE_BODY_SIZE =
SemconvStability.emitOldHttpSemconv()
? SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.http.internal.HttpAttributes;
import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes;
import io.opentelemetry.instrumentation.api.instrumenter.url.internal.UrlAttributes;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;

final class HttpMetricsAdvice {

Expand All @@ -38,6 +38,7 @@ static void applyStableClientDurationAdvice(DoubleHistogramBuilder builder) {
NetworkAttributes.SERVER_SOCKET_ADDRESS)));
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
static void applyOldClientDurationAdvice(DoubleHistogramBuilder builder) {
if (!(builder instanceof ExtendedDoubleHistogramBuilder)) {
return;
Expand All @@ -56,6 +57,7 @@ static void applyOldClientDurationAdvice(DoubleHistogramBuilder builder) {
SemanticAttributes.NET_SOCK_PEER_ADDR)));
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
static void applyClientRequestSizeAdvice(LongHistogramBuilder builder) {
if (!(builder instanceof ExtendedLongHistogramBuilder)) {
return;
Expand Down Expand Up @@ -100,6 +102,7 @@ static void applyStableServerDurationAdvice(DoubleHistogramBuilder builder) {
UrlAttributes.URL_SCHEME)));
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
static void applyOldServerDurationAdvice(DoubleHistogramBuilder builder) {
if (!(builder instanceof ExtendedDoubleHistogramBuilder)) {
return;
Expand All @@ -119,6 +122,7 @@ static void applyOldServerDurationAdvice(DoubleHistogramBuilder builder) {
SemanticAttributes.NET_PROTOCOL_VERSION)));
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
static void applyServerRequestSizeAdvice(LongHistogramBuilder builder) {
if (!(builder instanceof ExtendedLongHistogramBuilder)) {
return;
Expand Down Expand Up @@ -146,6 +150,7 @@ static void applyServerRequestSizeAdvice(LongHistogramBuilder builder) {
SemanticAttributes.NET_PROTOCOL_VERSION)));
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
static void applyServerActiveRequestsAdvice(LongUpDownCounterBuilder builder) {
if (!(builder instanceof ExtendedLongUpDownCounterBuilder)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.url.internal.InternalUrlAttributesExtractor;
import io.opentelemetry.instrumentation.api.internal.SpanKey;
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.function.Function;
import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.LocalRootSpan;
import io.opentelemetry.instrumentation.api.internal.HttpRouteState;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import javax.annotation.Nullable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.internal.SpanKey;
import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.List;
import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.Map;
import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.network.internal.AddressAndPort;
import io.opentelemetry.instrumentation.api.instrumenter.network.internal.FallbackAddressPortExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import javax.annotation.Nullable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.network.internal.AddressAndPort;
import io.opentelemetry.instrumentation.api.instrumenter.network.internal.FallbackAddressPortExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.network.ClientAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import javax.annotation.Nullable;

/**
Expand All @@ -34,6 +34,7 @@ public InternalClientAttributesExtractor(
this.emitOldHttpAttributes = emitOldHttpAttributes;
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
public void onStart(AttributesBuilder attributes, REQUEST request) {
AddressAndPort clientAddressAndPort = extractClientAddressAndPort(request);

Expand All @@ -48,6 +49,7 @@ public void onStart(AttributesBuilder attributes, REQUEST request) {
}
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPONSE response) {
AddressAndPort clientAddressAndPort = extractClientAddressAndPort(request);
String clientSocketAddress = getter.getClientSocketAddress(request, response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.Locale;
import javax.annotation.Nullable;

Expand All @@ -35,6 +35,7 @@ public InternalNetworkAttributesExtractor(
this.emitOldHttpAttributes = emitOldHttpAttributes;
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPONSE response) {
String protocolName = lowercase(getter.getNetworkProtocolName(request, response));
String protocolVersion = lowercase(getter.getNetworkProtocolVersion(request, response));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.function.BiPredicate;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -117,7 +117,10 @@ private AddressAndPort extractServerAddressAndPort(REQUEST request) {
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
@SuppressWarnings("ImmutableEnumChecker")
@SuppressWarnings({
"ImmutableEnumChecker",
"deprecation"
}) // until old http semconv are dropped in 2.0
public enum Mode {
PEER(
SemanticAttributes.NET_PEER_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import javax.annotation.Nullable;

abstract class RpcCommonAttributesExtractor<REQUEST, RESPONSE>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
import io.opentelemetry.extension.incubator.metrics.ExtendedDoubleHistogramBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.network.internal.NetworkAttributes;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.ArrayList;
import java.util.List;

final class RpcMetricsAdvice {

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
static void applyClientDurationAdvice(DoubleHistogramBuilder builder) {
if (!(builder instanceof ExtendedDoubleHistogramBuilder)) {
return;
Expand Down Expand Up @@ -47,6 +48,7 @@ static void applyClientDurationAdvice(DoubleHistogramBuilder builder) {
.setAdvice(advice -> advice.setAttributes(attributes));
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
static void applyServerDurationAdvice(DoubleHistogramBuilder builder) {
if (!(builder instanceof ExtendedDoubleHistogramBuilder)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.url.UrlAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.function.Function;
import javax.annotation.Nullable;

Expand All @@ -35,6 +35,7 @@ public InternalUrlAttributesExtractor(
this.emitOldHttpAttributes = emitOldHttpAttributes;
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
public void onStart(AttributesBuilder attributes, REQUEST request) {
String urlScheme = getUrlScheme(request);
String urlPath = getter.getUrlPath(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import io.opentelemetry.semconv.SemanticAttributes;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down
Loading

0 comments on commit 3b77cc4

Please sign in to comment.