router
router copied to clipboard
expose the TraceId functionality to rhai
issue: #1935 suggested exposing a span's trace id via the Context. I think it's better to avoid further use of the context and provide direct acccess to the traceid from rhai. (Note: In case it isn't obvious the TraceId is the opentelemetry Span Id.)
If you ran code like the docs example, you'd see something like:
2022-10-10T11:37:58.404084Z INFO apollo_router::plugins::rhai: id: 338600282987103915558890515230971876324
fixes: #1935
also: drive by fix of the log_error in the surrogate example.
@garypen, please add a /NEXT_CHANGELOG.md entry for this PR to the appropriate section!
I'm not familiar with OpenTelemetry but this diff seems reasonable.
This exposes
apollo_router::tracer::TraceId as Displayto Rhai, which is based onu128 as Displayin decimal.opentelemetry::trace::TraceId as Displayhowever uses fixed-width hexadecimal. Is this difference (not new in this PR) deliberate?
It's not deliberate. We could change it now to be the same. I don't think that would count as a breaking change.