Skip to content

Commit e511e86

Browse files
authored
Merge pull request #5324 from getsentry/fix/queue-instrumentation-kafka-otel-coexistence-ci
test(samples): [Queue Instrumentation 28] Cover OTel Jakarta Kafka coexistence in CI
2 parents a4417eb + e0bb87f commit e511e86

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)