Skip to content

Remove Tracer#logClearingTrace()#947

Closed
schlosna wants to merge 2 commits intodevelopfrom
ds/remove-logClearingTrace
Closed

Remove Tracer#logClearingTrace()#947
schlosna wants to merge 2 commits intodevelopfrom
ds/remove-logClearingTrace

Conversation

@schlosna
Copy link
Contributor

Before this PR

LOG4J2-3560 is triggering significant allocations on calls to Logger#isDebugEnabled() such as from Tracer#logClearingTrace()

static void clearCurrentTrace() {
logClearingTrace();
currentTrace.set(null);
MDC.remove(Tracers.TRACE_ID_KEY);
MDC.remove(Tracers.TRACE_SAMPLED_KEY);
MDC.remove(Tracers.REQUEST_ID_KEY);
}
private static void logClearingTrace() {
if (log.isDebugEnabled()) {
log.debug("Clearing current trace", SafeArg.of("trace", currentTrace.get()));
if (log.isTraceEnabled()) {
log.trace("Stacktrace at time of clearing trace", new SafeRuntimeException("not a real exception"));
}
}
}

Long term upstream fix for log4j is proposed as apache/logging-log4j2#974 ; however, we may want to consider removing Tracer#logClearingTrace() in the interim as it impacts services that heavily utilize tracing, such as timelock & atlasdb's AwaitingLeadershipProxy

After this PR

==COMMIT_MSG==
Remove Tracer#logClearingTrace()
==COMMIT_MSG==

Possible downsides?

We lose the debug & trace logging @tpetracca added in #678 though I don't think this is used often if ever.

@changelog-app
Copy link

changelog-app bot commented Jul 23, 2022

Generate changelog in changelog/@unreleased

Type
See change types. Select one:

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Remove Tracer#logClearingTrace()

Check the box to generate changelog(s)

  • Generate changelog entry

@schlosna
Copy link
Contributor Author

Going to close this out for now, will reopen if needed

@schlosna schlosna closed this Jul 25, 2022
@schlosna
Copy link
Contributor Author

#1413

@schlosna schlosna deleted the ds/remove-logClearingTrace branch August 13, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants