Commit 0ca42c8
ref(kafka): Reimplement SentryKafkaProducer as a dynamic Proxy
Replace the concrete `implements Producer<K,V>` class with a
`Proxy.newProxyInstance`-based wrapper that intercepts only the two
`send()` overloads and forwards every other method reflectively to
the delegate.
The concrete class required explicitly delegating every method on the
`Producer` interface, coupling the wrapper to a specific Kafka version:
`clientInstanceId(Duration)` was added in Kafka 3.7, and the deprecated
`sendOffsetsToTransaction(Map, String)` was removed in Kafka 4.0. The
dynamic proxy has no such coupling — new or removed interface methods are
handled automatically, giving full compatibility across all Kafka
client versions.
Public API change: `SentryKafkaProducer` is now a utility class with
static `wrap()` overloads instead of constructors. Callers wrap a
producer with `SentryKafkaProducer.wrap(producer)`. The Spring BPP and
console sample are updated accordingly.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 1e293c6 commit 0ca42c8
6 files changed
Lines changed: 219 additions & 267 deletions
File tree
- sentry-kafka
- api
- src
- main/java/io/sentry/kafka
- test/kotlin/io/sentry/kafka
- sentry-samples/sentry-samples-console/src/main/java/io/sentry/samples/console/kafka
- sentry-spring-jakarta/src
- main/java/io/sentry/spring/jakarta/kafka
- test/kotlin/io/sentry/spring/jakarta/kafka
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
34 | 18 | | |
35 | 19 | | |
0 commit comments