Repository navigation
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1416.
Cause
ProduceWithEnvelopeContextwas a plainobject, and theadvise(method, SomeObject)helper hands Kanela the generated class holding its static forwarders. On Scala 3 those forwarders keep the method annotations but drop the parameter annotations (confirmed withjavapon 2.13 vs 3.3.5). With no annotation, ByteBuddy binds a parameter as@Advice.Argument(index), soexit(@Advice.Enter scope: Storage.Scope)was bound toproduce'sProducerMessage$Envelopeargument:Changes
class+ companionobjectwith@staticmethods, advised viaclassOf[...], the same pattern the other Scala 3 instrumentations use. Parameter annotations are now present on both 2.13 and 3.CommittingProducerSinkStageLogicwas listed in the instrumentation but was missing fromwithininreference.conf, so it was never instrumented. I've added it. Itsproduceis private and compiles toorg$apache$pekko$kafka$internal$CommittingProducerSinkStageLogic$$produce(same in connectors-kafka 1.0.0 and 1.2.0, Scala 2.13 and 3), so the method matcher now also accepts names ending in$$produce.Testing
Added
ProducerMessageInstrumentationSpec, which runs with the Kanela agent and needs no Kafka broker: the producer stages use Kafka'sMockProducer(viaProducerSettings.withProducer), which recordsKamon.currentContext()whensendis called. It coversMessageandMultiMessagethroughProducer.flexiFlow(DefaultProducerStageLogic) and a committable message throughProducer.committableSink(CommittingProducerSinkStageLogic, with a fake committer frompekko-connectors-kafka-testkit).Passes on Scala 2.13 and 3.3.5. Without the fix, it fails all three tests on Scala 3 (with the same
Failed to transformerror as in the issue) and the committable sink test on Scala 2.13.🤖 Generated with Claude Code