lib/honeycomb/propagation.rb in honeycomb-beeline-1.0.0.pre.alpha1 vs lib/honeycomb/propagation.rb in honeycomb-beeline-1.0.0.pre.beta

- old
+ new

@@ -1,9 +1,10 @@ # frozen_string_literal: true require "base64" require "json" +require "uri" module Honeycomb # Parse trace headers module PropagationParser def parse(serialized_trace) @@ -26,11 +27,11 @@ trace_id, parent_span_id, trace_fields, dataset = nil payload.split(",").each do |entry| key, value = entry.split("=", 2) case key when "dataset" - dataset = value + dataset = URI.decode_www_form_component(value) when "trace_id" trace_id = value when "parent_id" parent_span_id = value when "context" @@ -50,9 +51,16 @@ # Serialize trace headers module PropagationSerializer def to_trace_header context = Base64.urlsafe_encode64(JSON.generate(trace.fields)).strip - "1;trace_id=#{trace.id},parent_id=#{id},context=#{context}" + encoded_dataset = URI.encode_www_form_component(builder.dataset) + data_to_propogate = [ + "dataset=#{encoded_dataset}", + "trace_id=#{trace.id}", + "parent_id=#{id}", + "context=#{context}", + ] + "1;#{data_to_propogate.join(',')}" end end end