Skip to content

Commit 0174f15

Browse files
committed
Merge branch 'feat/queue-instrumentation-spring-boot-2' into fix/queue-instrumentation-review-changes
2 parents 6204fd6 + a4b2016 commit 0174f15

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

sentry-spring/src/test/kotlin/io/sentry/spring/kafka/SentryKafkaConsumerBeanPostProcessorTest.kt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package io.sentry.spring.kafka
33
import kotlin.test.Test
44
import kotlin.test.assertSame
55
import kotlin.test.assertTrue
6-
import org.apache.kafka.clients.consumer.ConsumerRecord
76
import org.mockito.kotlin.mock
87
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory
98
import org.springframework.kafka.core.ConsumerFactory
@@ -64,12 +63,7 @@ class SentryKafkaConsumerBeanPostProcessorTest {
6463
val factory = ConcurrentKafkaListenerContainerFactory<String, String>()
6564
factory.consumerFactory = consumerFactory
6665

67-
val customerInterceptor =
68-
object : RecordInterceptor<String, String> {
69-
override fun intercept(
70-
record: ConsumerRecord<String, String>
71-
): ConsumerRecord<String, String>? = record
72-
}
66+
val customerInterceptor = RecordInterceptor<String, String> { record -> record }
7367
factory.setRecordInterceptor(customerInterceptor)
7468

7569
val processor = SentryKafkaConsumerBeanPostProcessor()
@@ -97,12 +91,7 @@ class SentryKafkaConsumerBeanPostProcessorTest {
9791
val consumerFactory = mock<ConsumerFactory<String, String>>()
9892
val factory = ConcurrentKafkaListenerContainerFactory<String, String>()
9993
factory.consumerFactory = consumerFactory
100-
val customerInterceptor =
101-
object : RecordInterceptor<String, String> {
102-
override fun intercept(
103-
record: ConsumerRecord<String, String>
104-
): ConsumerRecord<String, String>? = record
105-
}
94+
val customerInterceptor = RecordInterceptor<String, String> { record -> record }
10695
factory.setRecordInterceptor(customerInterceptor)
10796

10897
val field = factory.javaClass.superclass.getDeclaredField("recordInterceptor")

sentry-spring/src/test/kotlin/io/sentry/spring/kafka/SentryKafkaRecordInterceptorTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,19 @@ class SentryKafkaRecordInterceptorTest {
277277
verify(delegate).intercept(record, consumer)
278278
}
279279

280+
@Test
281+
fun `delegates to existing interceptor when consumer is null`() {
282+
val delegate = mock<RecordInterceptor<String, String>>()
283+
val record = createRecord()
284+
whenever(delegate.intercept(record)).thenReturn(record)
285+
286+
val interceptor = SentryKafkaRecordInterceptor(scopes, delegate)
287+
val result = interceptor.intercept(record)
288+
289+
assertEquals(record, result)
290+
verify(delegate).intercept(record)
291+
}
292+
280293
@Test
281294
fun `success finishes transaction and delegates`() {
282295
val delegate = mock<RecordInterceptor<String, String>>()

0 commit comments

Comments
 (0)