kamon-io / kanela

The Kamon Instrumentation Agent
Apache License 2.0
68 stars 22 forks source link

Misleading error message: "Malformed configuration for module on path: _. The module will be ignored." #139

Closed oschrenk closed 2 years ago

oschrenk commented 2 years ago

I experienced a weird error where I tried to use Kamon and injected the kanela runner.

I saw

[main] WARNING 2022-05-11 15:24:08  Logger : Malformed configuration for module on path: akka. The module will be ignored.
...

[main] WARNING 2022-05-11 15:24:08  Logger : Malformed configuration for module on path: akka-remote-sharding. The module will be ignored

# with ... omitting the same error message for other modules

I thought I had a malformed configuration but after a long day of debugging, and in the end, forking kanela to add more error output I found out that the error message was misleading. The actual issue was that my docker on macOS was running out of space.

The actual exception was:

[main] WARNING 2022-05-11 21:24:04  Logger : Malformed configuration for module on path: executor-service. The module will be ignored.java.lang.RuntimeException: java.nio.file.FileSystemException: /tmp/tmp1331809339540428722: No space left on device
        at kanela.agent.libs.io.vavr.collection.HashSet.map(HashSet.java:711)
        at kanela.agent.libs.io.vavr.collection.HashSet.map(HashSet.java:39)
        at kanela.agent.util.conf.KanelaConfiguration.getAgentModules(KanelaConfiguration.java:92)
        at kanela.agent.InstrumentationLoader.load(InstrumentationLoader.java:43)
        at kanela.agent.Kanela.lambda$null$0(Kanela.java:79)
        at kanela.agent.util.classloader.InstrumentationClassPath.use(InstrumentationClassPath.java:84)
        at kanela.agent.Kanela.lambda$start$1(Kanela.java:68)
        at kanela.agent.util.Execution.timed(Execution.java:32)
        at kanela.agent.util.Execution.runWithTimeSpent(Execution.java:41)
        at kanela.agent.Kanela.start(Kanela.java:67)
        at kanela.agent.Kanela.premain(Kanela.java:47)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)

Why I could still build images I don't know but I was helped by running a simple docker system prune - far away from a malformed configuration.

It would be great if the error message would be better and would actually show the stack trace or at least message of the actual issue.

The IO Exception is replaced with a runtime exception here:

https://github.com/kamon-io/kanela/blob/master/agent/src/main/java/kanela/agent/util/conf/KanelaConfiguration.java#L312

and then that RuntimeException is ignored for the log output here:

https://github.com/kamon-io/kanela/blob/867d2f2594cdbc5d0a5adb89c8514f0d24ec348f/agent/src/main/java/kanela/agent/util/conf/KanelaConfiguration.java#L125