Datadog distributed tracing
NOTE: Newer versions of ddtrace have all this as an option (for sidekiq jobs)* See also https://github.com/datadog/dd-trace-rb/blob/master/docs/GettingStarted.md#sidekiq
This is for ddtrace v1.1
See also Distributed tracing docs
- Might need to use continue tracing when spawning threads or other weird scenarios like continuing tracing for background job processing.
- Need to use a TraceDigest object which is a wrapper for trace properties. If
needed this can easily be serialized as JSON and later parsed to
re-instantiate a
TraceDigest
object. Example…
# Cache the trace digest as JSON string current_trace = Datadog::Tracing.active_trace trace_digest_json = current_trace&.to_digest&.to_json # Later re-instantiate a TraceDigest with parsed digest properties and continue trace if trace_digest_json trace_digest = Datadog::Tracing::TraceDigest.new(**JSON.parse(trace_digest_json).symbolize_keys) Datadog::Tracing.trace('foo', resource: 'bar', continue_from: trace_digest) do # do stuff end end