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

Semconv 1.21 #9408

Merged
merged 20 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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
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 @@ -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 @@ -11,7 +11,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;
import java.util.HashSet;
import java.util.Set;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -42,6 +42,7 @@ private static Set<AttributeKey> buildStableDurationClientView() {
return view;
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
private static Set<AttributeKey> buildOldDurationClientView() {
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/metrics/semantic_conventions/http-metrics.md#metric-httpclientduration
Set<AttributeKey> view = new HashSet<>();
Expand All @@ -67,6 +68,7 @@ private static Set<AttributeKey> buildStableDurationServerView() {
return view;
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
private static Set<AttributeKey> buildOldDurationServerView() {
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/metrics/semantic_conventions/http-metrics.md#metric-httpserverduration
Set<AttributeKey> view = new HashSet<>();
Expand All @@ -81,6 +83,7 @@ private static Set<AttributeKey> buildOldDurationServerView() {
return view;
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
private static Set<AttributeKey> buildActiveRequestsView() {
Set<AttributeKey> view = new HashSet<>();
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/metrics/semantic_conventions/http-metrics.md#metric-httpserveractive_requests
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.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.HashSet;
import java.util.Set;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -43,6 +43,7 @@ private static Set<AttributeKey> buildAlwaysInclude() {
return view;
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
private static Set<AttributeKey> buildClientView() {
// the list of rpc client metrics attributes is from
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#attributes
Expand All @@ -55,6 +56,7 @@ private static Set<AttributeKey> buildClientView() {
return view;
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
private static Set<AttributeKey> buildServerView() {
// the list of rpc server metrics attributes is from
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#attributes
Expand All @@ -66,6 +68,7 @@ private static Set<AttributeKey> buildServerView() {
return view;
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
private static Set<AttributeKey> buildServerFallbackView() {
// the list of rpc server metrics attributes is from
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#attributes
Expand All @@ -86,6 +89,7 @@ static Attributes applyClientView(Attributes startAttributes, Attributes endAttr
return applyView(clientView, startAttributes, endAttributes);
}

@SuppressWarnings("deprecation") // until old http semconv are dropped in 2.0
static Attributes applyServerView(Attributes startAttributes, Attributes endAttributes) {
Set<AttributeKey> fullSet = serverView;
if (SemconvStability.emitOldHttpSemconv()
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 @@ -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
Loading