Skip to content

Commit bf6dbe7

Browse files
authored
Merge 81fee1d into 07e1216
2 parents 07e1216 + 81fee1d commit bf6dbe7

File tree

9 files changed

+38
-28
lines changed

9 files changed

+38
-28
lines changed

buildSrc/src/main/java/Config.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,15 @@ object Config {
151151
val apolloKotlin = "com.apollographql.apollo3:apollo-runtime:3.8.2"
152152

153153
object OpenTelemetry {
154-
val otelVersion = "1.39.0"
154+
val otelVersion = "1.41.0"
155155
val otelAlphaVersion = "$otelVersion-alpha"
156-
val otelJavaagentVersion = "2.5.0"
156+
val otelJavaagentVersion = "2.7.0"
157157
val otelJavaagentAlphaVersion = "$otelJavaagentVersion-alpha"
158-
val otelSemanticConvetionsVersion = "1.23.1-alpha"
158+
val otelSemanticConvetionsVersion = "1.25.0-alpha" // check https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/dependencyManagement/build.gradle.kts#L49 for release version above to find a compatible version
159159

160160
val otelSdk = "io.opentelemetry:opentelemetry-sdk:$otelVersion"
161161
val otelSemconv = "io.opentelemetry.semconv:opentelemetry-semconv:$otelSemanticConvetionsVersion"
162+
val otelSemconvIncubating = "io.opentelemetry.semconv:opentelemetry-semconv-incubating:$otelSemanticConvetionsVersion"
162163
val otelJavaAgent = "io.opentelemetry.javaagent:opentelemetry-javaagent:$otelJavaagentVersion"
163164
val otelJavaAgentExtensionApi = "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api:$otelJavaagentAlphaVersion"
164165
val otelJavaAgentTooling = "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:$otelJavaagentAlphaVersion"

sentry-opentelemetry/sentry-opentelemetry-bootstrap/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ dependencies {
3838

3939
testImplementation(Config.Libs.OpenTelemetry.otelSdk)
4040
testImplementation(Config.Libs.OpenTelemetry.otelSemconv)
41+
testImplementation(Config.Libs.OpenTelemetry.otelSemconvIncubating)
4142
}
4243

4344
configure<SourceSetContainer> {

sentry-opentelemetry/sentry-opentelemetry-core/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies {
2626

2727
implementation(Config.Libs.OpenTelemetry.otelSdk)
2828
compileOnly(Config.Libs.OpenTelemetry.otelSemconv)
29+
compileOnly(Config.Libs.OpenTelemetry.otelSemconvIncubating)
2930

3031
compileOnly(Config.CompileOnly.nopen)
3132
errorprone(Config.CompileOnly.nopenChecker)
@@ -44,6 +45,7 @@ dependencies {
4445

4546
testImplementation(Config.Libs.OpenTelemetry.otelSdk)
4647
testImplementation(Config.Libs.OpenTelemetry.otelSemconv)
48+
testImplementation(Config.Libs.OpenTelemetry.otelSemconvIncubating)
4749
}
4850

4951
configure<SourceSetContainer> {

sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry/OtelInternalSpanDetectionUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import io.opentelemetry.api.common.Attributes;
44
import io.opentelemetry.api.trace.SpanKind;
5-
import io.opentelemetry.semconv.SemanticAttributes;
5+
import io.opentelemetry.semconv.UrlAttributes;
66
import io.sentry.DsnUtil;
77
import io.sentry.IScopes;
88
import java.util.Arrays;
@@ -27,12 +27,13 @@ public static boolean isSentryRequest(
2727
return false;
2828
}
2929

30-
final @Nullable String httpUrl = attributes.get(SemanticAttributes.HTTP_URL);
30+
final @Nullable String httpUrl =
31+
attributes.get(io.opentelemetry.semconv.SemanticAttributes.HTTP_URL);
3132
if (DsnUtil.urlContainsDsnHost(scopes.getOptions(), httpUrl)) {
3233
return true;
3334
}
3435

35-
final @Nullable String fullUrl = attributes.get(SemanticAttributes.URL_FULL);
36+
final @Nullable String fullUrl = attributes.get(UrlAttributes.URL_FULL);
3637
if (DsnUtil.urlContainsDsnHost(scopes.getOptions(), fullUrl)) {
3738
return true;
3839
}

sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry/SentrySpanExporter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import io.opentelemetry.sdk.trace.data.SpanData;
1111
import io.opentelemetry.sdk.trace.data.StatusData;
1212
import io.opentelemetry.sdk.trace.export.SpanExporter;
13-
import io.opentelemetry.semconv.ResourceAttributes;
14-
import io.opentelemetry.semconv.SemanticAttributes;
13+
import io.opentelemetry.semconv.HttpAttributes;
14+
import io.opentelemetry.semconv.incubating.ProcessIncubatingAttributes;
1515
import io.sentry.Baggage;
1616
import io.sentry.DateUtils;
1717
import io.sentry.DefaultSpanFactory;
@@ -63,7 +63,7 @@ public final class SentrySpanExporter implements SpanExporter {
6363
InternalSemanticAttributes.PROFILE_SAMPLED.getKey(),
6464
InternalSemanticAttributes.PROFILE_SAMPLE_RATE.getKey(),
6565
InternalSemanticAttributes.PARENT_SAMPLED.getKey(),
66-
ResourceAttributes.PROCESS_COMMAND_ARGS.getKey() // can be very long
66+
ProcessIncubatingAttributes.PROCESS_COMMAND_ARGS.getKey() // can be very long
6767
);
6868
private static final @NotNull Long SPAN_TIMEOUT = DateUtils.secondsToNanos(5 * 60);
6969

@@ -455,7 +455,7 @@ private SpanStatus mapOtelStatus(
455455
}
456456

457457
final @Nullable Long httpStatus =
458-
otelSpanData.getAttributes().get(SemanticAttributes.HTTP_STATUS_CODE);
458+
otelSpanData.getAttributes().get(HttpAttributes.HTTP_RESPONSE_STATUS_CODE);
459459
if (httpStatus != null) {
460460
final @Nullable SpanStatus spanStatus = SpanStatus.fromHttpStatusCode(httpStatus.intValue());
461461
if (spanStatus != null) {

sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry/SentrySpanProcessor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
import io.opentelemetry.sdk.trace.SpanProcessor;
1313
import io.opentelemetry.sdk.trace.data.SpanData;
1414
import io.opentelemetry.sdk.trace.data.StatusData;
15-
import io.opentelemetry.semconv.SemanticAttributes;
15+
import io.opentelemetry.semconv.HttpAttributes;
16+
import io.opentelemetry.semconv.UrlAttributes;
1617
import io.sentry.Baggage;
1718
import io.sentry.DsnUtil;
1819
import io.sentry.IScopes;
@@ -261,7 +262,7 @@ private boolean isSentryRequest(final @NotNull ReadableSpan otelSpan) {
261262
return false;
262263
}
263264

264-
final @Nullable String httpUrl = otelSpan.getAttribute(SemanticAttributes.HTTP_URL);
265+
final @Nullable String httpUrl = otelSpan.getAttribute(UrlAttributes.URL_FULL);
265266
return DsnUtil.urlContainsDsnHost(scopes.getOptions(), httpUrl);
266267
}
267268

@@ -345,7 +346,8 @@ private SpanStatus mapOtelStatus(final @NotNull ReadableSpan otelSpan) {
345346
return SpanStatus.OK;
346347
}
347348

348-
final @Nullable Long httpStatus = otelSpan.getAttribute(SemanticAttributes.HTTP_STATUS_CODE);
349+
final @Nullable Long httpStatus =
350+
otelSpan.getAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE);
349351
if (httpStatus != null) {
350352
final @Nullable SpanStatus spanStatus = SpanStatus.fromHttpStatusCode(httpStatus.intValue());
351353
if (spanStatus != null) {

sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry/SpanDescriptionExtractor.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import io.opentelemetry.api.common.Attributes;
44
import io.opentelemetry.api.trace.SpanKind;
55
import io.opentelemetry.sdk.trace.data.SpanData;
6-
import io.opentelemetry.semconv.SemanticAttributes;
6+
import io.opentelemetry.semconv.HttpAttributes;
7+
import io.opentelemetry.semconv.UrlAttributes;
8+
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
9+
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;
710
import io.sentry.protocol.TransactionNameSource;
811
import org.jetbrains.annotations.ApiStatus;
912
import org.jetbrains.annotations.NotNull;
@@ -17,18 +20,17 @@ public final class SpanDescriptionExtractor {
1720
final @NotNull SpanData otelSpan, final @Nullable OtelSpanWrapper sentrySpan) {
1821
final @NotNull Attributes attributes = otelSpan.getAttributes();
1922

20-
final @Nullable String httpMethod = attributes.get(SemanticAttributes.HTTP_METHOD);
23+
final @Nullable String httpMethod = attributes.get(HttpAttributes.HTTP_REQUEST_METHOD);
2124
if (httpMethod != null) {
2225
return descriptionForHttpMethod(otelSpan, httpMethod);
2326
}
2427

25-
final @Nullable String httpRequestMethod =
26-
attributes.get(SemanticAttributes.HTTP_REQUEST_METHOD);
28+
final @Nullable String httpRequestMethod = attributes.get(HttpAttributes.HTTP_REQUEST_METHOD);
2729
if (httpRequestMethod != null) {
2830
return descriptionForHttpMethod(otelSpan, httpRequestMethod);
2931
}
3032

31-
final @Nullable String dbSystem = attributes.get(SemanticAttributes.DB_SYSTEM);
33+
final @Nullable String dbSystem = attributes.get(DbIncubatingAttributes.DB_SYSTEM);
3234
if (dbSystem != null) {
3335
return descriptionForDbSystem(otelSpan);
3436
}
@@ -53,15 +55,14 @@ private OtelSpanInfo descriptionForHttpMethod(
5355
} else if (SpanKind.SERVER.equals(kind)) {
5456
opBuilder.append(".server");
5557
}
56-
final @Nullable String httpTarget = attributes.get(SemanticAttributes.HTTP_TARGET);
57-
final @Nullable String httpRoute = attributes.get(SemanticAttributes.HTTP_ROUTE);
58+
final @Nullable String httpTarget = attributes.get(HttpIncubatingAttributes.HTTP_TARGET);
59+
final @Nullable String httpRoute = attributes.get(HttpAttributes.HTTP_ROUTE);
5860
@Nullable String httpPath = httpRoute;
5961
if (httpPath == null) {
6062
httpPath = httpTarget;
6163
}
6264
final @NotNull String op = opBuilder.toString();
63-
64-
final @Nullable String urlFull = attributes.get(SemanticAttributes.URL_FULL);
65+
final @Nullable String urlFull = attributes.get(UrlAttributes.URL_FULL);
6566
if (urlFull != null) {
6667
if (httpPath == null) {
6768
httpPath = urlFull;
@@ -82,7 +83,7 @@ private OtelSpanInfo descriptionForHttpMethod(
8283
@SuppressWarnings("deprecation")
8384
private OtelSpanInfo descriptionForDbSystem(final @NotNull SpanData otelSpan) {
8485
final @NotNull Attributes attributes = otelSpan.getAttributes();
85-
@Nullable String dbStatement = attributes.get(SemanticAttributes.DB_STATEMENT);
86+
@Nullable String dbStatement = attributes.get(DbIncubatingAttributes.DB_STATEMENT);
8687
@NotNull String description = dbStatement != null ? dbStatement : otelSpan.getName();
8788
return new OtelSpanInfo("db", description, TransactionNameSource.TASK);
8889
}

sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/SentrySpanProcessorTest.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import io.opentelemetry.sdk.OpenTelemetrySdk
1717
import io.opentelemetry.sdk.trace.ReadWriteSpan
1818
import io.opentelemetry.sdk.trace.ReadableSpan
1919
import io.opentelemetry.sdk.trace.SdkTracerProvider
20-
import io.opentelemetry.semconv.SemanticAttributes
20+
import io.opentelemetry.semconv.HttpAttributes
21+
import io.opentelemetry.semconv.UrlAttributes
2122
import io.sentry.Baggage
2223
import io.sentry.BaggageHeader
2324
import io.sentry.Hint
@@ -125,7 +126,7 @@ class SentrySpanProcessorTest {
125126
fun `ignores sentry client request`() {
126127
fixture.setup()
127128
givenSpanBuilder(SpanKind.CLIENT)
128-
.setAttribute(SemanticAttributes.HTTP_URL, "https://key@sentry.io/proj/some-api")
129+
.setAttribute(UrlAttributes.URL_FULL, "https://key@sentry.io/proj/some-api")
129130
.startSpan()
130131

131132
thenNoTransactionIsStarted()
@@ -135,7 +136,7 @@ class SentrySpanProcessorTest {
135136
fun `ignores sentry internal request`() {
136137
fixture.setup()
137138
givenSpanBuilder(SpanKind.CLIENT)
138-
.setAttribute(SemanticAttributes.HTTP_URL, "https://key@sentry.io/proj/some-api")
139+
.setAttribute(UrlAttributes.URL_FULL, "https://key@sentry.io/proj/some-api")
139140
.startSpan()
140141

141142
thenNoTransactionIsStarted()
@@ -304,8 +305,8 @@ class SentrySpanProcessorTest {
304305
thenChildSpanIsStarted()
305306

306307
otelChildSpan.setStatus(StatusCode.ERROR)
307-
otelChildSpan.setAttribute(SemanticAttributes.HTTP_URL, "http://github.com/getsentry/sentry-java")
308-
otelChildSpan.setAttribute(SemanticAttributes.HTTP_STATUS_CODE, 404L)
308+
otelChildSpan.setAttribute(UrlAttributes.URL_FULL, "http://github.com/getsentry/sentry-java")
309+
otelChildSpan.setAttribute(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 404L)
309310

310311
otelChildSpan.end()
311312
thenChildSpanIsFinished(SpanStatus.NOT_FOUND)

sentry-opentelemetry/sentry-opentelemetry-extra/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ dependencies {
4040

4141
testImplementation(Config.Libs.OpenTelemetry.otelSdk)
4242
testImplementation(Config.Libs.OpenTelemetry.otelSemconv)
43+
testImplementation(Config.Libs.OpenTelemetry.otelSemconvIncubating)
4344
}
4445

4546
configure<SourceSetContainer> {

0 commit comments

Comments
 (0)