Skip to content

Conversation

@SylvainJuge
Copy link
Member

@SylvainJuge SylvainJuge commented Jun 24, 2025

With the upstream otel agent, when the otel.javaagent.debug option is set to true, an additional span logging exporter is added when there is none, that means spans start/and are logged at INFO level when otel.javaagent.debug is set to true.

Our current implementation of dynamic log level does currently replicates this behavior, which means that when the dynamic log level is set to DEBUG the resulting behavior is not exactly equivalent to setting otel.javaagent.debug=true with the upstream agent.

This PR replicates this behavior by doing the following:

  • when an logging exporter is already configured, we let the configured one log the spans, which means span logging will happen whenever log level is INFO or above.
  • when no logging exporter is configured, we add a dedicated SpanExporter that can be controlled at runtime, then when the log level is set to DEBUG or above we can then control this extra span exporter at runtime when needed.
  • when the upstream debug config option is used, use the same plain text output as the upstream agent
  • when setting our own logger level to debug, use the json output for easier log parsing.

Feature documentation is covered in elastic/opentelemetry#315

@SylvainJuge SylvainJuge self-assigned this Jun 24, 2025
@SylvainJuge SylvainJuge marked this pull request as ready for review June 26, 2025 13:08
@SylvainJuge SylvainJuge requested a review from a team as a code owner June 26, 2025 13:08
jackshirazi
jackshirazi previously approved these changes Jun 26, 2025
@SylvainJuge SylvainJuge enabled auto-merge (squash) June 27, 2025 13:07
@SylvainJuge SylvainJuge merged commit 1255e39 into elastic:main Jun 27, 2025
14 checks passed
@SylvainJuge SylvainJuge deleted the debug-spans-logging branch June 27, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants