apollographql / router

A configurable, high-performance routing runtime for Apollo Federation 🚀
https://www.apollographql.com/docs/router/
Other
807 stars 272 forks source link

AWS X-Ray traceId handling in router #3445

Open laszlorostas opened 1 year ago

laszlorostas commented 1 year ago

We want to examine the router as a trace in aws x-ray. Currently, only one format of traceid is possible for the router.

It would be nice if, say, a custom traceid solution could be brought via a rhai script

bnjjj commented 1 year ago

Have you ever tried to use request propagation mentioned here ?

laszlorostas commented 1 year ago

I know it, but as far as I know, the traceid format that the router generates for them is the same. But a completely unique traceId format, such as UUID or X-ray format, is discarded by the router.

abernix commented 1 year ago

I'm curious if @bnjjj was referring to the section of the documentation that suggests using a custom header, which exists on that page (link to highlighted part):

      # If you have your own way to generate a trace id and you want to pass it via a custom request header
      request:
        header_name: my-trace-id

For example, what if you did:

      # If you have your own way to generate a trace id and you want to pass it via a custom request header
      request:
        header_name: X-Amzn-Trace-Id

Is that sufficient?

scottmace commented 1 year ago

The X-Amzn-Trace-ID header format is not directly compatible with the OpenTelemetry TraceID format. Specifying it as the header_name above results in a "cannot generate custom trace_id" error.

The AWS X-Ray Propagator used in that PR handles converting back and forth between the X-Amzn-Trace-ID header and a valid OpenTelemetry Trace ID:

https://github.com/open-telemetry/opentelemetry-rust/blob/41e8d63652b323866c03981b4b2ca62b9b8d6d44/opentelemetry-aws/src/lib.rs#L74

o0Ignition0o commented 10 months ago

CC @BrynCooke @bnjjj we might need to update the configuration in the #3226 efforts.