Class: Atatus::Span Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ChildDurations::Methods
Defined in:
lib/atatus/span.rb,
lib/atatus/span/context.rb,
lib/atatus/span/context/db.rb,
lib/atatus/span/context/http.rb,
lib/atatus/span/context/destination.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

Classes: Context

Constant Summary collapse

DEFAULT_TYPE =

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.

'Custom'
DEFAULT_SUBTYPE =

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.

'Ruby'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ChildDurations::Methods

#child_durations, #child_started, #child_stopped

Constructor Details

#initialize(name:, transaction:, trace_context:, parent:, type: nil, subtype: nil, action: nil, context: nil, stacktrace_builder: nil, sync: nil, sample_rate: nil) ⇒ Span

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.

rubocop:disable Metrics/ParameterLists



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/atatus/span.rb', line 32

def initialize(
  name:,
  transaction:,
  trace_context:,
  parent:,
  type: nil,
  subtype: nil,
  action: nil,
  context: nil,
  stacktrace_builder: nil,
  sync: nil,
  sample_rate: nil
)
  @name = name

  if subtype.nil? && type&.include?('.')
    @type, @subtype, @action = type.split('.')
  else
    @type = type || DEFAULT_TYPE
    @subtype = subtype || DEFAULT_SUBTYPE
    @action = action
  end

  @transaction = transaction
  @transaction_id = transaction.id
  @parent = parent
  @trace_context = trace_context || parent.trace_context.child
  @sample_rate = transaction.sample_rate

  @context = context || Span::Context.new(sync: sync)
  @stacktrace_builder = stacktrace_builder
end

Instance Attribute Details

#actionObject

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.



68
69
70
# File 'lib/atatus/span.rb', line 68

def action
  @action
end

#contextObject (readonly)

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.



76
77
78
# File 'lib/atatus/span.rb', line 76

def context
  @context
end

#durationObject (readonly)

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.



76
77
78
# File 'lib/atatus/span.rb', line 76

def duration
  @duration
end

#nameObject

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.



68
69
70
# File 'lib/atatus/span.rb', line 68

def name
  @name
end

#original_backtraceObject

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.



68
69
70
# File 'lib/atatus/span.rb', line 68

def original_backtrace
  @original_backtrace
end

#parentObject (readonly)

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.



76
77
78
# File 'lib/atatus/span.rb', line 76

def parent
  @parent
end

#sample_rateObject (readonly)

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.



76
77
78
# File 'lib/atatus/span.rb', line 76

def sample_rate
  @sample_rate
end

#self_timeObject (readonly)

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.



76
77
78
# File 'lib/atatus/span.rb', line 76

def self_time
  @self_time
end

#stacktraceObject (readonly)

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.



76
77
78
# File 'lib/atatus/span.rb', line 76

def stacktrace
  @stacktrace
end

#subtypeObject

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.



68
69
70
# File 'lib/atatus/span.rb', line 68

def subtype
  @subtype
end

#timestampObject (readonly)

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.



76
77
78
# File 'lib/atatus/span.rb', line 76

def timestamp
  @timestamp
end

#trace_contextObject

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.



68
69
70
# File 'lib/atatus/span.rb', line 68

def trace_context
  @trace_context
end

#transactionObject (readonly)

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.



76
77
78
# File 'lib/atatus/span.rb', line 76

def transaction
  @transaction
end

#transaction_idObject (readonly)

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.



76
77
78
# File 'lib/atatus/span.rb', line 76

def transaction_id
  @transaction_id
end

#typeObject

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.



68
69
70
# File 'lib/atatus/span.rb', line 68

def type
  @type
end

Instance Method Details

#done(clock_end: Util.monotonic_micros) ⇒ 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.



104
105
106
107
# File 'lib/atatus/span.rb', line 104

def done(clock_end: Util.monotonic_micros)
  stop clock_end
  self
end

#inspectObject

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.

relations



128
129
130
131
132
133
# File 'lib/atatus/span.rb', line 128

def inspect
  "<Atatus::Span id:#{trace_context&.id}" \
    " name:#{name.inspect}" \
    " type:#{type.inspect}" \
    '>'
end

#prepare_for_serialization!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.



109
110
111
112
# File 'lib/atatus/span.rb', line 109

def prepare_for_serialization!
  # build_stacktrace! if should_build_stacktrace?
  self.original_backtrace = nil # release original
end

#running?Boolean

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:

  • (Boolean)


122
123
124
# File 'lib/atatus/span.rb', line 122

def running?
  started? && !stopped?
end

#start(clock_start = Util.monotonic_micros) ⇒ 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.

life cycle



90
91
92
93
94
95
# File 'lib/atatus/span.rb', line 90

def start(clock_start = Util.monotonic_micros)
  @timestamp = Util.micros
  @clock_start = clock_start
  @parent.child_started
  self
end

#started?Boolean

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:

  • (Boolean)


118
119
120
# File 'lib/atatus/span.rb', line 118

def started?
  !!timestamp
end

#stop(clock_end = Util.monotonic_micros) ⇒ 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.



97
98
99
100
101
102
# File 'lib/atatus/span.rb', line 97

def stop(clock_end = Util.monotonic_micros)
  @duration ||= (clock_end - @clock_start)
  @parent.child_stopped
  @self_time = @duration - child_durations.duration
  self
end

#stopped?Boolean

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:

  • (Boolean)


114
115
116
# File 'lib/atatus/span.rb', line 114

def stopped?
  !!duration
end