DataDog / dd-trace-rb

Datadog Tracing Ruby Client
https://docs.datadoghq.com/tracing/
Other
311 stars 375 forks source link

Rails distributed_tracing flag is not working as documented #1101

Open eddiesiegel opened 4 years ago

eddiesiegel commented 4 years ago

We are using ddtrace version 0.34.2 with the following configuration:

  Datadog.configure do |c|
    c.use :rails, {
        analytics_enabled: true,
        distributed_tracing: true,
        service_name: 'myservice'
    }
  end

The upstream service (nginx) is setting/sending the x-datadog-trace-id header, but the value of the header is being ignored and ddtrace is generating its own trace IDs.

We have verified this by logging both the value of request.headers['X-Datadog-Trace-Id'] and Datadog.tracer.active_correlation.trace_id, and the two values disagree with one another.

Example log line: {"method":"GET","path":"/","format":"html","controller":"HomeController","action":"landing","status":302,"duration":1996.72,"view":0.0,"db":1961.96,"location":"redacted","time":"2020-07-02 16:45:46 +0000","params":{},"dd":{"trace_id":"4688686075633624864","span_id":"1802778151391069052","trace_id_header":"1-5efe0f38-e571148bdf112dc08b872635"},"user_id":1234}

dd.trace_id is the trace ID reported by Datadog, and dd.trace_id_header is the value in the header.

marcotc commented 4 years ago

👋 @eddiesiegel, your scenario looks correct, and distributed tracing should be picking up your header correctly. I'll take a look and try to reproduce this issue.

matthewberends commented 1 year ago

Is there any update on this. Were you able to reproduce this? I am experiencing a similar issue.

marcotc commented 1 year ago

@matthewberends, most of the code around distributed_tracing has changed since the issue was first reported.

Could you provide us with the ddtrace version you are using, and any relevant configuration options you have set (Datadog.configure do |c|..., environment variables related to distributed tracing or propagation)?