You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ClickHouse accepts trace context HTTP headers, as described by the W3C recommendation. It also accepts trace context over a native protocol that is used for communication between ClickHouse servers or between the client and server.
However there doesn't appear to be any way to set these given the current client interface. You can set the request headers once during createClient but for the headers to be useful they need to be settable for each query, as each query will have a different traceparent.
I've temporarily found a work around for this using some gross Proxy magic and intercepting the serialisation of the header with Symbol.toPrimitive and then setting the module global currentSpan just before calling client.query. This is very fragile though as it relies upon the header being serialised without yielding back to the event loop potentially causing currentSpan to be set to a different value. While this is currently true, it is certainly not an invariant guaranteed by the API and could break at any time.
Following up from the above hack with Symbol.toPromitive, after further testing it is not at all reliable, I guess we do yield back to the event loop in between setting the global currentSpan and the header being serialised. I've opened a PR #395, that adds the ability to specify the headers when querying.
Use case
Being able to associate the traces in system.opentelemetry_span_log with a client query. As documented here
Describe the solution you'd like
Clickhouse documentation states that
However there doesn't appear to be any way to set these given the current client interface. You can set the request headers once during
createClient
but for the headers to be useful they need to be settable for each query, as each query will have a different traceparent.The text was updated successfully, but these errors were encountered: