Class: StackifyRubyAPM::Span Private

Inherits:
Object
  • Object
show all
Defined in:
lib/stackify_apm/span.rb,
lib/stackify_apm/span/context.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'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transaction, id, name, type = nil, parent_id: nil, context: nil, http_status: 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



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/stackify_apm/span.rb', line 15

def initialize(
  transaction,
  id,
  name,
  type = nil,
  parent_id: nil,
  context: nil,
  http_status: nil
)
  @transaction = transaction
  @id = id
  @name = name
  @type = type || DEFAULT_TYPE
  @parent_id = parent_id
  @context = context
  @http_status = http_status
  @stacktrace = nil
  @original_backtrace = nil
end

Instance Attribute Details

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



37
38
39
# File 'lib/stackify_apm/span.rb', line 37

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.



37
38
39
# File 'lib/stackify_apm/span.rb', line 37

def duration
  @duration
end

#http_statusObject

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:enable Metrics/ParameterLists



36
37
38
# File 'lib/stackify_apm/span.rb', line 36

def http_status
  @http_status
end

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



37
38
39
# File 'lib/stackify_apm/span.rb', line 37

def id
  @id
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.

rubocop:enable Metrics/ParameterLists



36
37
38
# File 'lib/stackify_apm/span.rb', line 36

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.

rubocop:enable Metrics/ParameterLists



36
37
38
# File 'lib/stackify_apm/span.rb', line 36

def original_backtrace
  @original_backtrace
end

#parent_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.



37
38
39
# File 'lib/stackify_apm/span.rb', line 37

def parent_id
  @parent_id
end

#relative_endObject (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.



37
38
39
# File 'lib/stackify_apm/span.rb', line 37

def relative_end
  @relative_end
end

#relative_startObject (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.



37
38
39
# File 'lib/stackify_apm/span.rb', line 37

def relative_start
  @relative_start
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.



37
38
39
# File 'lib/stackify_apm/span.rb', line 37

def stacktrace
  @stacktrace
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.

rubocop:enable Metrics/ParameterLists



36
37
38
# File 'lib/stackify_apm/span.rb', line 36

def type
  @type
end

Instance Method Details

#doneObject

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.



45
46
47
48
49
50
51
# File 'lib/stackify_apm/span.rb', line 45

def done
  @relative_end = Time.now.to_f * 1000
  @duration = Time.now.to_f * 1000
  self.original_backtrace = nil # release it

  self
end

#done?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)


53
54
55
56
# File 'lib/stackify_apm/span.rb', line 53

def done?
  # !!duration
  !duration.nil?
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.



62
63
64
65
66
67
# File 'lib/stackify_apm/span.rb', line 62

def inspect
  "<StackifyRubyAPM::Span id:#{id}" \
    " name:#{name.inspect}" \
    " type:#{type.inspect}" \
    '>'
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)


58
59
60
# File 'lib/stackify_apm/span.rb', line 58

def running?
  relative_start && !done?
end

#startObject

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.



39
40
41
42
43
# File 'lib/stackify_apm/span.rb', line 39

def start
  @relative_start = Time.now.to_f * 1000

  self
end