Class: Breakers::StatsdPlugin
- Inherits:
-
Object
- Object
- Breakers::StatsdPlugin
- Defined in:
- lib/breakers/statsd_plugin.rb
Instance Method Summary collapse
- #get_tags(upstream_request) ⇒ Object
- #on_error(service, request_env, response_env) ⇒ Object
- #on_skipped_request(service) ⇒ Object
- #on_success(service, request_env, response_env) ⇒ Object
- #send_metric(status, service, request_env, response_env) ⇒ Object
Instance Method Details
#get_tags(upstream_request) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/breakers/statsd_plugin.rb', line 7 def (upstream_request) source_app = RequestStore.store.dig('additional_request_attributes', 'source') = [] if upstream_request if upstream_request.url&.path .append("endpoint:#{StringHelpers.filtered_endpoint_tag(upstream_request.url.path)}") end .append("method:#{upstream_request.method}") if upstream_request.method .append("source:#{source_app}") if source_app end end |
#on_error(service, request_env, response_env) ⇒ Object
21 22 23 |
# File 'lib/breakers/statsd_plugin.rb', line 21 def on_error(service, request_env, response_env) send_metric('failed', service, request_env, response_env) end |
#on_skipped_request(service) ⇒ Object
25 26 27 |
# File 'lib/breakers/statsd_plugin.rb', line 25 def on_skipped_request(service) send_metric('skipped', service, nil, nil) end |
#on_success(service, request_env, response_env) ⇒ Object
29 30 31 |
# File 'lib/breakers/statsd_plugin.rb', line 29 def on_success(service, request_env, response_env) send_metric('success', service, request_env, response_env) end |
#send_metric(status, service, request_env, response_env) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/breakers/statsd_plugin.rb', line 33 def send_metric(status, service, request_env, response_env) = (request_env) metric_base = "api.external_http_request.#{service.name}." StatsD.increment(metric_base + status, 1, tags:) StatsD.measure("#{metric_base}time", response_env[:duration], tags:) if response_env && response_env[:duration] end |