Tyk OpenTelemetry Trace Context Propagation

I’m having issues correlating traces from frontend/mobile apps as tyk always regenerates the trace ID instead of propagating the trace ID sent to the gateway. This is my opentelemetry configuration:

    "opentelemetry": {
      "enabled": true,
      "endpoint": "otel-collector.opentelemetry.svc:4317",
      "connection_timeout": 10,
      "resource_name": "tyk-gateway",
      "context_propagation": "tracecontext",
      "sampling": {
            "type": "TraceIDRatioBased",
            "rate": 0.1,
            "parent_based": false
        }
    }

I am using tyk OSS v5.2.2

hello azunna1 and welcome to the community :raised_hands:

If the trace context headers are already set on the request made to Tyk gateway, Tyk will re-use the same trace id and continue the trace. You have correctly set tracecontext as the context propagation format (which is also the default one), so that should work as expected.

Have you validated that your frontend/mobile app is adding the trace-context headers to the requests sent to Tyk? Is your frontend/mobile app sending calls directly to Tyk or is there any other components in between? If there’s a component in between they might be removing those headers.

I hope this helps,
Sonja

Hi @sonja Thanks for your response. I did a little more digging and i discovered the error was from google Application Load balancers. I am exposing tyk using an ALB and they seem to set the traceparent header even though their documentation doesn’t mention it. They’re only meant to add the X-Cloud-Trace-Context headers. So it seems you have to set both headers or the X-Cloud-Trace-Context for it to not change. B3 propagation works fine so i will just switch to that.

1 Like

thanks for the update! glad you figured it out.