Class: NatsWork::StatsDCollector
- Inherits:
-
MetricsCollector
- Object
- MetricsCollector
- NatsWork::StatsDCollector
- Defined in:
- lib/natswork/metrics.rb
Overview
StatsD metrics collector
Instance Method Summary collapse
- #collect(type, metric, value, tags) ⇒ Object
-
#initialize(client) ⇒ StatsDCollector
constructor
A new instance of StatsDCollector.
Constructor Details
#initialize(client) ⇒ StatsDCollector
Returns a new instance of StatsDCollector.
220 221 222 |
# File 'lib/natswork/metrics.rb', line 220 def initialize(client) @client = client end |
Instance Method Details
#collect(type, metric, value, tags) ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/natswork/metrics.rb', line 224 def collect(type, metric, value, ) metric_name = .empty? ? metric : "#{metric}.#{.map { |k, v| "#{k}_#{v}" }.join('.')}" case type when :counter @client.increment(metric_name, value) when :gauge @client.gauge(metric_name, value) when :histogram @client.histogram(metric_name, value) when :timer @client.timing(metric_name, value) end rescue StandardError # Log but don't raise end |