Skip to content

Commit e0bb87f

Browse files
committed
test(samples): Cover OTel Jakarta Kafka coexistence end-to-end
Enable the Kafka Spring profile (and Kafka broker) for the two OTel Spring Boot 3 Jakarta sample modules in the system-test runner, and add a Kafka system test in each that produces a message and asserts no Sentry-style `queue.publish` / `queue.process` span/transaction is emitted. SentryKafkaQueueConfiguration is guarded by @ConditionalOnMissingClass("io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider"), so the Sentry Kafka bean post-processors must not be wired when the Sentry OTel integration is present. The new assertions lock that suppression into CI for both the agent and noagent OTel Jakarta samples. Addresses review finding F-011.
1 parent 47b2d2f commit e0bb87f

3 files changed

Lines changed: 94 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package io.sentry.systemtest
2+
3+
import io.sentry.systemtest.util.TestHelper
4+
import kotlin.test.Test
5+
import kotlin.test.assertEquals
6+
import org.junit.Before
7+
8+
/**
9+
* System tests for Kafka queue instrumentation on the OTel Jakarta noagent sample.
10+
*
11+
* The Sentry Kafka auto-configuration (`SentryKafkaQueueConfiguration`) is intentionally suppressed
12+
* when `io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider` is on the classpath, so
13+
* the Sentry `SentryKafkaProducerInterceptor` and `SentryKafkaRecordInterceptor` must not be wired.
14+
*
15+
* These tests produce a Kafka message end-to-end and assert that Sentry-style `queue.publish` /
16+
* `queue.process` spans/transactions are *not* emitted. Any Kafka telemetry in OTel mode must come
17+
* from the OTel Kafka instrumentation, not from the Sentry Kafka integration.
18+
*
19+
* Requires:
20+
* - The sample app running with `--spring.profiles.active=kafka`
21+
* - A Kafka broker at localhost:9092
22+
* - The mock Sentry server at localhost:8000
23+
*/
24+
class KafkaOtelCoexistenceSystemTest {
25+
lateinit var testHelper: TestHelper
26+
27+
@Before
28+
fun setup() {
29+
testHelper = TestHelper("http://localhost:8080")
30+
testHelper.reset()
31+
}
32+
33+
@Test
34+
fun `Sentry Kafka integration is suppressed when OTel is active`() {
35+
val restClient = testHelper.restClient
36+
37+
restClient.produceKafkaMessage("otel-coexistence-test")
38+
assertEquals(200, restClient.lastKnownStatusCode)
39+
40+
testHelper.ensureNoTransactionReceived { transaction, _ ->
41+
transaction.contexts.trace?.operation == "queue.process" ||
42+
transaction.spans.any { span -> span.op == "queue.publish" }
43+
}
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package io.sentry.systemtest
2+
3+
import io.sentry.systemtest.util.TestHelper
4+
import kotlin.test.Test
5+
import kotlin.test.assertEquals
6+
import org.junit.Before
7+
8+
/**
9+
* System tests for Kafka queue instrumentation on the OTel Jakarta sample.
10+
*
11+
* The Sentry Kafka auto-configuration (`SentryKafkaQueueConfiguration`) is intentionally suppressed
12+
* when `io.sentry.opentelemetry.SentryAutoConfigurationCustomizerProvider` is on the classpath, so
13+
* the Sentry `SentryKafkaProducerInterceptor` and `SentryKafkaRecordInterceptor` must not be wired.
14+
*
15+
* These tests produce a Kafka message end-to-end and assert that Sentry-style `queue.publish` /
16+
* `queue.process` spans/transactions are *not* emitted. Any Kafka telemetry in OTel mode must come
17+
* from the OTel Kafka instrumentation, not from the Sentry Kafka integration.
18+
*
19+
* Requires:
20+
* - The sample app running with `--spring.profiles.active=kafka`
21+
* - A Kafka broker at localhost:9092
22+
* - The mock Sentry server at localhost:8000
23+
*/
24+
class KafkaOtelCoexistenceSystemTest {
25+
lateinit var testHelper: TestHelper
26+
27+
@Before
28+
fun setup() {
29+
testHelper = TestHelper("http://localhost:8080")
30+
testHelper.reset()
31+
}
32+
33+
@Test
34+
fun `Sentry Kafka integration is suppressed when OTel is active`() {
35+
val restClient = testHelper.restClient
36+
37+
restClient.produceKafkaMessage("otel-coexistence-test")
38+
assertEquals(200, restClient.lastKnownStatusCode)
39+
40+
testHelper.ensureNoTransactionReceived { transaction, _ ->
41+
transaction.contexts.trace?.operation == "queue.process" ||
42+
transaction.spans.any { span -> span.op == "queue.publish" }
43+
}
44+
}
45+
}

test/system-test-runner.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@
7171
KAFKA_BROKER_REQUIRED_MODULES = {
7272
"sentry-samples-console",
7373
"sentry-samples-spring-boot-jakarta",
74+
"sentry-samples-spring-boot-jakarta-opentelemetry",
75+
"sentry-samples-spring-boot-jakarta-opentelemetry-noagent",
7476
}
7577
KAFKA_PROFILE_REQUIRED_MODULES = {
7678
"sentry-samples-spring-boot-jakarta",
79+
"sentry-samples-spring-boot-jakarta-opentelemetry",
80+
"sentry-samples-spring-boot-jakarta-opentelemetry-noagent",
7781
}
7882

7983
class ServerType(Enum):

0 commit comments

Comments
 (0)