Class: OpenTracing::Reference

Inherits:
Object
  • Object
show all
Defined in:
lib/opentracing/reference.rb

Overview

:nodoc:

Constant Summary collapse

CHILD_OF =
'child_of'.freeze
FOLLOWS_FROM =
'follows_from'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, context) ⇒ Reference



68
69
70
71
# File 'lib/opentracing/reference.rb', line 68

def initialize(type, context)
  @type = type
  @context = context
end

Instance Attribute Details

#contextSpanContext (readonly)



77
78
79
# File 'lib/opentracing/reference.rb', line 77

def context
  @context
end

#typeString (readonly)



74
75
76
# File 'lib/opentracing/reference.rb', line 74

def type
  @type
end

Class Method Details

.child_of(context) ⇒ Reference

Returns a ChildOf reference.

Examples:

root_span = OpenTracing.start_span('root operation')
child_span = OpenTracing.start_span('child operation', references: [
  OpenTracing::Reference.child_of(root_span)
])


27
28
29
30
# File 'lib/opentracing/reference.rb', line 27

def self.child_of(context)
  context = context.context if context.is_a?(Span)
  Reference.new(CHILD_OF, context)
end

.follows_from(context) ⇒ Reference

Returns a FollowsFrom reference.

Examples:

context = OpenTracing.extract(OpenTracing::FORMAT_RACK, rack_env)
span = OpenTracing.start_span('following operation', references: [
  OpenTracing::Reference.follows_from(context)
])


63
64
65
66
# File 'lib/opentracing/reference.rb', line 63

def self.follows_from(context)
  context = context.context if context.is_a?(Span)
  Reference.new(FOLLOWS_FROM, context)
end