Skip to content

Fix pekko-connectors-kafka producer instrumentation on Scala 3 - #6

Merged
pjfanning merged 2 commits into
mainfrom
pekko-kafka-scala3-advice
Oct 10, 2026
Merged

pjfanning merged 2 commits into
mainfrom
pekko-kafka-scala3-advice

Conversation

@pjfanning

Copy link
Copy Markdown
Owner

Brings over kamon-io#1432 (fixes kamon-io#1416). Both commits cherry-picked cleanly onto `main`.

  • ProduceWithEnvelopeContext is now a class + companion object with @static methods, advised via classOf. On Scala 3, the static forwarders of a plain object drop parameter annotations, so ByteBuddy bound @Advice.Enter to the wrong argument.
  • CommittingProducerSinkStageLogic is added to within in reference.conf, and the method matcher also accepts its private ...$$produce name.
  • New ProducerMessageInstrumentationSpec, which uses Kafka's MockProducer and needs no broker.

Checked locally (Java 17): "+scalafmtCheckAll;scalafmtSbtCheck" passes and "+kamon-pekko-connectors-kafka/test" passes 3/3 on Scala 2.13.13 and 3.3.5.

🤖 Generated with Claude Code

pjfanning and others added 2 commits October 10, 2026 21:49
Scala 3 drops parameter annotations on the static forwarders of a plain
object, so ByteBuddy treated the exit advice's Storage.Scope parameter
as @argument(0) and failed to transform DefaultProducerStageLogic. Use a
class with @static methods, as the other Scala 3 instrumentations do.

Also instrument CommittingProducerSinkStageLogic, which was targeted but
missing from 'within' and whose private produce method is name-mangled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs the producer stages against Kafka's MockProducer, so no broker is
needed, and checks the Context captured on message creation is current
when the stage calls send. Fails without the fix: all three tests on
Scala 3, and the committable sink test on Scala 2.13.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pjfanning
pjfanning merged commit 8db726e into main Oct 10, 2026
2 of 3 checks passed
@pjfanning
pjfanning deleted the pekko-kafka-scala3-advice branch October 10, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[kamon-pekko-connectors-kafka] Kamon 2.8.1 throws IllegalStateException when using pekko-connectors-kafka 1.1.0

1 participant