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

= kamon-core: add context name and token to MDC #363

Merged
merged 1 commit into from Jul 3, 2016

Conversation

Projects
None yet
2 participants
@dspasojevic

dspasojevic commented Jun 18, 2016

This change pushes the trace name and token into the MDC. This means that they can be accessed in async appenders using the normal mechanism - without using the LogbackTraceTokenConverter.

@@ -34,7 +39,12 @@ trait MdcKeysSupport {
private[this] def copyToMdc(traceContext: TraceContext): Iterable[String] = traceContext match {
case ctx: MetricsOnlyContext
ctx.traceLocalStorage.underlyingStorage.collect {
// Add the default key value pairs for the trace token and trace name.

This comment has been minimized.

@dpsoft

dpsoft Jun 22, 2016

Contributor

@dspasojevic @ivantopo I think that instead of using:

val traceTokenKey = "traceToken"
val traceNameKey = "traceName"

private val defaultKeys = Seq(traceTokenKey, traceNameKey)

MDC.put(traceTokenKey, ctx.token)
MDC.put(traceNameKey, ctx.name)

we can use the kamon api like this:

val TraceTokenKey = AvailableToMdc.fromKey("traceToken")
val TraceNameKey = AvailableToMdc.fromKey("traceName")

TraceLocal.store(TraceTokenKey)(ctx.token)
TraceLocal.store(TraceNameKey)(ctx.name)

this is only a idea, please guys WDYT?

This comment has been minimized.

@dspasojevic

dspasojevic Jun 23, 2016

That is fine with me.

It does mean that calling withMdc has the side-effect of modifying TraceLocal's storage though. At the moment, it should return the MDC and TraceLocal storage to the initial state.

This comment has been minimized.

@dpsoft

dpsoft Jun 23, 2016

Contributor

I see your point, and I think that is a good point :). @ivantopo?

@dspasojevic

This comment has been minimized.

dspasojevic commented Jul 1, 2016

@dpsoft are there any changes that you would like to this PR?

@dpsoft dpsoft merged commit 0a106c8 into kamon-io:master Jul 3, 2016

@dpsoft

This comment has been minimized.

Contributor

dpsoft commented Jul 3, 2016

@dspasojevic thanks for proposing this PR!!!! Done.

@dspasojevic dspasojevic deleted the dspasojevic:mdc branch Jul 14, 2016

dpsoft added a commit that referenced this pull request Dec 4, 2016

Merge pull request #363 from dspasojevic/mdc
= kamon-core: add context name and token to MDC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment