Module: Honeycomb::HoneycombPropagation::MarshalTraceContext
- Includes:
- Libhoney::Cleaner
- Included in:
- PropagationSerializer
- Defined in:
- lib/honeycomb/propagation/honeycomb.rb
Overview
Serialize trace headers
Class Method Summary collapse
- .clean_data ⇒ Object
- .clean_string ⇒ Object
- .encode_dataset(dataset) ⇒ Object
- .encode_trace_fields(fields) ⇒ Object
- .parse_faraday_env(_env, propagation_context) ⇒ Object
- .to_trace_header(propagation_context) ⇒ Object
Instance Method Summary collapse
Class Method Details
.clean_data ⇒ Object
.clean_string ⇒ Object
.encode_dataset(dataset) ⇒ Object
102 103 104 |
# File 'lib/honeycomb/propagation/honeycomb.rb', line 102 def encode_dataset(dataset) URI.encode_www_form_component(dataset) end |
.encode_trace_fields(fields) ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/honeycomb/propagation/honeycomb.rb', line 93 def encode_trace_fields(fields) Base64.urlsafe_encode64( JSON.generate( clean_data(fields), ), ).strip end |
.parse_faraday_env(_env, propagation_context) ⇒ Object
77 78 79 80 81 |
# File 'lib/honeycomb/propagation/honeycomb.rb', line 77 def self.parse_faraday_env(_env, propagation_context) { "X-Honeycomb-Trace" => to_trace_header(propagation_context), } end |
.to_trace_header(propagation_context) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/honeycomb/propagation/honeycomb.rb', line 83 def self.to_trace_header(propagation_context) data_to_propogate = [ "dataset=#{encode_dataset(propagation_context.dataset)}", "trace_id=#{propagation_context.trace_id}", "parent_id=#{propagation_context.parent_id}", "context=#{encode_trace_fields(propagation_context.trace_fields)}", ] "1;#{data_to_propogate.join(',')}" end |
Instance Method Details
#to_trace_header ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/honeycomb/propagation/honeycomb.rb', line 67 def to_trace_header data_to_propogate = [ "dataset=#{encode_dataset(builder.dataset)}", "trace_id=#{trace.id}", "parent_id=#{id}", "context=#{encode_trace_fields(trace.fields)}", ] "1;#{data_to_propogate.join(',')}" end |