Class: Simple::Metrics::RackMetrics
- Inherits:
-
Object
- Object
- Simple::Metrics::RackMetrics
- Extended by:
- Meter
- Defined in:
- lib/simple/metrics/rack_metrics.rb
Constant Summary
Constants included from Simple::Metrics
DEFAULT_DURATION_UNIT, DEFAULT_RATE_UNIT, DEFAULT_TIMING_UNIT, VERSION
Instance Method Summary (collapse)
- - (Object) call(env)
-
- (RackMetrics) initialize(app, application_name)
constructor
Rack middleware for capturing response codes.
Methods included from Meter
Methods included from Simple::Metrics
#metrics_registry, #new_metric_name, #sanitize_classname
Methods included from Timer
Constructor Details
- (RackMetrics) initialize(app, application_name)
Rack middleware for capturing response codes
Creates a series of response meters that will be marked based on the response code that is returned by rack.
12 13 14 15 16 17 18 19 |
# File 'lib/simple/metrics/rack_metrics.rb', line 12 def initialize(app, application_name) @app = app self.class.define_meter '2xx-responses', application_name self.class.define_meter '3xx-responses', application_name self.class.define_meter '4xx-responses', application_name self.class.define_meter '5xx-responses', application_name end |
Instance Method Details
- (Object) call(env)
21 22 23 24 25 26 27 28 29 |
# File 'lib/simple/metrics/rack_metrics.rb', line 21 def call(env) begin status, headers, body = @app.call(env) ensure status_code = (status ||= 500).to_s[0] status_method = "#{status_code}xx-responses".to_sym self.send(status_method).mark end end |