question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Manually set baggage is not automatically cleaned up from MDC

See original GitHub issue

I have configured:

spring.sleuth:
  propagation-keys:
    - x-session-id
  log:
    slf4j:
      whitelisted-mdc-keys: x-session-id 

If I pass this propagation key with a value to my app as HTTP header then after the request is completed it is automatically removed from MDC by Slf4jScopeDecorator.

But if I don’t pass it as header but manually set the value somewhere during processing of the request then I have to manually set it to two places:

ExtraFieldPropagation.set(continuedSpan.context(), "x-session-id", "mySession123");
MDC.put("x-session-id", "mySession123");

and I also have to create an Interceptor and manually wipe it from MDC after the request processing has completed by calling: MDC.remove("my-key")

This is because Slf4jScopeDecorator only wipes any baggage that arrived with the request.

I propose to create a mechanism to register the value with single call (so it gets set in both to ExtraFieldPropagation and to MDC) and also after a value has been registered it would be automatically wiped from MDC after the request has completed.

Related StackOverflow post.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:23 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
dlsrb6342commented, Oct 17, 2019

This feature is not released yet I think.

1reaction
dlsrb6342commented, Aug 5, 2019

No. sleuth cannot clear MDC. In current implementation, previousMdc’s key set is consist of whited list keys that have non-null value. But, if you call ExtraFieldPropagation.set(key, value) after TraceWebFilter.filter(), there is no value in ExtraFieldPropagation when Slf4jScopeDecorator decorate current span.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - How to avoid manual cleanup when using baggage with ...
Is there any way to set the baggage value to Sleuth in a way that Sleuth itself sets it to MDC (and cleans...
Read more >
Spring Cloud Sleuth Features
In order to automatically set the baggage values to Slf4j's MDC, you have to set the spring.sleuth.baggage.correlation-fields property with a list of ...
Read more >
manual of procedure - Miami Dade College
To provide guidelines for the reimbursement of travel expenses incurred by Miami Dade College personnel, the District Board of Trustees, and ...
Read more >
MDC-360C OPERATION AND SERVICE MANUAL - INFICON
and upon examination by INFICON the equipment must be found not to ... The MDC-360C Deposition Controller can be set to operate one...
Read more >
OWNER'S MANUAL - MDC USA
That weight may not safely exceed the available cargo and luggage capacity calculated in Step # 4. 6. If your vehicle will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found