Class: MicroscopeTracer::Span

Inherits:
Object
  • Object
show all
Defined in:
lib/microscope_tracer/span.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trace_id, parent_span_id, span_id) ⇒ Span

Returns a new instance of Span.



20
21
22
23
24
# File 'lib/microscope_tracer/span.rb', line 20

def initialize(trace_id,parent_span_id,span_id)
  trace_id ||= Span.generate_unique_id
  span_id ||= Span.generate_unique_id
  @trace_id, @parent_span_id, @span_id = trace_id, parent_span_id, span_id
end

Instance Attribute Details

#parent_span_idObject (readonly)

Returns the value of attribute parent_span_id.



6
7
8
# File 'lib/microscope_tracer/span.rb', line 6

def parent_span_id
  @parent_span_id
end

#span_idObject (readonly)

Returns the value of attribute span_id.



6
7
8
# File 'lib/microscope_tracer/span.rb', line 6

def span_id
  @span_id
end

#trace_idObject (readonly)

Returns the value of attribute trace_id.



6
7
8
# File 'lib/microscope_tracer/span.rb', line 6

def trace_id
  @trace_id
end

Class Method Details

.generate_unique_idObject



8
9
10
# File 'lib/microscope_tracer/span.rb', line 8

def self.generate_unique_id
  SecureRandom.uuid
end

.lookup_for_this_requestObject



12
13
14
# File 'lib/microscope_tracer/span.rb', line 12

def self.lookup_for_this_request
  RequestStore.store[:microscope_span]
end

Instance Method Details

#store_for_this_requestObject



16
17
18
# File 'lib/microscope_tracer/span.rb', line 16

def store_for_this_request
  RequestStore.store[:microscope_span] = self
end