Class: ZipkinTracer::ZipkinEnv
- Inherits:
-
Object
- Object
- ZipkinTracer::ZipkinEnv
- Defined in:
- lib/zipkin-tracer/rack/zipkin_env.rb
Overview
This class manages the Zipkin related information in the Rack environment. It is only used by the rack middleware.
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #called_with_zipkin_b3_single_header? ⇒ Boolean
- #called_with_zipkin_headers? ⇒ Boolean
-
#initialize(env, config) ⇒ ZipkinEnv
constructor
A new instance of ZipkinEnv.
- #trace_id(default_flags = Trace::Flags::EMPTY) ⇒ Object
Constructor Details
#initialize(env, config) ⇒ ZipkinEnv
Returns a new instance of ZipkinEnv.
7 8 9 10 |
# File 'lib/zipkin-tracer/rack/zipkin_env.rb', line 7 def initialize(env, config) @env = env @config = config end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/zipkin-tracer/rack/zipkin_env.rb', line 5 def env @env end |
Instance Method Details
#called_with_zipkin_b3_single_header? ⇒ Boolean
19 20 21 |
# File 'lib/zipkin-tracer/rack/zipkin_env.rb', line 19 def called_with_zipkin_b3_single_header? @called_with_zipkin_b3_single_header ||= @env.key?(B3_SINGLE_HEADER) end |
#called_with_zipkin_headers? ⇒ Boolean
23 24 25 |
# File 'lib/zipkin-tracer/rack/zipkin_env.rb', line 23 def called_with_zipkin_headers? @called_with_zipkin_headers ||= B3_REQUIRED_HEADERS.all? { |key| @env.key?(key) } end |
#trace_id(default_flags = Trace::Flags::EMPTY) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/zipkin-tracer/rack/zipkin_env.rb', line 12 def trace_id(default_flags = Trace::Flags::EMPTY) trace_id, span_id, parent_span_id, sampled, flags, shared = retrieve_or_generate_ids sampled = sampled_header_value(sampled) flags = (flags || default_flags).to_i Trace::TraceId.new(trace_id, parent_span_id, span_id, sampled, flags, shared) end |