Class: ElasticAPM::TraceContext::Tracestate Private
- Inherits:
-
Object
- Object
- ElasticAPM::TraceContext::Tracestate
- Extended by:
- Forwardable
- Defined in:
- lib/elastic_apm/trace_context/tracestate.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Constant Summary collapse
- ENTRY_SPLIT_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\s*[\n,]+\s*/
Instance Attribute Summary collapse
- #entries ⇒ Object private
Class Method Summary collapse
- .parse(header) ⇒ Object private
Instance Method Summary collapse
-
#initialize(entries: {}, sample_rate: nil) ⇒ Tracestate
constructor
private
A new instance of Tracestate.
- #to_header ⇒ Object private
Constructor Details
#initialize(entries: {}, sample_rate: nil) ⇒ Tracestate
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Tracestate.
97 98 99 100 101 |
# File 'lib/elastic_apm/trace_context/tracestate.rb', line 97 def initialize(entries: {}, sample_rate: nil) @entries = entries self.sample_rate = sample_rate if sample_rate end |
Instance Attribute Details
#entries ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
103 104 105 |
# File 'lib/elastic_apm/trace_context/tracestate.rb', line 103 def entries @entries end |
Class Method Details
.parse(header) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/elastic_apm/trace_context/tracestate.rb', line 107 def self.parse(header) entries = split_by_nl_and_comma(header) .each_with_object({}) do |entry, hsh| k, v = entry.split('=') next unless k && v && !k.empty? && !v.empty? hsh[k] = case k when 'es' then EsEntry.new(v) else Entry.new(k, v) end end new(entries: entries) end |
Instance Method Details
#to_header ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
123 124 125 126 127 |
# File 'lib/elastic_apm/trace_context/tracestate.rb', line 123 def to_header return "" unless entries.any? entries.values.map(&:to_s).join(',') end |