Skip to content

Commit 10ae067

Browse files
Bump OpenTelemetry SDK to 1.51.0, instrumentation to 2.17.0 and semconv to 1.34.0 (#4532)
* Bump OTel SDK to 1.51.0, instrumentation to 2.17.0 and semconv to 1.34.0 * Restore span names for GraphQL on the new version of OpenTelemetry (by changing OpenTelemetry defaults) (#4537) * do not override span name if customized * Format code * log in case system property cannot be set * merge * changelog --------- Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io> * Use non alpha version for semconv * move changelog entry --------- Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
1 parent d1e46e5 commit 10ae067

File tree

6 files changed

+55
-50
lines changed

6 files changed

+55
-50
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
- Enable the Logs feature in your `SentryOptions` or with the `io.sentry.logs.enabled` manifest option and the SDK will automatically send logcat logs to Sentry, if the Sentry Android Gradle plugin is applied.
1212
- To set the logcat level check the [Logcat integration documentation](https://docs.sentry.io/platforms/android/integrations/logcat/#configure).
1313

14+
### Dependencies
15+
16+
- Bump OpenTelemetry ([#4532](https://github.com/getsentry/sentry-java/pull/4532))
17+
- `opentelemetry-sdk` to `1.51.0`
18+
- `opentelemetry-instrumentation` to `2.17.0`
19+
- `opentelemetry-javaagent` to `2.17.0`
20+
- `opentelemetry-semconv` to `1.34.0`
21+
- We are now configuring OpenTelemetry to still behave the same way it did before for span names it generates in GraphQL auto instrumentation ([#4537](https://github.com/getsentry/sentry-java/pull/4537))
22+
1423
## 8.16.1-alpha.2
1524

1625
### Fixes

gradle/libs.versions.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ nopen = "1.0.1"
1919
# see https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compatibility-and-versioning.html#kotlin-compatibility
2020
# see https://developer.android.com/jetpack/androidx/releases/compose-kotlin
2121
okhttp = "4.9.2"
22-
otel = "1.44.1"
23-
otelInstrumentation = "2.10.0"
24-
otelInstrumentationAlpha = "2.10.0-alpha"
22+
otel = "1.51.0"
23+
otelInstrumentation = "2.17.0"
24+
otelInstrumentationAlpha = "2.17.0-alpha"
2525
# 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
26-
otelSemanticConventions = "1.28.0-alpha"
26+
otelSemanticConventions = "1.34.0"
27+
otelSemanticConventionsAlpha = "1.34.0-alpha"
2728
retrofit = "2.9.0"
2829
slf4j = "1.7.30"
2930
springboot2 = "2.7.18"
@@ -110,7 +111,7 @@ otel-javaagent = { module = "io.opentelemetry.javaagent:opentelemetry-javaagent"
110111
otel-javaagent-tooling = { module = "io.opentelemetry.javaagent:opentelemetry-javaagent-tooling", version.ref = "otelInstrumentationAlpha" }
111112
otel-javaagent-extension-api = { module = "io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api", version.ref = "otelInstrumentationAlpha" }
112113
otel-semconv = { module = "io.opentelemetry.semconv:opentelemetry-semconv", version.ref = "otelSemanticConventions" }
113-
otel-semconv-incubating = { module = "io.opentelemetry.semconv:opentelemetry-semconv-incubating", version.ref = "otelSemanticConventions" }
114+
otel-semconv-incubating = { module = "io.opentelemetry.semconv:opentelemetry-semconv-incubating", version.ref = "otelSemanticConventionsAlpha" }
114115
p6spy = { module = "p6spy:p6spy", version = "3.9.1" }
115116
quartz = { module = "org.quartz-scheduler:quartz", version = "2.3.0" }
116117
reactor-core = { module = "io.projectreactor:reactor-core", version = "3.5.3" }

sentry-opentelemetry/sentry-opentelemetry-agentcustomization/src/main/java/io/sentry/opentelemetry/SentryAutoConfigurationCustomizerProvider.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,23 @@
1414
import io.sentry.protocol.SentryPackage;
1515
import java.util.HashMap;
1616
import java.util.Map;
17+
import java.util.logging.Level;
18+
import java.util.logging.Logger;
1719
import org.jetbrains.annotations.NotNull;
1820
import org.jetbrains.annotations.Nullable;
1921

2022
public final class SentryAutoConfigurationCustomizerProvider
2123
implements AutoConfigurationCustomizerProvider {
2224

25+
private static final Logger logger =
26+
Logger.getLogger(SentryAutoConfigurationCustomizerProvider.class.getName());
27+
2328
public static volatile boolean skipInit = false;
2429

2530
@Override
2631
public void customize(AutoConfigurationCustomizer autoConfiguration) {
2732
ensureSentryOtelStorageIsInitialized();
33+
customizeOpenTelemetryDefaults();
2834
final @Nullable ManifestVersionReader.VersionInfoHolder versionInfoHolder =
2935
ManifestVersionReader.getInstance().readOpenTelemetryVersion();
3036

@@ -63,6 +69,18 @@ private static void ensureSentryOtelStorageIsInitialized() {
6369
Sentry.getGlobalScope();
6470
}
6571

72+
private void customizeOpenTelemetryDefaults() {
73+
try {
74+
if (System.getProperty("otel.instrumentation.graphql.add-operation-name-to-span-name.enabled")
75+
== null) {
76+
System.setProperty(
77+
"otel.instrumentation.graphql.add-operation-name-to-span-name.enabled", "true");
78+
}
79+
} catch (Exception e) {
80+
logger.log(Level.WARNING, "Unable to change OpenTelemetry defaults for use with Sentry.", e);
81+
}
82+
}
83+
6684
private boolean isSentryAutoInitEnabled() {
6785
if (skipInit) {
6886
return false;

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,13 @@ private static Map<String, String> collectHeaders(
105105
return headers;
106106
}
107107

108-
@SuppressWarnings("deprecation")
109108
public @Nullable String extractUrl(
110109
final @NotNull Attributes attributes, final @NotNull SentryOptions options) {
111110
final @Nullable String urlFull = attributes.get(UrlAttributes.URL_FULL);
112111
if (urlFull != null) {
113112
return urlFull;
114113
}
115114

116-
final @Nullable String deprecatedUrl =
117-
attributes.get(io.opentelemetry.semconv.SemanticAttributes.HTTP_URL);
118-
if (deprecatedUrl != null) {
119-
return deprecatedUrl;
120-
}
121-
122115
final String urlString = buildUrlString(attributes, options);
123116
if (!urlString.isEmpty()) {
124117
return urlString;

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ package io.sentry.opentelemetry
22

33
import io.opentelemetry.api.common.AttributeKey
44
import io.opentelemetry.sdk.internal.AttributesMap
5+
import io.opentelemetry.sdk.trace.SpanLimits
56
import io.opentelemetry.sdk.trace.data.SpanData
67
import io.opentelemetry.semconv.HttpAttributes
7-
import io.opentelemetry.semconv.SemanticAttributes
88
import io.opentelemetry.semconv.ServerAttributes
99
import io.opentelemetry.semconv.UrlAttributes
1010
import io.sentry.Scope
1111
import io.sentry.SentryOptions
1212
import io.sentry.protocol.Request
13+
import java.util.UUID
1314
import kotlin.test.Test
1415
import kotlin.test.assertEquals
1516
import kotlin.test.assertFalse
@@ -21,7 +22,7 @@ import org.mockito.kotlin.whenever
2122
class OpenTelemetryAttributesExtractorTest {
2223
private class Fixture {
2324
val spanData = mock<SpanData>()
24-
val attributes = AttributesMap.create(100, 100)
25+
val attributes = AttributesMap.create(100, SpanLimits.getDefault().maxAttributeValueLength)
2526
val options = SentryOptions.empty()
2627
val scope = Scope(options)
2728

@@ -195,15 +196,6 @@ class OpenTelemetryAttributesExtractorTest {
195196
assertEquals("https://sentry.io/some/path", url)
196197
}
197198

198-
@Test
199-
fun `returns deprecated URL if present`() {
200-
givenAttributes(mapOf(SemanticAttributes.HTTP_URL to "https://sentry.io/some/path"))
201-
202-
val url = whenExtractingUrl()
203-
204-
assertEquals("https://sentry.io/some/path", url)
205-
}
206-
207199
@Test
208200
fun `returns reconstructed URL if attributes present`() {
209201
givenAttributes(
@@ -293,19 +285,30 @@ class OpenTelemetryAttributesExtractorTest {
293285

294286
@Test
295287
fun `sets server request headers based on OTel attributes and merges list of values`() {
296-
givenAttributes(
288+
val elements =
289+
"sentry-environment=production,sentry-public_key=502f25099c204a2fbf4cb16edc5975d1,sentry-sample_rate=1,sentry-sampled=true,sentry-trace_id=df71f5972f754b4c85af13ff5c07017d"
290+
val listOf = listOf(elements, "another-baggage=abc,more=def")
291+
val pairs = AttributeKey.stringArrayKey("http.request.header.baggage") to listOf
292+
val map =
297293
mapOf(
298294
HttpAttributes.HTTP_REQUEST_METHOD to "GET",
299-
AttributeKey.stringArrayKey("http.request.header.baggage") to
300-
listOf(
301-
"sentry-environment=production,sentry-public_key=502f25099c204a2fbf4cb16edc5975d1,sentry-sample_rate=1,sentry-sampled=true,sentry-trace_id=df71f5972f754b4c85af13ff5c07017d",
302-
"another-baggage=abc,more=def",
303-
),
295+
pairs,
304296
AttributeKey.stringArrayKey("http.request.header.sentry-trace") to
305297
listOf("f9118105af4a2d42b4124532cd176588-4542d085bb0b4de5"),
306-
AttributeKey.stringArrayKey("http.response.header.some-header") to listOf("some-value"),
298+
AttributeKey.stringArrayKey("http.response.header.some-header") to
299+
listOf(
300+
"some-value" +
301+
"__" +
302+
UUID.randomUUID().toString() +
303+
"__" +
304+
UUID.randomUUID().toString() +
305+
"__" +
306+
UUID.randomUUID().toString() +
307+
"__" +
308+
UUID.randomUUID().toString()
309+
),
307310
)
308-
)
311+
givenAttributes(map)
309312

310313
whenExtractingAttributes()
311314

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import io.opentelemetry.api.common.AttributeKey
44
import io.opentelemetry.api.trace.SpanKind
55
import io.opentelemetry.sdk.internal.AttributesMap
66
import io.opentelemetry.semconv.HttpAttributes
7-
import io.opentelemetry.semconv.SemanticAttributes
87
import io.opentelemetry.semconv.ServerAttributes
98
import io.opentelemetry.semconv.UrlAttributes
109
import io.sentry.IScopes
@@ -56,15 +55,6 @@ class OtelInternalSpanDetectionUtilTest {
5655
thenRequestIsConsideredInternal()
5756
}
5857

59-
@Test
60-
fun `detects deprecated url as internal (span kind client)`() {
61-
givenDsn("https://publicKey:secretKey@io.sentry:8081/path/id?sample.rate=0.1")
62-
givenSpanKind(SpanKind.CLIENT)
63-
givenAttributes(mapOf(SemanticAttributes.HTTP_URL to "https://io.sentry:8081"))
64-
65-
thenRequestIsConsideredInternal()
66-
}
67-
6858
@Test
6959
fun `detects split url as internal (span kind internal)`() {
7060
givenDsn("https://publicKey:secretKey@io.sentry:8081/path/id?sample.rate=0.1")
@@ -92,15 +82,6 @@ class OtelInternalSpanDetectionUtilTest {
9282
thenRequestIsConsideredInternal()
9383
}
9484

95-
@Test
96-
fun `detects deprecated url as internal (span kind internal)`() {
97-
givenDsn("https://publicKey:secretKey@io.sentry:8081/path/id?sample.rate=0.1")
98-
givenSpanKind(SpanKind.INTERNAL)
99-
givenAttributes(mapOf(SemanticAttributes.HTTP_URL to "https://io.sentry:8081"))
100-
101-
thenRequestIsConsideredInternal()
102-
}
103-
10485
@Test
10586
fun `does not detect full url as internal (span kind server)`() {
10687
givenDsn("https://publicKey:secretKey@io.sentry:8081/path/id?sample.rate=0.1")

0 commit comments

Comments
 (0)