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

Log4J appender open telemetry installation should be possible via log4j config #12468

Open
faucct opened this issue Oct 18, 2024 · 4 comments
Open
Labels
enhancement New feature or request needs triage New issue that requires triage

Comments

@faucct
Copy link

faucct commented Oct 18, 2024

Is your feature request related to a problem? Please describe.

In some applications, for example Spark, it is not trivial to add arbitrary initialization code running on startup:
https://spark.apache.org/docs/3.5.1/configuration.html#configuring-logging
As this appender forces you to write Java code, this makes it hard to plug it into Spark, if not impossible:
https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/log4j/log4j-appender-2.17/library#usage

Describe the solution you'd like

I would like the OpenTelemetry installation to be possible via log4j configuration.
Here is an example of it from another plugin:
https://github.com/tkowalcz/tjahzi/tree/master/log4j2-appender

Describe alternatives you've considered

No response

Additional context

No response

@faucct faucct added enhancement New feature or request needs triage New issue that requires triage labels Oct 18, 2024
@olabodeIdowu

This comment was marked as spam.

@greatvovan
Copy link
Contributor

I am not a maintainer of OpenTelemetry, but my understanding is that the examples you gave are self-sufficient appenders, whereas OpenTelemetryAppender is supposed to act like a bridge between the logging framework and the instrumentation ecosystem. The appender itself does not know where to export the logs – that should be configured downstream in the SDK instance, hence the connection must be made somehow.

You can, however, access the logging configuration in runtime and tweak it by adding OpenTelemetryAppender, like in the linked issue's discussion. I know, this is not ideal, since it affects the logging system globally and needs to be synchronized across workloads, but may be useful in single-job clusters or with orchestrated workloads.

@faucct
Copy link
Author

faucct commented Oct 27, 2024

You are right about just opentelemetry-log4j-appender-2.17 being not enough to implement exporting to specific endpoint and needing extra libraries, but if for example it would configure itself to use the static GlobalOpenTelemetry.get(), then you could add the opentelemetry-exporter-otlp JARs and the rest would be configurable via -Dotel.exporter.otlp.* properties:

openTelemetryAppender.setOpenTelemetry(GlobalOpenTelemetry.get())

@greatvovan
Copy link
Contributor

Makes sense, could possibly work with GlobalOpenTelemetry and a config attribute instructing to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New issue that requires triage
Projects
None yet
Development

No branches or pull requests

3 participants