kamon-io / kamon-logback

12 stars 17 forks source link

Instrumentation does not remove tags from MDC #23

Closed carstenlenz closed 5 years ago

carstenlenz commented 5 years ago

When having kamon.instrumentation.logback.mdc.copy.tags = yes the tags are put into the MDC will stay in the MDC forever (well... on that thread ... as long as the thread lives...)

In https://github.com/kamon-io/kamon-logback/blob/a26cf66a66ff21b2bfe61693454c76ab1c94375d/src/main/scala/kamon/instrumentation/logback/LogbackInstrumentation.scala#L115-L119 only traceID spanID and configured entries get removed.

Is it ok to remove tags as well?

ivantopo commented 5 years ago

Hey @carstenlenz!

Indeed, tags should be removed as well. Otherwise, we risk mixing data from requests that don't have certain tags with the data from the last request that had those tags in a given thread. No good!

Are you up for raising a quick PR? :wink:

carstenlenz commented 5 years ago

Yes ! :)

There are essentially two ways of doing it:

I tried doing the first one but can provide the other solution as well.