Class: Pier::PageRequest::Metric
- Inherits:
-
Object
- Object
- Pier::PageRequest::Metric
- Defined in:
- lib/pier/page_request/metric.rb
Instance Method Summary collapse
- #call(name, started, finished, unique_id, payload) ⇒ Object
-
#initialize(client:, namespace:) ⇒ Metric
constructor
A new instance of Metric.
Constructor Details
#initialize(client:, namespace:) ⇒ Metric
7 8 9 10 |
# File 'lib/pier/page_request/metric.rb', line 7 def initialize(client:, namespace:) @client = client @namespace = namespace end |
Instance Method Details
#call(name, started, finished, unique_id, payload) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pier/page_request/metric.rb', line 12 def call(name, started, finished, unique_id, payload) client.increment( "#{namespace}.http", tags: (payload: payload) ) client.histogram( "#{namespace}.http.response_time", payload[:view_runtime].to_f + payload[:db_runtime].to_f, tags: (payload: payload) ) if payload[:view_runtime] client.histogram( "#{namespace}.http.response_time.views", payload[:view_runtime].to_f, tags: (payload: payload) ) end if payload[:db_runtime] client.histogram( "#{namespace}.http.response_time.db", payload[:db_runtime].to_f, tags: (payload: payload) ) end end |