Search code examples
ruby-on-railsdatadog

is it possible to access a DataDog trace_id from within a Rails application


We are using DataDog's Distributed tracing in a rails application and would like to write the trace_id (for a controller#action) so that we could access the url later to our Rails logs. How could I do this?

something like?:

trace_id = DataDog.trace_id

Solution

  • Datadog's Ruby library keeps this info on the struct Datadog.tracer.active_correlation.

    You can call Datadog.tracer.active_correlation.trace_id to grab the trace ID.