-
Notifications
You must be signed in to change notification settings - Fork 913
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
Logback: don't make MDCPropertyMap of logging event immutable #12718
Conversation
import ch.qos.logback.core.spi.AppenderAttachableImpl; | ||
import java.util.Iterator; | ||
|
||
public class TestAppender extends UnsynchronizedAppenderBase<ILoggingEvent> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public class TestAppender extends UnsynchronizedAppenderBase<ILoggingEvent> | |
class TestAppender extends UnsynchronizedAppenderBase<ILoggingEvent> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this class must be public
...y/src/test/java/io/opentelemetry/instrumentation/logback/mdc/v1_0/internal/UnionMapTest.java
Show resolved
Hide resolved
if (eventContext == null) { | ||
eventContext = contextData; | ||
} else { | ||
eventContext = new UnionMap<>(eventContext, contextData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was there some benefit in retaining both individual maps with the use of UnionMap
that we lose now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It avoided copying the original map.
runWithSpanAndBaggage("test", baggage, () -> logger.info("log message")); | ||
|
||
assertThat(testAppender.lastEvent.getMessage()).isEqualTo("log message"); | ||
Map<String, String> map = testAppender.lastEvent.getMDCPropertyMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two instrumentation points:
Line 54 in 8ff6cb0
.and(namedOneOf("getMDCPropertyMap", "getMdc")) |
Is there any reason to miss
getMdc
test here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a library instrumentation tests. It only serves as a regression test to ensure that we don't accidentally introduce something similar to the union map in the future.
Resolves #12615