Repository navigation
keep the parameter annotations of two advices on Scala 3 - #1435
Open
Dichotomia wants to merge 1 commit into
Open
Dichotomia wants to merge 1 commit into
Dichotomia wants to merge 1 commit into
Conversation
On Scala 3, the static forwarders generated for a plain object do not carry the parameter annotations of its methods, and Kanela reads the advice from those forwarders. ProduceWithEnvelopeContext and CaptureCurrentTimestampOnExit were plain objects, so on kamon-bundle_3 their @Advice.Enter / @Advice.Argument / @Advice.This were lost: ByteBuddy bound exit's scope as @Advice.Argument(0) and failed to transform DefaultProducerStageLogic with "Cannot assign final org.apache.pekko.kafka.ProducerMessage$Envelope in to interface kamon.context.Storage$Scope" (kamon-io#1416). Both now follow the pattern the other advices already use: a private companion class and @static methods. The new specs read the parameter annotations of the static advice methods by reflection; they fail on Scala 3 before this change and pass on 2.13 and 3 after it.
Author
|
I've signed the CLA. |
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.
On Scala 3, the static forwarders of a plain
objectdon't carry the parameter annotations of its methods, and Kanela reads the advice from those forwarders.ProduceWithEnvelopeContextandCaptureCurrentTimestampOnExitwere plain objects, so onkamon-bundle_3their@Advice.Enter/@Advice.Argument/@Advice.Thiswere lost. ByteBuddy then boundexit'sscopeas@Advice.Argument(0)and failed to transformDefaultProducerStageLogicwithCannot assign final org.apache.pekko.kafka.ProducerMessage$Envelope in to interface kamon.context.Storage$Scope. The module became Scala 3 in #1397, which only added the cross version.Both advices now follow the pattern the other advices already use (
CaptureCurrentTimestampOnEnter,HikariInstrumentation): a private companion class and@staticmethods.The two new specs read the parameter annotations of the static advice methods by reflection. They fail on Scala 3 before the change (
Map("enter" -> List(List()), "exit" -> List(List()))) and pass on 2.13 and 3 after it, along with the rest ofkamon-instrumentation-commonandkamon-pekko-connectors-kafka(++ 2.13.13!and++ 3.3.5!).scalafmtCheckAllis clean on both modules.A scan of the static advice methods with parameters in
kamon-bundle_3-2.8.1found no other advice in this situation.