Skip to content

Commit be3a2ba

Browse files
adinauerclaude
andcommitted
fix(spring-jakarta): Update consumer references and add reflection warning log
Update SentryKafkaRecordInterceptor and its test to reference SentryProducerInterceptor instead of the removed SentryKafkaProducerWrapper. Add a warning log in SentryKafkaConsumerBeanPostProcessor when reflection fails to read the existing RecordInterceptor, so users know their custom interceptor may not be chained. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2b74bab commit be3a2ba

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/kafka/SentryKafkaConsumerBeanPostProcessor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.sentry.spring.jakarta.kafka;
22

33
import io.sentry.ScopesAdapter;
4+
import io.sentry.SentryLevel;
45
import java.lang.reflect.Field;
56
import org.jetbrains.annotations.ApiStatus;
67
import org.jetbrains.annotations.NotNull;
@@ -50,6 +51,15 @@ public final class SentryKafkaConsumerBeanPostProcessor
5051
field.setAccessible(true);
5152
return (RecordInterceptor<?, ?>) field.get(factory);
5253
} catch (NoSuchFieldException | IllegalAccessException e) {
54+
ScopesAdapter.getInstance()
55+
.getOptions()
56+
.getLogger()
57+
.log(
58+
SentryLevel.WARNING,
59+
"Unable to read existing recordInterceptor from "
60+
+ "AbstractKafkaListenerContainerFactory via reflection. "
61+
+ "If you had a custom RecordInterceptor, it may not be chained with Sentry's interceptor.",
62+
e);
5363
return null;
5464
}
5565
}

sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/kafka/SentryKafkaRecordInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private void continueTrace(
141141
}
142142

143143
final @Nullable String enqueuedTimeStr =
144-
headerValue(record, SentryKafkaProducerWrapper.SENTRY_ENQUEUED_TIME_HEADER);
144+
headerValue(record, SentryProducerInterceptor.SENTRY_ENQUEUED_TIME_HEADER);
145145
if (enqueuedTimeStr != null) {
146146
try {
147147
final long enqueuedTime = Long.parseLong(enqueuedTimeStr);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class SentryKafkaRecordInterceptorTest {
7474
}
7575
enqueuedTime?.let {
7676
headers.add(
77-
SentryKafkaProducerWrapper.SENTRY_ENQUEUED_TIME_HEADER,
77+
SentryProducerInterceptor.SENTRY_ENQUEUED_TIME_HEADER,
7878
it.toString().toByteArray(StandardCharsets.UTF_8),
7979
)
8080
}

0 commit comments

Comments
 (0)