As far as I can tell, this is supposed to work (#931, #4405), but it doesn't - traceId changes when a suspended function resumes.
I've prepared a minimal failing example here: https://github.com/joedj/datadog-coroutine-trace-test
In the example I'm using dd-java-agent 1.20.1, kotlin 1.9.10 and kotlinx-coroutines-core 1.7.3, but it fails the same way on every version I've tried.
@Trace
suspend fun suspending(): Pair<String, String> {
val tracer = GlobalTracer.get()
val traceId1 = tracer.traceId
delay(1)
val traceId2 = tracer.traceId
return traceId1 to traceId2
}
@Test
fun `trace annotated suspend function`(): Unit = runBlocking {
// when
val (traceId1, traceId2) = suspending()
// then
assertNotNull(traceId1)
assertNotEquals(traceId1, "")
assertNotEquals(traceId1, "0")
assertEquals(traceId1, traceId2)
}
As far as I can tell, this is supposed to work (#931, #4405), but it doesn't -
traceIdchanges when a suspended function resumes.I've prepared a minimal failing example here: https://github.com/joedj/datadog-coroutine-trace-test
In the example I'm using dd-java-agent 1.20.1, kotlin 1.9.10 and kotlinx-coroutines-core 1.7.3, but it fails the same way on every version I've tried.
@Trace suspend fun suspending(): Pair<String, String> { val tracer = GlobalTracer.get() val traceId1 = tracer.traceId delay(1) val traceId2 = tracer.traceId return traceId1 to traceId2 } @Test fun `trace annotated suspend function`(): Unit = runBlocking { // when val (traceId1, traceId2) = suspending() // then assertNotNull(traceId1) assertNotEquals(traceId1, "") assertNotEquals(traceId1, "0") assertEquals(traceId1, traceId2) }