diff --git a/.github/workflows/spring-boot-4-matrix.yml b/.github/workflows/spring-boot-4-matrix.yml index c82113828cc..b436a7f31ed 100644 --- a/.github/workflows/spring-boot-4-matrix.yml +++ b/.github/workflows/spring-boot-4-matrix.yml @@ -132,14 +132,13 @@ jobs: --auto-init "false" \ --build "true" -# needs a fix in opentelemetry-spring-boot-starter -# - name: Run sentry-samples-spring-boot-4-opentelemetry-noagent -# run: | -# python3 test/system-test-runner.py test \ -# --module "sentry-samples-spring-boot-4-opentelemetry-noagent" \ -# --agent false \ -# --auto-init "true" \ -# --build "true" + - name: Run sentry-samples-spring-boot-4-opentelemetry-noagent + run: | + python3 test/system-test-runner.py test \ + --module "sentry-samples-spring-boot-4-opentelemetry-noagent" \ + --agent false \ + --auto-init "true" \ + --build "true" - name: Run sentry-samples-spring-7 run: | diff --git a/.github/workflows/system-tests-backend.yml b/.github/workflows/system-tests-backend.yml index 4f7929343cc..f57f81aaf84 100644 --- a/.github/workflows/system-tests-backend.yml +++ b/.github/workflows/system-tests-backend.yml @@ -72,9 +72,9 @@ jobs: - sample: "sentry-samples-spring-boot-4-webflux" agent: "false" agent-auto-init: "true" -# - sample: "sentry-samples-spring-boot-4-opentelemetry-noagent" -# agent: "false" -# agent-auto-init: "true" + - sample: "sentry-samples-spring-boot-4-opentelemetry-noagent" + agent: "false" + agent-auto-init: "true" - sample: "sentry-samples-spring-boot-4-opentelemetry" agent: "true" agent-auto-init: "true" diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d640f385a..58d20127fbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,15 @@ } ``` +### Dependencies + +- Bump OpenTelemetry ([#5225](https://github.com/getsentry/sentry-java/pull/5225)) + - `opentelemetry` to `1.60.1` (was `1.57.0`) + - `opentelemetry-instrumentation` to `2.26.0` (was `2.23.0`) + - `opentelemetry-instrumentation-alpha` to `2.26.0-alpha` (was `2.23.0-alpha`) + - `opentelemetry-semconv` to `1.40.0` (was `1.37.0`) + - `opentelemetry-semconv-alpha` to `1.40.0-alpha` (was `1.37.0-alpha`) + ## 8.36.0 ### Features diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7b53258a5a6..60be4fd2c03 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -22,12 +22,12 @@ nopen = "1.0.1" # see https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compatibility-and-versioning.html#kotlin-compatibility # see https://developer.android.com/jetpack/androidx/releases/compose-kotlin okhttp = "4.9.2" -otel = "1.57.0" -otelInstrumentation = "2.23.0" -otelInstrumentationAlpha = "2.23.0-alpha" +otel = "1.60.1" +otelInstrumentation = "2.26.0" +otelInstrumentationAlpha = "2.26.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 -otelSemanticConventions = "1.37.0" -otelSemanticConventionsAlpha = "1.37.0-alpha" +otelSemanticConventions = "1.40.0" +otelSemanticConventionsAlpha = "1.40.0-alpha" retrofit = "2.9.0" slf4j = "1.7.30" springboot2 = "2.7.18" diff --git a/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/OpenTelemetryAttributesExtractorTest.kt b/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/OpenTelemetryAttributesExtractorTest.kt index 5cc37d80f9c..6d37240f0b2 100644 --- a/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/OpenTelemetryAttributesExtractorTest.kt +++ b/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/OpenTelemetryAttributesExtractorTest.kt @@ -1,8 +1,7 @@ package io.sentry.opentelemetry import io.opentelemetry.api.common.AttributeKey -import io.opentelemetry.sdk.internal.AttributesMap -import io.opentelemetry.sdk.trace.SpanLimits +import io.opentelemetry.api.common.Attributes import io.opentelemetry.sdk.trace.data.SpanData import io.opentelemetry.semconv.HttpAttributes import io.opentelemetry.semconv.ServerAttributes @@ -22,12 +21,12 @@ import org.mockito.kotlin.whenever class OpenTelemetryAttributesExtractorTest { private class Fixture { val spanData = mock() - val attributes = AttributesMap.create(100, SpanLimits.getDefault().maxAttributeValueLength) + var attributes: Attributes = Attributes.empty() val options = SentryOptions.empty() val scope = Scope(options) init { - whenever(spanData.attributes).thenReturn(attributes) + whenever(spanData.attributes).thenAnswer { attributes } } } @@ -346,7 +345,22 @@ class OpenTelemetryAttributesExtractorTest { } private fun givenAttributes(map: Map, Any>) { - map.forEach { k, v -> fixture.attributes.put(k, v) } + fixture.attributes = buildAttributes(map) + } + + private fun buildAttributes(map: Map, Any>): Attributes { + val builder = Attributes.builder() + map.forEach { (key, value) -> putAttribute(builder, key, value) } + return builder.build() + } + + @Suppress("UNCHECKED_CAST") + private fun putAttribute( + builder: io.opentelemetry.api.common.AttributesBuilder, + key: AttributeKey, + value: Any, + ) { + builder.put(key as AttributeKey, value) } private fun whenExtractingAttributes() { diff --git a/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/OtelInternalSpanDetectionUtilTest.kt b/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/OtelInternalSpanDetectionUtilTest.kt index bc453be6c1a..63a6c77c520 100644 --- a/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/OtelInternalSpanDetectionUtilTest.kt +++ b/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/OtelInternalSpanDetectionUtilTest.kt @@ -1,8 +1,8 @@ package io.sentry.opentelemetry import io.opentelemetry.api.common.AttributeKey +import io.opentelemetry.api.common.Attributes import io.opentelemetry.api.trace.SpanKind -import io.opentelemetry.sdk.internal.AttributesMap import io.opentelemetry.semconv.HttpAttributes import io.opentelemetry.semconv.ServerAttributes import io.opentelemetry.semconv.UrlAttributes @@ -17,7 +17,7 @@ import org.mockito.kotlin.whenever class OtelInternalSpanDetectionUtilTest { private class Fixture { val scopes = mock() - val attributes = AttributesMap.create(100, 100) + var attributes: Attributes = Attributes.empty() val options = SentryOptions.empty() var spanKind: SpanKind = SpanKind.INTERNAL @@ -152,7 +152,22 @@ class OtelInternalSpanDetectionUtilTest { } private fun givenAttributes(map: Map, Any>) { - map.forEach { k, v -> fixture.attributes.put(k, v) } + fixture.attributes = buildAttributes(map) + } + + private fun buildAttributes(map: Map, Any>): Attributes { + val builder = Attributes.builder() + map.forEach { (key, value) -> putAttribute(builder, key, value) } + return builder.build() + } + + @Suppress("UNCHECKED_CAST") + private fun putAttribute( + builder: io.opentelemetry.api.common.AttributesBuilder, + key: AttributeKey, + value: Any, + ) { + builder.put(key as AttributeKey, value) } private fun givenDsn(dsn: String) { diff --git a/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/SpanDescriptionExtractorTest.kt b/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/SpanDescriptionExtractorTest.kt index af04914e278..9c5a1a352df 100644 --- a/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/SpanDescriptionExtractorTest.kt +++ b/sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/SpanDescriptionExtractorTest.kt @@ -1,11 +1,11 @@ package io.sentry.opentelemetry import io.opentelemetry.api.common.AttributeKey +import io.opentelemetry.api.common.Attributes import io.opentelemetry.api.trace.SpanContext import io.opentelemetry.api.trace.SpanKind import io.opentelemetry.api.trace.TraceFlags import io.opentelemetry.api.trace.TraceState -import io.opentelemetry.sdk.internal.AttributesMap import io.opentelemetry.sdk.trace.data.SpanData import io.opentelemetry.semconv.HttpAttributes import io.opentelemetry.semconv.UrlAttributes @@ -22,14 +22,14 @@ class SpanDescriptionExtractorTest { private class Fixture { val sentrySpan = mock() val otelSpan = mock() - val attributes = AttributesMap.create(100, 100) + var attributes: Attributes = Attributes.empty() var parentSpanContext = SpanContext.getInvalid() var spanKind = SpanKind.INTERNAL var spanName: String? = null var spanDescription: String? = null fun setup() { - whenever(otelSpan.attributes).thenReturn(attributes) + whenever(otelSpan.attributes).thenAnswer { attributes } whenever(otelSpan.parentSpanContext).thenReturn(parentSpanContext) whenever(otelSpan.kind).thenReturn(spanKind) spanName?.let { whenever(otelSpan.name).thenReturn(it) } @@ -271,7 +271,22 @@ class SpanDescriptionExtractorTest { } private fun givenAttributes(map: Map, Any>) { - map.forEach { k, v -> fixture.attributes.put(k, v) } + fixture.attributes = buildAttributes(map) + } + + private fun buildAttributes(map: Map, Any>): Attributes { + val builder = Attributes.builder() + map.forEach { (key, value) -> putAttribute(builder, key, value) } + return builder.build() + } + + @Suppress("UNCHECKED_CAST") + private fun putAttribute( + builder: io.opentelemetry.api.common.AttributesBuilder, + key: AttributeKey, + value: Any, + ) { + builder.put(key as AttributeKey, value) } private fun whenExtractingSpanInfo(): OtelSpanInfo {