Class: Hooks::Core::Stats
- Inherits:
-
Object
- Object
- Hooks::Core::Stats
- Defined in:
- lib/hooks/core/stats.rb
Overview
Global stats component for metrics reporting
This is a stub implementation that does nothing by default. Users can replace this with their own implementation for services like DataDog, New Relic, etc.
Instance Method Summary collapse
-
#increment(metric_name, tags = {}) ⇒ void
Increment a counter.
-
#measure(metric_name, tags = {}) ⇒ Object
Measure execution time of a block.
-
#record(metric_name, value, tags = {}) ⇒ void
Record a metric.
-
#timing(metric_name, duration, tags = {}) ⇒ void
Record a timing metric.
Instance Method Details
#increment(metric_name, tags = {}) ⇒ void
This method returns an undefined value.
Increment a counter
26 27 28 |
# File 'lib/hooks/core/stats.rb', line 26 def increment(metric_name, = {}) # Override in subclass for actual metrics reporting end |
#measure(metric_name, tags = {}) ⇒ Object
Measure execution time of a block
45 46 47 48 49 50 51 |
# File 'lib/hooks/core/stats.rb', line 45 def measure(metric_name, = {}) start_time = Time.now.utc result = yield duration = Time.now.utc - start_time timing(metric_name, duration, ) result end |
#record(metric_name, value, tags = {}) ⇒ void
This method returns an undefined value.
Record a metric
17 18 19 |
# File 'lib/hooks/core/stats.rb', line 17 def record(metric_name, value, = {}) # Override in subclass for actual metrics reporting end |
#timing(metric_name, duration, tags = {}) ⇒ void
This method returns an undefined value.
Record a timing metric
36 37 38 |
# File 'lib/hooks/core/stats.rb', line 36 def timing(metric_name, duration, = {}) # Override in subclass for actual metrics reporting end |