Module: Honeycomb::AWSPropagation::UnmarshalTraceContext
- Defined in:
- lib/honeycomb/propagation/aws.rb
Overview
Parse trace headers
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.get_fields(fields) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/honeycomb/propagation/aws.rb', line 27 def get_fields(fields) trace_id, parent_span_id = nil trace_fields = {} fields.each do |entry| key, value = entry.split("=", 2) case key.downcase when "root" trace_id = value when "self" parent_span_id = value when "parent" parent_span_id = value if parent_span_id.nil? else trace_fields[key] = value unless key.empty? end end [trace_id, parent_span_id, trace_fields] end |
.parse(serialized_trace) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/honeycomb/propagation/aws.rb', line 8 def parse(serialized_trace) unless serialized_trace.nil? split = serialized_trace.split(";") trace_id, parent_span_id, trace_fields = get_fields(split) parent_span_id = trace_id if parent_span_id.nil? trace_fields = nil if trace_fields.empty? if !trace_id.nil? && !parent_span_id.nil? # return nil for dataset return [trace_id, parent_span_id, trace_fields, nil] end end [nil, nil, nil, nil] end |
Instance Method Details
#parse(serialized_trace) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/honeycomb/propagation/aws.rb', line 8 def parse(serialized_trace) unless serialized_trace.nil? split = serialized_trace.split(";") trace_id, parent_span_id, trace_fields = get_fields(split) parent_span_id = trace_id if parent_span_id.nil? trace_fields = nil if trace_fields.empty? if !trace_id.nil? && !parent_span_id.nil? # return nil for dataset return [trace_id, parent_span_id, trace_fields, nil] end end [nil, nil, nil, nil] end |