Class: Pigeon::Statsd
- Inherits:
-
Object
- Object
- Pigeon::Statsd
- Defined in:
- lib/pigeon/statsd.rb
Instance Method Summary collapse
- #capture(action: :increment, count: 0) ⇒ Object
-
#initialize(name, tags: []) ⇒ Statsd
constructor
A new instance of Statsd.
Constructor Details
#initialize(name, tags: []) ⇒ Statsd
Returns a new instance of Statsd.
5 6 7 8 9 |
# File 'lib/pigeon/statsd.rb', line 5 def initialize(name, tags: []) @statsd = Datadog::Statsd.new(ENV['STATSD_HOST'], ENV['STATSD_PORT'], tags: ["environment:#{ENV['DD_ENV']}", "project:#{ENV['DD_SERVICE']}"]) @name = name @tags = end |
Instance Method Details
#capture(action: :increment, count: 0) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pigeon/statsd.rb', line 11 def capture(action: :increment, count: 0) return unless %w[increment count histogram].include? action.to_s case action.to_s when 'increment' increment(tags: @tags) when 'count' count(count: count, tags: @tags) when 'histogram' histogram(count: count, tags: @tags) else raise "unknown action #{action}" end end |