Method: Sentry::PropagationContext.extract_sentry_trace

Defined in:
lib/sentry/propagation_context.rb

.extract_sentry_trace(sentry_trace) ⇒ Array?

Extract the trace_id, parent_span_id and parent_sampled values from a sentry-trace header.

Parameters:

  • sentry_trace (String)

    the sentry-trace header value from the previous transaction.

Returns:

  • (Array, nil)


43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sentry/propagation_context.rb', line 43

def self.extract_sentry_trace(sentry_trace)
  value = sentry_trace.to_s.strip
  return if value.empty?

  match = SENTRY_TRACE_REGEXP.match(value)
  return if match.nil?

  trace_id, parent_span_id, sampled_flag = match[1..3]
  parent_sampled = sampled_flag.nil? ? nil : sampled_flag != "0"

  [trace_id, parent_span_id, parent_sampled]
end