|
| 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 | +} |
0 commit comments