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 MDC attribute capture configuration #9758

Closed
stevesea opened this issue Oct 25, 2023 · 4 comments · Fixed by #10054
Closed

log4j MDC attribute capture configuration #9758

stevesea opened this issue Oct 25, 2023 · 4 comments · Fixed by #10054
Assignees
Labels
bug Something isn't working needs triage New issue that requires triage

Comments

@stevesea
Copy link

Describe the bug

the log4j1 instrumentation uses otel.instrumentation.log4j-appender.experimental.capture-mdc-attributes, which aligns with the name of the logback/jboss logging configuration

The log4j2 instrumentation uses otel.instrumentation.log4j-appender.experimental.capture-context-data-attributes

can log4j2 instrumentation be updated to use .capture-mdc-attributes, to align it with the log4j1, logback and jboss instrumentation?

Steps to reproduce

n/a

Expected behavior

if I want to capture MDC attributes, I should use `otel.instrumentation.{instrumentation-name}.experimental.capture-mdc-attributes

Actual behavior

log4j2 uses '.capture-context-data-attributes'

Javaagent or library instrumentation version

1.31.0

Environment

JDK: temurin 17
OS: centos

Additional context

No response

@stevesea stevesea added bug Something isn't working needs triage New issue that requires triage labels Oct 25, 2023
@trask
Copy link
Member

trask commented Oct 25, 2023

I'm not opposed to this, even though I don't believe Log4j2 calls it "MDC" (either in their API or in their documentation). This could allow us to have a single config, e.g.

otel.instrumentation.common.logging.capture-mdc-attributes

see also #8637 (comment)

@stevesea
Copy link
Author

stevesea commented Oct 26, 2023

I'd love to have a single config setting, rather than having separate framework-specific settings.

@mateuszrzeszutek
Copy link
Member

Interestingly, the ThreadContext javadoc even calls itself "MDC".

Should we perhaps use a more generic term and rename the properties to otel.instrumentation.common.logging.capture-diagnostic-attributes or otel.instrumentation.common.logging.capture-diagnostic-context-attributes?

@zeitlinger zeitlinger self-assigned this Dec 12, 2023
@zeitlinger
Copy link
Member

I would propose to use .capture-mdc-attributes everywhere, because many devs are familiar with that term.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New issue that requires triage
Projects
Development

Successfully merging a pull request may close this issue.

4 participants