Module: Datadog::Transport::Statistics
- Defined in:
- lib/ddtrace/transport/statistics.rb
Overview
Tracks statistics for transports
Defined Under Namespace
Classes: Counts
Instance Method Summary collapse
- #metrics_for_exception(_exception) ⇒ Object
- #metrics_for_response(response) ⇒ Object
- #stats ⇒ Object
- #update_stats_from_exception!(exception) ⇒ Object
- #update_stats_from_response!(response) ⇒ Object
Instance Method Details
#metrics_for_exception(_exception) ⇒ Object
45 46 47 |
# File 'lib/ddtrace/transport/statistics.rb', line 45 def metrics_for_exception(_exception) { api_errors: Metrics::Metric.new(:api_errors, nil, 1) } end |
#metrics_for_response(response) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/ddtrace/transport/statistics.rb', line 28 def metrics_for_response(response) {}.tap do |metrics| metrics[:api_errors] = Metrics::Metric.new(:api_errors, nil, 1) if response.internal_error? metrics[:api_responses] = Metrics::Metric.new(:api_responses, nil, 1) unless response.internal_error? end end |
#stats ⇒ Object
7 8 9 |
# File 'lib/ddtrace/transport/statistics.rb', line 7 def stats @stats ||= Counts.new end |
#update_stats_from_exception!(exception) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/ddtrace/transport/statistics.rb', line 35 def update_stats_from_exception!(exception) stats.internal_error += 1 stats.consecutive_errors += 1 # Send health metrics Diagnostics::Health.metrics.send_metrics( metrics_for_exception(exception).values ) end |
#update_stats_from_response!(response) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ddtrace/transport/statistics.rb', line 11 def update_stats_from_response!(response) if response.ok? stats.success += 1 stats.consecutive_errors = 0 else stats.client_error += 1 if response.client_error? stats.server_error += 1 if response.server_error? stats.internal_error += 1 if response.internal_error? stats.consecutive_errors += 1 end # Send health metrics Diagnostics::Health.metrics.send_metrics( metrics_for_response(response).values ) end |