Uploaded image for project: 'JS - JS7 JobScheduler Engine'
  1. JS - JS7 JobScheduler Engine
  2. JS-2258

Controller and Agent stop logging when used with OpenTelemetry Java Agent

    XMLWordPrintable

Details

    Description

      We received the following problem report:

      Summary

      When the JS7 Controller (2.8.3) is started with the OpenTelemetry Java agent (-javaagent:/opt/opentelemetry-javaagent.jar), every log event triggers a java.lang.UnsupportedOperationException: entrySet originating from JS7's own js7.base.log.log4j.Log4jMap.

      Environment

      • JS7 Controller: 2.8.3
      • OpenTelemetry Java agent: 2.29.0
      • Log4j: 2.24.3

      Root Cause

      JS7's Log4jMap intentionally does not implement entrySet():

      def entrySet(): util.Set[Map.Entry[String, String]] =
        throw new UnsupportedOperationException("entrySet")

      The OpenTelemetry agent's Log4j context-data (MDC) instrumentation injects trace/span context into Log4j's ThreadContext. Log4j's ThreadContextDataInjector then calls HashMap.putMapEntries → Log4jMap.entrySet(), which throws.

      Impact

      • Log events (ControllerInitialized, ControllerReady, Prometheus /metrics startup, etc.) are not written to the log.
      • Appender creation also fails: Could not create plugin ... RollingRandomAccessFileAppender: UnsupportedOperationException: entrySet.
      • The controller still starts and becomes ready, but logging is kinda broken while the OTel agent is active.

      Steps to Reproduce

      1. Start the JS7 Controller with:
        JAVA_OPTIONS=-javaagent:/opt/opentelemetry-javaagent.jar
      2. Observe repeated UnsupportedOperationException: entrySet stack traces in the container output.
      3. Removing the -javaagent option eliminates the errors.

      Workaround

      Disable the OTel Log4j context-data injection (tracing/metrics remain functional) by use of the environment variable:
      OTEL_INSTRUMENTATION_LOG4J_CONTEXT_DATA_ENABLED=false

      Attachments

        Issue Links

          Activity

            People

              jz Joacim Zschimmer
              ap Andreas Püschel
              Karuna Pawar Karuna Pawar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: