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

jboss-logmanager getMdcCopy() doesn't contain trace information #6111

Closed
ahus1 opened this issue May 28, 2022 · 0 comments · Fixed by #6112
Closed

jboss-logmanager getMdcCopy() doesn't contain trace information #6111

ahus1 opened this issue May 28, 2022 · 0 comments · Fixed by #6112
Labels
enhancement New feature or request

Comments

@ahus1
Copy link
Contributor

ahus1 commented May 28, 2022

Is your feature request related to a problem? Please describe.
The library jboss-logmanager contains since version 1.3 a new method getMdcCopy(). This one returns a map with all MDC attributes. In order to be able to log span/trace IDs for example in a JSON log, the return value should contain the values like getMdc(attribute) already supports.

Describe the solution you'd like
Extended the instrumentation to return a map that includes those attributes if they are now already set.

Describe alternatives you've considered
It would be possible to create a custom instrumentation, still I think this would be useful for everyone else as well.

Additional context

The version 1.3 has been release in Apr 2012, almost 10 years ago, and the API is available in the current versions as well.

I'll prepare a PR shortly later today.

This would allow to log the trace/span information in my setup where a Quarkus application logs JSON.
Before that change the MDC would be empty.

{"timestamp":"2022-05-28T14:33:44.197+02:00","sequence":8441,"loggerClassName":"org.jboss.logging.Logger","loggerName":"org.keycloak.events","level":"WARN","message":"type=LOGIN_ERROR, realmId=84f7eab5-4af2-40a3-ab44-783b76f5919a, c
lientId=null, userId=null, ipAddress=127.0.0.1, error=expired_code, restart_after_timeout=true, authSessionParentId=37f81c2c-2db1-4b7c-9a1c-6d0d7b2fd552, authSessionTabId=Xp6HO7eT8V4","threadName":"executor-thread-0","threadId":24,"mdc":{},"ndc":"","hostName":"tiny","processName":"QuarkusEntryPoint","processId":17268}

Now it contains the tracing information:

{"timestamp":"2022-05-28T14:33:44.197+02:00","sequence":8441,"loggerClassName":"org.jboss.logging.Logger","loggerName":"org.keycloak.events","level":"WARN","message":"type=LOGIN_ERROR, realmId=84f7eab5-4af2-40a3-ab44-783b76f5919a, clientId=null, userId=null, ipAddress=127.0.0.1, error=expired_code, restart_after_timeout=true, authSessionParentId=37f81c2c-2db1-4b7c-9a1c-6d0d7b2fd552, authSessionTabId=Xp6HO7eT8V4","threadName":"executor-thread-0","threadId":24,"mdc":{"trace_flags":"aa4a99929037cee4a35fb8666b924c04","trace_id":"aa4a99929037cee4a35fb8666b924c04","span_id":"aa4a99929037cee4a35fb8666b924c04"},"ndc":"","hostName":"tiny","processName":"QuarkusEntryPoint","processId":17268}

@ahus1 ahus1 added the enhancement New feature or request label May 28, 2022
ahus1 added a commit to ahus1/opentelemetry-java-instrumentation that referenced this issue May 28, 2022
This allows, for example, in JSON logs to have the MDC to contain span and trace information.
ahus1 added a commit to ahus1/opentelemetry-java-instrumentation that referenced this issue May 28, 2022
This allows, for example, in JSON logs to have the MDC to contain span and trace information.
ahus1 added a commit to ahus1/opentelemetry-java-instrumentation that referenced this issue May 28, 2022
This allows, for example, in JSON logs to have the MDC to contain span and trace information.
ahus1 added a commit to ahus1/opentelemetry-java-instrumentation that referenced this issue May 30, 2022
This allows, for example, in JSON logs to have the MDC to contain span and trace information.
ahus1 added a commit to ahus1/opentelemetry-java-instrumentation that referenced this issue May 30, 2022
This allows, for example, in JSON logs to have the MDC to contain span and trace information.
ahus1 added a commit to ahus1/opentelemetry-java-instrumentation that referenced this issue May 30, 2022
This allows, for example, in JSON logs to have the MDC to contain span and trace information.
trask pushed a commit that referenced this issue Jun 2, 2022
This allows, for example, in JSON logs to have the MDC to contain span and trace information.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant