Class: Rack::Metrics::Event

Inherits:
ActiveSupport::Notifications::Event
  • Object
show all
Defined in:
lib/rack/metrics.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Event.



126
127
128
129
130
# File 'lib/rack/metrics.rb', line 126

def initialize(name, start, ending, transaction_id, payload)
  @queries = []
  @partials = []
  super(name, start, ending, transaction_id, payload)
end

Instance Attribute Details

#endObject

Returns the value of attribute end.



124
125
126
# File 'lib/rack/metrics.rb', line 124

def end
  @end
end

#nameObject

Returns the value of attribute name.



124
125
126
# File 'lib/rack/metrics.rb', line 124

def name
  @name
end

#partialsObject

Returns the value of attribute partials.



124
125
126
# File 'lib/rack/metrics.rb', line 124

def partials
  @partials
end

#payloadObject

Returns the value of attribute payload.



124
125
126
# File 'lib/rack/metrics.rb', line 124

def payload
  @payload
end

#queriesObject

Returns the value of attribute queries.



124
125
126
# File 'lib/rack/metrics.rb', line 124

def queries
  @queries
end

#stackObject

Returns the value of attribute stack.



124
125
126
# File 'lib/rack/metrics.rb', line 124

def stack
  @stack
end

#templateObject

Returns the value of attribute template.



124
125
126
# File 'lib/rack/metrics.rb', line 124

def template
  @template
end

#timeObject

Returns the value of attribute time.



124
125
126
# File 'lib/rack/metrics.rb', line 124

def time
  @time
end

#transaction_idObject

Returns the value of attribute transaction_id.



124
125
126
# File 'lib/rack/metrics.rb', line 124

def transaction_id
  @transaction_id
end

Instance Method Details

#as_json(options = {}) ⇒ Object



140
141
142
143
144
145
146
# File 'lib/rack/metrics.rb', line 140

def as_json(options={})
  attrs = super(options)
  attrs['duration'] = self.duration.round(2)
  attrs.delete_if {|k, v| v.nil?}
  attrs.delete_if {|k, v| v.respond_to?(:empty?) and v.empty? }
  attrs
end

#init(name, start, ending, transaction_id, payload) ⇒ Object



132
133
134
135
136
137
138
# File 'lib/rack/metrics.rb', line 132

def init(name, start, ending, transaction_id, payload)
  @name           = name
  @payload        = payload.dup
  @time           = start
  @transaction_id = transaction_id
  @end            = ending
end