Closed greatvovan closed 1 month ago
Firstly you should check what version of opentelemetry dependencies you have. Instrumentation 2.8.0
is compatible with otel api/sdk 1.42.1
. If you see a different version (which is probably so based on the exception you get) you'll have to find a way to deal with it. In maven and gradle you'd import the BOM to enforce the versions, in sbt I have no idea what you'll need to do.
You might be right... After inspecting the package version in runtime, opentelemetry-api was of version 1.42.1, and opentelemetry-sdk was 1.40.0. Importing opentelemetry-bom v1.42.1 did not change a thing, but
libraryDependencies += "io.opentelemetry" % "opentelemetry-sdk" % "1.42.1"
did. It is unfortunate that the default referenced versions are inconsistent.
It is unfortunate that the default referenced versions are inconsistent.
opentelemetry-log4j-appender-2.17
does not have a dependency on the sdk, it is users responsibility to bring in a compatible sdk. You probably get your sdk through azure-monitor-opentelemetry-exporter
. Usually one would use a bom to align the versions, idk if sbt supports boms at all.
Anyway, I have a working solution for now. Thanks for your help.
Describe the bug
AppenderLoggingException on logging with Appenders by opentelemetry-log4j-appender-2.17, opentelemetry-logback-appender-1.0 of version 2.8.0-alpha.
Steps to reproduce
sbt:
Scala:
sbt run
Expected behavior
Logging works emitting a message. No exceptions are thrown.
Actual behavior
Error::
ERROR An exception occurred processing Appender Otel org.apache.logging.log4j.core.appender.AppenderLoggingException: java.lang.NoClassDefFoundError: io/opentelemetry/api/incubator/logs/AnyValue
```text at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:164) at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:133) at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:124) at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:88) at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:714) at org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:672) at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:648) at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:584) at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:92) at org.apache.logging.log4j.core.Logger.log(Logger.java:240) at org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2904) at org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2857) at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2839) at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2618) at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:2565) at org.apache.logging.log4j.spi.AbstractLogger.info(AbstractLogger.java:1568) at Main$.delayedEndpoint$Main$1(Main.scala:39) at Main$delayedInit$body.apply(Main.scala:1) at scala.Function0.apply$mcV$sp(Function0.scala:42) at scala.Function0.apply$mcV$sp$(Function0.scala:42) at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17) at scala.App.$anonfun$main$1(App.scala:98) at scala.App.$anonfun$main$1$adapted(App.scala:98) at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:576) at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:574) at scala.collection.AbstractIterable.foreach(Iterable.scala:933) at scala.App.main(App.scala:98) at scala.App.main$(App.scala:96) at Main$.main(Main.scala:1) at Main.main(Main.scala) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at sbt.Run.invokeMain(Run.scala:144) at sbt.Run.execute$1(Run.scala:94) at sbt.Run.$anonfun$runWithLoader$5(Run.scala:121) at sbt.Run$.executeSuccess(Run.scala:187) at sbt.Run.runWithLoader(Run.scala:121) at sbt.Defaults$.$anonfun$bgRunTask$6(Defaults.scala:2038) at sbt.Defaults$.$anonfun$termWrapper$2(Defaults.scala:1977) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) at scala.util.Try$.apply(Try.scala:213) at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:367) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) at java.base/java.lang.Thread.run(Thread.java:1570) Caused by: java.lang.NoClassDefFoundError: io/opentelemetry/api/incubator/logs/AnyValue at io.opentelemetry.sdk.logs.SdkLogRecordBuilder.setBody(SdkLogRecordBuilder.java:91) at io.opentelemetry.sdk.logs.SdkLogRecordBuilder.setBody(SdkLogRecordBuilder.java:24) at io.opentelemetry.instrumentation.log4j.appender.v2_17.internal.LogEventMapper.captureMessage(LogEventMapper.java:129) at io.opentelemetry.instrumentation.log4j.appender.v2_17.internal.LogEventMapper.mapLogEvent(LogEventMapper.java:94) at io.opentelemetry.instrumentation.log4j.appender.v2_17.OpenTelemetryAppender.emit(OpenTelemetryAppender.java:303) at io.opentelemetry.instrumentation.log4j.appender.v2_17.OpenTelemetryAppender.append(OpenTelemetryAppender.java:247) at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:160) ... 44 more Caused by: java.lang.ClassNotFoundException: io.opentelemetry.api.incubator.logs.AnyValue at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445) at sbt.internal.ManagedClassLoader.findClass(ManagedClassLoader.java:103) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) ... 51 more ```Javaagent or library instrumentation version
2.8.0-alpha
Environment
Scala: 2.13 OS: 14.6.1 (23G93)
Additional context
Switching to version 2.7.0-alpha fixes the problem.