Eduard Boloș
06/28/2024, 2:55 PMval traceId = Random.nextBytes(16).toHex()
val spanId = Random.nextULong()
val call = client.query(query)
.fetchPolicy(FetchPolicy.CacheFirst)
.refetchPolicy(FetchPolicy.NetworkOnly)
.httpHeaders(listOf(HttpHeader("x-cloud-trace-context", "${traceId}/${spanId};o=1")))
.watch(true, true)
.catch { e ->
maybeHandleCallException(e, traceId)
}
but I want traceId
to be different for each refetch, and in my catch I need the actual last value used.
To be honest, this is a bit of a made-up case, as the refetch policy we use is actually FetchPolicy.CacheOnly
, to there's at most one single HTTP request being made, but I would still like to know how this would be done in case that we would change the refetch policy to the one in the code snippet above.bod
06/28/2024, 3:22 PMrefetchPolicy
and implement something yourself?Eduard Boloș
06/28/2024, 3:46 PMbod
06/28/2024, 3:48 PMI would have to throw my own kind of exception that contains the trace ID, I guess.yeah something like that probably
Eduard Boloș
06/28/2024, 3:56 PMbod
06/28/2024, 3:57 PM