Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

### Dependencies

- Bump Spring Boot 4 from 4.1.0 to 4.2.0-RC2 and OpenTelemetry from 1.63.0 / 2.29.0 to 1.67.0 / 2.33.1 ([#6532](https://github.com/getsentry/sentry-java/pull/6532))
- Bump OkHttp from 4.9.2 to 5.5.1 ([#6472](https://github.com/getsentry/sentry-java/pull/6472))
- `sentry-okhttp` and the Spring Boot integrations keep OkHttp as a `compileOnly` dependency, so your app keeps the OkHttp version it declares. OkHttp 4 is still supported.
- [changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ nopen = "1.0.1"
# see https://developer.android.com/jetpack/androidx/releases/compose-kotlin
okhttp = "5.5.1"
openfeature = "1.18.2"
otel = "1.63.0"
otelAlpha = "1.63.0-alpha"
otelInstrumentation = "2.29.0"
otelInstrumentationAlpha = "2.29.0-alpha"
otel = "1.67.0"
otelAlpha = "1.67.0-alpha"
otelInstrumentation = "2.33.1"
otelInstrumentationAlpha = "2.33.1-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.42.0"
otelSemanticConventionsAlpha = "1.42.0-alpha"
Expand All @@ -48,7 +48,7 @@ slf4j = "1.7.30"
spotless = "8.8.0"
springboot2 = "2.7.18"
springboot3 = "3.5.0"
springboot4 = "4.1.0"
springboot4 = "4.2.0-RC2"
springKafka2 = "2.8.11"
springKafka3 = "3.3.5"
sqldelight = "2.3.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import io.opentelemetry.api.trace.TraceFlags
import io.opentelemetry.api.trace.TraceState
import io.opentelemetry.context.Context
import io.opentelemetry.sdk.trace.SdkTracerProvider
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor
import io.opentelemetry.sdk.trace.export.SpanExporter
import io.opentelemetry.sdk.trace.samplers.Sampler
import io.opentelemetry.sdk.trace.samplers.SamplingDecision
import io.sentry.DataCategory
Expand Down Expand Up @@ -138,18 +140,24 @@ class SentrySamplerTest {
verify(onDiscard).execute(DiscardReason.CALLBACK_ERROR, DataCategory.Span, 1)
verifyNoMoreInteractions(onDiscard)
val recordingSampler = mock<Sampler>(defaultAnswer = delegatesTo(sampler))
SdkTracerProvider.builder().setSampler(recordingSampler).build().use { provider ->
val openTelemetry =
mock<OpenTelemetry>().also {
whenever(it.tracerProvider).thenReturn(provider)
}
OtelSpanFactory(openTelemetry).createTransaction(context, scopes, TransactionOptions(), null)
val attributes = argumentCaptor<Attributes>()
verify(recordingSampler).shouldSample(any(), any(), any(), any(), attributes.capture(), any())
val restored = OtelSamplingUtil.extractSamplingDecision(attributes.firstValue)!!
assertThat(restored.sampled).isFalse()
assertThat(restored.profileSampled).isFalse()
}
SdkTracerProvider.builder()
.setSampler(recordingSampler)
.addSpanProcessor(SimpleSpanProcessor.create(SpanExporter.composite()))
.build()
.use { provider ->
val openTelemetry =
mock<OpenTelemetry>().also {
whenever(it.tracerProvider).thenReturn(provider)
}
OtelSpanFactory(openTelemetry)
.createTransaction(context, scopes, TransactionOptions(), null)
val attributes = argumentCaptor<Attributes>()
verify(recordingSampler)
.shouldSample(any(), any(), any(), any(), attributes.capture(), any())
val restored = OtelSamplingUtil.extractSamplingDecision(attributes.firstValue)!!
assertThat(restored.sampled).isFalse()
assertThat(restored.profileSampled).isFalse()
}

verifyNoMoreInteractions(onDiscard)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import io.opentelemetry.context.Context
import io.opentelemetry.context.propagation.TextMapGetter
import io.opentelemetry.context.propagation.TextMapSetter
import io.opentelemetry.sdk.trace.SdkTracerProvider
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor
import io.opentelemetry.sdk.trace.export.SpanExporter
import io.sentry.Baggage
import io.sentry.Sentry
import kotlin.test.AfterTest
Expand Down Expand Up @@ -180,7 +182,10 @@ class OpenTelemetryOtlpPropagatorTest {
}
val propagator = OpenTelemetryOtlpPropagator()
val carrier = mutableMapOf<String, String>()
val tracerProvider = SdkTracerProvider.builder().build()
val tracerProvider =
SdkTracerProvider.builder()
.addSpanProcessor(SimpleSpanProcessor.create(SpanExporter.composite()))
.build()
val otelSpan =
tracerProvider
.get("test")
Expand Down Expand Up @@ -220,7 +225,10 @@ class OpenTelemetryOtlpPropagatorTest {
}
val propagator = OpenTelemetryOtlpPropagator()
val carrier = mutableMapOf<String, String>()
val tracerProvider = SdkTracerProvider.builder().build()
val tracerProvider =
SdkTracerProvider.builder()
.addSpanProcessor(SimpleSpanProcessor.create(SpanExporter.composite()))
.build()
val otelSpan =
tracerProvider
.get("test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package io.sentry.opentelemetry.otlp
import com.google.common.truth.Truth.assertThat
import io.opentelemetry.sdk.OpenTelemetrySdk
import io.opentelemetry.sdk.trace.SdkTracerProvider
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor
import io.opentelemetry.sdk.trace.export.SpanExporter
import io.sentry.Sentry
import io.sentry.test.MockSentryServer
import io.sentry.test.event
Expand All @@ -20,7 +22,13 @@ import kotlin.test.Test
class OtlpEndToEndTest {
private val server = MockSentryServer()
private val openTelemetry =
OpenTelemetrySdk.builder().setTracerProvider(SdkTracerProvider.builder().build()).build()
OpenTelemetrySdk.builder()
.setTracerProvider(
SdkTracerProvider.builder()
.addSpanProcessor(SimpleSpanProcessor.create(SpanExporter.composite()))
.build()
)
.build()

@AfterTest
fun teardown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class WebConfig {
* @return RestTemplate
*/
@Bean
@SuppressWarnings("removal")
RestTemplate restTemplate(IScopes scopes) {
RestTemplate restTemplate = new RestTemplate();
SentrySpanClientHttpRequestInterceptor sentryRestTemplateInterceptor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

@Service
public class PersonService {
@SuppressWarnings("removal")
private final RestTemplate restTemplate;

@SuppressWarnings("removal")
public PersonService(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@SpringBootApplication
@EnableCaching
@EnableScheduling
@SuppressWarnings("removal")
public class SentryDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SentryDemoApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import reactor.core.scheduler.Schedulers;

@RestController
@SuppressWarnings("removal")
public class TodoController {
private final RestTemplate restTemplate;
private final WebClient webClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

@SpringBootApplication
@EnableScheduling
@SuppressWarnings("removal")
public class SentryDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SentryDemoApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import reactor.core.scheduler.Schedulers;

@RestController
@SuppressWarnings("removal")
public class TodoController {
private final RestTemplate restTemplate;
private final WebClient webClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@SpringBootApplication
@EnableCaching
@EnableScheduling
@SuppressWarnings("removal")
public class SentryDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SentryDemoApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import reactor.core.scheduler.Schedulers;

@RestController
@SuppressWarnings("removal")
public class TodoController {
private final RestTemplate restTemplate;
private final WebClient webClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@SpringBootApplication
@EnableCaching
@EnableScheduling
@SuppressWarnings("removal")
public class SentryDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SentryDemoApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import reactor.core.scheduler.Schedulers;

@RestController
@SuppressWarnings("removal")
public class TodoController {
private final RestTemplate restTemplate;
private final WebClient webClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@SpringBootApplication
@EnableCaching
@EnableScheduling
@SuppressWarnings("removal")
public class SentryDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SentryDemoApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import tools.jackson.databind.ObjectMapper;

@RestController
@SuppressWarnings("removal")
public class TodoController {
private final RestTemplate restTemplate;
private final WebClient webClient;
Expand Down
6 changes: 6 additions & 0 deletions sentry-samples/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
pluginManagement {
repositories {
mavenCentral()
maven("https://repo.spring.io/milestone") {
content { includeGroupByRegex("org\\.springframework.*") }
}
gradlePluginPortal()
}
}
Expand All @@ -20,6 +23,9 @@ develocity {
dependencyResolutionManagement {
repositories {
mavenCentral()
maven("https://repo.spring.io/milestone") {
content { includeGroupByRegex("org\\.springframework.*") }
}
mavenLocal()
}
versionCatalogs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package io.sentry.spring7.graphql

import graphql.execution.instrumentation.parameters.InstrumentationFieldFetchParameters
import graphql.language.Document
import graphql.language.Field
import graphql.language.OperationDefinition
import graphql.language.SelectionSet
import graphql.schema.DataFetchingEnvironment
import io.sentry.IScopes
import io.sentry.graphql.ExceptionReporter
Expand All @@ -20,22 +22,26 @@ import org.springframework.graphql.execution.SubscriptionPublisherException
import reactor.core.publisher.Flux

class SentrySpringSubscriptionHandlerTest {
private val document =
Document.newDocument()
.definition(
OperationDefinition.newOperationDefinition()
.operation(OperationDefinition.Operation.QUERY)
.name("testQuery")
.selectionSet(
SelectionSet.newSelectionSet().selection(Field.newField("test").build()).build()
)
.build()
)
.build()

@Test
fun `reports exception`() {
val exception = IllegalStateException("some exception")
val scopes = mock<IScopes>()
val exceptionReporter = mock<ExceptionReporter>()
val parameters = mock<InstrumentationFieldFetchParameters>()
val dataFetchingEnvironment = mock<DataFetchingEnvironment>()
val document =
Document.newDocument()
.definition(
OperationDefinition.newOperationDefinition()
.operation(OperationDefinition.Operation.QUERY)
.name("testQuery")
.build()
)
.build()
whenever(dataFetchingEnvironment.document).thenReturn(document)
whenever(parameters.environment).thenReturn(dataFetchingEnvironment)
val resultObject =
Expand All @@ -49,7 +55,7 @@ class SentrySpringSubscriptionHandlerTest {
check {
assertEquals(true, it.isSubscription)
assertSame(scopes, it.scopes)
assertEquals("query testQuery \n", it.query)
assertEquals("query testQuery {\n test\n}\n", it.query)
},
anyOrNull(),
)
Expand All @@ -63,15 +69,6 @@ class SentrySpringSubscriptionHandlerTest {
val exceptionReporter = mock<ExceptionReporter>()
val parameters = mock<InstrumentationFieldFetchParameters>()
val dataFetchingEnvironment = mock<DataFetchingEnvironment>()
val document =
Document.newDocument()
.definition(
OperationDefinition.newOperationDefinition()
.operation(OperationDefinition.Operation.QUERY)
.name("testQuery")
.build()
)
.build()
whenever(dataFetchingEnvironment.document).thenReturn(document)
whenever(parameters.environment).thenReturn(dataFetchingEnvironment)
val resultObject =
Expand All @@ -90,7 +87,7 @@ class SentrySpringSubscriptionHandlerTest {
check {
assertEquals(true, it.isSubscription)
assertSame(scopes, it.scopes)
assertEquals("query testQuery \n", it.query)
assertEquals("query testQuery {\n test\n}\n", it.query)
},
anyOrNull(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ static class SentrySpanPointcutAutoConfiguration {}
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({RestTemplate.class, RestTemplateAutoConfiguration.class})
@Open
@SuppressWarnings("removal")
static class SentryPerformanceRestTemplateConfigurationWrapper {
@Configuration(proxyBeanMethods = false)
@AutoConfigureBefore(RestTemplateAutoConfiguration.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.web.client.RestTemplate;

@Open
@SuppressWarnings("removal")
class SentrySpanRestTemplateCustomizer implements RestTemplateCustomizer {
private final @NotNull SentrySpanClientHttpRequestInterceptor interceptor;

Expand Down
6 changes: 6 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement {
repositories {
mavenCentral()
maven("https://repo.spring.io/milestone") {
content { includeGroupByRegex("org\\.springframework.*") }
}
gradlePluginPortal()
google()
}
Expand Down Expand Up @@ -36,6 +39,9 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://repo.spring.io/milestone") {
content { includeGroupByRegex("org\\.springframework.*") }
}
mavenLocal()
}
}
Expand Down
Loading