Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish instrumentation artifacts for Scala 3 #1064

Open
ivantopo opened this issue Oct 21, 2021 · 2 comments
Open

Publish instrumentation artifacts for Scala 3 #1064

ivantopo opened this issue Oct 21, 2021 · 2 comments

Comments

@ivantopo
Copy link
Contributor

We went through upgrading the core libraries and reporters for Scala 3, but all the instrumentation is still pending. I got this exception at my very first attempt at running the instrumentation-common tests with Scala 3 and thought that instead of delaying a new release even more we should publish the parts that are already supported, and create this issue to track instrumentation updates.

[pool-1-thread-1-ScalaTest-running-ContextInstrumentationSpec] ERROR 2021-10-21 09:55:12  Logger : Error => kamon.instrumentation.context.ContextInstrumentationSpec$Target with message public kamon.context.Context kamon.instrumentation.context.ContextInstrumentationSpec$Target.doWork() does not define an index 0. Class loader: sun.misc.Launcher$AppClassLoader@18b4aac2: java.lang.IllegalStateException: public kamon.context.Context kamon.instrumentation.context.ContextInstrumentationSpec$Target.doWork() does not define an index 0
	at kanela.agent.libs.net.bytebuddy.asm.Advice$OffsetMapping$ForArgument$Unresolved.resolve(Advice.java:1664)
	at kanela.agent.libs.net.bytebuddy.asm.Advice$OffsetMapping$ForArgument.resolve(Advice.java:1575)
	at kanela.agent.libs.net.bytebuddy.asm.Advice$OffsetMapping$ForArgument$Unresolved.resolve(Advice.java:1683)
	at kanela.agent.libs.net.bytebuddy.asm.Advice$Dispatcher$Inlining$Resolved$ForMethodEnter.doApply(Advice.java:8305)
	at kanela.agent.libs.net.bytebuddy.asm.Advice$Dispatcher$Inlining$Resolved$ForMethodEnter.apply(Advice.java:8266)
	at kanela.agent.libs.net.bytebuddy.asm.Advice$Dispatcher$Inlining$Resolved$AdviceMethodInliner.visitMethod(Advice.java:7970)
	at kanela.agent.libs.net.bytebuddy.jar.asm.ClassReader.readMethod(ClassReader.java:1353)
	at kanela.agent.libs.net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:744)
	at kanela.agent.libs.net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:424)
	at kanela.agent.libs.net.bytebuddy.asm.Advice$Dispatcher$Inlining$Resolved$AdviceMethodInliner.apply(Advice.java:7964)
	at kanela.agent.libs.net.bytebuddy.asm.Advice$AdviceVisitor.onAfterExceptionTable(Advice.java:10108)
	at kanela.agent.libs.net.bytebuddy.utility.visitor.ExceptionTableSensitiveMethodVisitor.considerEndOfExceptionTable(ExceptionTableSensitiveMethodVisitor.java:49)
	at kanela.agent.libs.net.bytebuddy.utility.visitor.ExceptionTableSensitiveMethodVisitor.visitLabel(ExceptionTableSensitiveMethodVisitor.java:81)
	at kanela.agent.libs.net.bytebuddy.jar.asm.Label.accept(Label.java:358)
	at kanela.agent.libs.net.bytebuddy.jar.asm.ClassReader.readCode(ClassReader.java:2057)
	at kanela.agent.libs.net.bytebuddy.jar.asm.ClassReader.readMethod(ClassReader.java:1514)
	at kanela.agent.libs.net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:744)
	at kanela.agent.libs.net.bytebuddy.jar.asm.ClassReader.accept(ClassReader.java:424)
	at kanela.agent.libs.net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining.create(TypeWriter.java:3919)
	at kanela.agent.libs.net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:2193)
	at kanela.agent.libs.net.bytebuddy.dynamic.scaffold.inline.RebaseDynamicTypeBuilder.make(RebaseDynamicTypeBuilder.java:250)
	at kanela.agent.libs.net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.doTransform(AgentBuilder.java:11362)
	at kanela.agent.libs.net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.transform(AgentBuilder.java:11298)
	at kanela.agent.libs.net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.access$1700(AgentBuilder.java:11016)
	at kanela.agent.libs.net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer$LegacyVmDispatcher.run(AgentBuilder.java:11690)
	at kanela.agent.libs.net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer$LegacyVmDispatcher.run(AgentBuilder.java:11637)
	at java.security.AccessController.doPrivileged(Native Method)
	at kanela.agent.libs.net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.doPrivileged(AgentBuilder.java)
	at kanela.agent.libs.net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.transform(AgentBuilder.java:11205)
	at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
	at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at kamon.instrumentation.context.ContextInstrumentationSpec.f$proxy1$1(ContextInstrumentationSpec.scala:15)
	at kamon.instrumentation.context.ContextInstrumentationSpec.$init$$$anonfun$2$$anonfun$1(ContextInstrumentationSpec.scala:14)
	at org.scalatest.Transformer.apply$$anonfun$1(Transformer.scala:22)
	at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
	at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:31)
	at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
	at org.scalatest.Transformer.apply(Transformer.scala:22)
	at org.scalatest.Transformer.apply(Transformer.scala:21)
	at org.scalatest.wordspec.AnyWordSpecLike$$anon$3.apply(AnyWordSpecLike.scala:1105)
	at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
	at org.scalatest.TestSuite.withFixture$(TestSuite.scala:138)
	at org.scalatest.wordspec.AnyWordSpec.withFixture(AnyWordSpec.scala:1879)
	at org.scalatest.wordspec.AnyWordSpecLike.invokeWithFixture$1(AnyWordSpecLike.scala:1111)
	at org.scalatest.wordspec.AnyWordSpecLike.runTest$$anonfun$1(AnyWordSpecLike.scala:1115)
	at org.scalatest.SuperEngine.runTestImpl(Engine.scala:306)
	at org.scalatest.wordspec.AnyWordSpecLike.runTest(AnyWordSpecLike.scala:1115)
	at org.scalatest.wordspec.AnyWordSpecLike.runTest$(AnyWordSpecLike.scala:44)
	at org.scalatest.wordspec.AnyWordSpec.runTest(AnyWordSpec.scala:1879)
	at org.scalatest.wordspec.AnyWordSpecLike.runTests$$anonfun$1(AnyWordSpecLike.scala:1174)
	at org.scalatest.SuperEngine.traverseSubNodes$2$$anonfun$1(Engine.scala:413)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:429)
	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:390)
	at org.scalatest.SuperEngine.traverseSubNodes$2$$anonfun$1(Engine.scala:427)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:333)
	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:429)
	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:396)
	at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:475)
	at org.scalatest.wordspec.AnyWordSpecLike.runTests(AnyWordSpecLike.scala:1174)
	at org.scalatest.wordspec.AnyWordSpecLike.runTests$(AnyWordSpecLike.scala:44)
	at org.scalatest.wordspec.AnyWordSpec.runTests(AnyWordSpec.scala:1879)
	at org.scalatest.Suite.run(Suite.scala:1112)
	at org.scalatest.Suite.run$(Suite.scala:563)
	at org.scalatest.wordspec.AnyWordSpec.org$scalatest$wordspec$AnyWordSpecLike$$super$run(AnyWordSpec.scala:1879)
	at org.scalatest.wordspec.AnyWordSpecLike.run$$anonfun$1(AnyWordSpecLike.scala:1219)
	at org.scalatest.SuperEngine.runImpl(Engine.scala:535)
	at org.scalatest.wordspec.AnyWordSpecLike.run(AnyWordSpecLike.scala:1219)
	at org.scalatest.wordspec.AnyWordSpecLike.run$(AnyWordSpecLike.scala:44)
	at org.scalatest.wordspec.AnyWordSpec.run(AnyWordSpec.scala:1879)
	at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:318)
	at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:513)
	at sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:413)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748) 

@vaslabs
Copy link
Contributor

vaslabs commented Jul 29, 2022

It looks to me like a scala 3 issue, where parameter annotations are missing from the bytecode

#1191

@vaslabs
Copy link
Contributor

vaslabs commented Jul 29, 2022

Ok found a fix for this, it's in the above PR, but it's a PoC, it passes the test for scala 3 but it needs code changes to keep compatibility for older versions + do the work for all the classes that have parameter annotations

EDIT: I think it should be ready to be tested. Also needed for kamon-http4s

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

No branches or pull requests

2 participants