Class: Philiprehberger::HttpClient::Metrics
- Inherits:
-
Object
- Object
- Philiprehberger::HttpClient::Metrics
- Defined in:
- lib/philiprehberger/http_client/metrics.rb
Overview
Timing metrics for an HTTP request. Captures DNS, connect, TLS, first byte, and total durations.
Instance Attribute Summary collapse
-
#connect_time ⇒ Object
readonly
Returns the value of attribute connect_time.
-
#dns_time ⇒ Object
readonly
Returns the value of attribute dns_time.
-
#first_byte_time ⇒ Object
readonly
Returns the value of attribute first_byte_time.
-
#tls_time ⇒ Object
readonly
Returns the value of attribute tls_time.
-
#total_time ⇒ Object
readonly
Returns the value of attribute total_time.
Instance Method Summary collapse
-
#initialize ⇒ Metrics
constructor
A new instance of Metrics.
-
#record(field, value) ⇒ Object
Record a timing measurement.
-
#to_h ⇒ Hash{Symbol => Float}
Return all timings as a hash.
Constructor Details
#initialize ⇒ Metrics
Returns a new instance of Metrics.
10 11 12 13 14 15 16 |
# File 'lib/philiprehberger/http_client/metrics.rb', line 10 def initialize @dns_time = 0.0 @connect_time = 0.0 @tls_time = 0.0 @first_byte_time = 0.0 @total_time = 0.0 end |
Instance Attribute Details
#connect_time ⇒ Object (readonly)
Returns the value of attribute connect_time.
8 9 10 |
# File 'lib/philiprehberger/http_client/metrics.rb', line 8 def connect_time @connect_time end |
#dns_time ⇒ Object (readonly)
Returns the value of attribute dns_time.
8 9 10 |
# File 'lib/philiprehberger/http_client/metrics.rb', line 8 def dns_time @dns_time end |
#first_byte_time ⇒ Object (readonly)
Returns the value of attribute first_byte_time.
8 9 10 |
# File 'lib/philiprehberger/http_client/metrics.rb', line 8 def first_byte_time @first_byte_time end |
#tls_time ⇒ Object (readonly)
Returns the value of attribute tls_time.
8 9 10 |
# File 'lib/philiprehberger/http_client/metrics.rb', line 8 def tls_time @tls_time end |
#total_time ⇒ Object (readonly)
Returns the value of attribute total_time.
8 9 10 |
# File 'lib/philiprehberger/http_client/metrics.rb', line 8 def total_time @total_time end |
Instance Method Details
#record(field, value) ⇒ Object
Record a timing measurement.
22 23 24 |
# File 'lib/philiprehberger/http_client/metrics.rb', line 22 def record(field, value) instance_variable_set(:"@#{field}", value) end |
#to_h ⇒ Hash{Symbol => Float}
Return all timings as a hash.
29 30 31 32 33 34 35 36 37 |
# File 'lib/philiprehberger/http_client/metrics.rb', line 29 def to_h { dns_time: @dns_time, connect_time: @connect_time, tls_time: @tls_time, first_byte_time: @first_byte_time, total_time: @total_time } end |