Class: TingYun::Instrumentation::Support::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/ting_yun/instrumentation/support/evented_subscriber.rb

Overview

Taken from ActiveSupport::Notifications::Event, pasted here with a couple minor additions so we don’t have a hard dependency on ActiveSupport::Notifications.

Represents an intrument event, provides timing and metric name information useful when recording metrics.

Direct Known Subclasses

Rails::ControllerEvent, Rails::RenderEvent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, start, ending, transaction_id, payload, _ = nil) ⇒ Event

Returns a new instance of Event.



69
70
71
72
73
74
75
76
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 69

def initialize(name, start, ending, transaction_id, payload, _=nil)
  @name           = name
  @payload        = payload.dup
  @time           = start
  @transaction_id = transaction_id
  @end            = ending
  @children       = []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



66
67
68
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 66

def children
  @children
end

#endObject

Returns the value of attribute end.



67
68
69
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 67

def end
  @end
end

#frameObject

Returns the value of attribute frame.



67
68
69
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 67

def frame
  @frame
end

#nameObject (readonly)

Returns the value of attribute name.



66
67
68
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 66

def name
  @name
end

#parentObject

Returns the value of attribute parent.



67
68
69
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 67

def parent
  @parent
end

#payloadObject (readonly)

Returns the value of attribute payload.



66
67
68
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 66

def payload
  @payload
end

#timeObject (readonly)

Returns the value of attribute time.



66
67
68
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 66

def time
  @time
end

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



66
67
68
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 66

def transaction_id
  @transaction_id
end

Instance Method Details

#<<(event) ⇒ Object



86
87
88
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 86

def <<(event)
  @children << event
end

#durationObject



82
83
84
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 82

def duration
  (self.end - time)*1000
end

#metric_nameObject

Raises:

  • (NotImplementedError)


78
79
80
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 78

def metric_name
  raise NotImplementedError
end

#parent_of?(event) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/ting_yun/instrumentation/support/evented_subscriber.rb', line 90

def parent_of?(event)
  @children.include? event
end