Module: Datadog::Transport::Statistics
- Included in:
- IO::Client
- 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
46 47 48 |
# File 'lib/ddtrace/transport/statistics.rb', line 46 def metrics_for_exception(_exception) { api_errors: Metrics::Metric.new(:api_errors, nil, 1) } end |
#metrics_for_response(response) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ddtrace/transport/statistics.rb', line 29 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
8 9 10 |
# File 'lib/ddtrace/transport/statistics.rb', line 8 def stats @stats ||= Counts.new end |
#update_stats_from_exception!(exception) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/ddtrace/transport/statistics.rb', line 36 def update_stats_from_exception!(exception) stats.internal_error += 1 stats.consecutive_errors += 1 # Send health metrics Datadog.health_metrics.send_metrics( metrics_for_exception(exception).values ) end |
#update_stats_from_response!(response) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ddtrace/transport/statistics.rb', line 12 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 Datadog.health_metrics.send_metrics( metrics_for_response(response).values ) end |