Kamon
Kamon copied to clipboard
kamon-datadog and kamon-logback report trace id's differently, not configurable
kamon-datadog sends trace and span id's as BigInt, due to DataDog's requirement for these id's to be numeric. kamon-logback records trace id and spand id in hex. This causes issues correlating log and trace data. I'm surprised that there is no way to configure kamon-logback to log these id's as bigint's instead of Hex, given these differences.
traceId in logs: 4519eea8b9532d0f
traceId sent to DataDog APM: 4979273271465946383
I found this called out in your gitter: https://gitter.im/kamon-io/Kamon?at=5d7b2bfad3283306ba320417
but no answers. We've got a workaround, but the lack of ability to configure the data types to match each other has been a pain. Thanks!
Not the maintainer, but I don't think it's really fair to ask kamon-logback
, which is unrelated to Datadog, to cater to the strange choices of Datadog when it comes to trace/span IDs. Datadog really has gone in their own direction with 64-bit ints instead of 64- or 128-bit hex strings.
That said, I did hit this issue too. My workaround is to have:
package com.example
import ch.qos.logback.classic.pattern.ClassicConverter
import ch.qos.logback.classic.spi.ILoggingEvent
import kamon.Kamon
import kamon.trace.Identifier
class KamonDatadogTraceIdToLogback extends ClassicConverter {
override def convert(event: ILoggingEvent): String = {
val traceId = Kamon.currentSpan.trace.id
if (traceId == Identifier.Empty)
""
else
BigInt(traceId.string.takeRight(16), 16).toString
}
}
and in logback.xml
:
<conversionRule conversionWord="ddTraceId" converterClass="com.example.KamonDatadogTraceIdToLogback" />`
Note you have to do something similar with the span ID, since it's also a 64-bit Int.
This could probably be better documented in Kamon, since I imagine it's a common issue, but the configurability is there.