Sha256: ea2cb17701d454bb44a7961f971ac1f9da53b084fdc09817a355350c2e865de9

Contents?: true

Size: 1.25 KB

Versions: 77

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'deimos/metrics/provider'

module Deimos
  module Metrics
    # A Metrics wrapper class for Datadog.
    class Datadog < Metrics::Provider
      # :nodoc:
      def initialize(config, logger)
        raise 'Metrics config must specify host_ip' if config[:host_ip].nil?
        raise 'Metrics config must specify host_port' if config[:host_port].nil?
        raise 'Metrics config must specify namespace' if config[:namespace].nil?

        logger.info("DatadogMetricsProvider configured with: #{config}")
        @client = Datadog::Statsd.new(
          config[:host_ip],
          config[:host_port]
        )
        @client.tags = config[:tags]
        @client.namespace = config[:namespace]
      end

      # :nodoc:
      def increment(metric_name, options={})
        @client.increment(metric_name, options)
      end

      # :nodoc:
      def gauge(metric_name, count, options={})
        @client.gauge(metric_name, count, options)
      end

      # :nodoc:
      def histogram(metric_name, count, options={})
        @client.histogram(metric_name, count, options)
      end

      # :nodoc:
      def time(metric_name, options={})
        @client.time(metric_name, options) do
          yield
        end
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 3 rubygems

Version Path
deimos-ruby-1.12.5 lib/deimos/metrics/datadog.rb
deimos-ruby-1.12.4 lib/deimos/metrics/datadog.rb
deimos-ruby-1.12.3 lib/deimos/metrics/datadog.rb
deimos-ruby-1.12.2 lib/deimos/metrics/datadog.rb
deimos-ruby-1.12.1 lib/deimos/metrics/datadog.rb
deimos-ruby-1.12.0 lib/deimos/metrics/datadog.rb
deimos-temp-fork-0.0.7 lib/deimos/metrics/datadog.rb
deimos-ruby-1.11.2 lib/deimos/metrics/datadog.rb
deimos-ruby-1.11.1 lib/deimos/metrics/datadog.rb
deimos-ruby-1.11.0 lib/deimos/metrics/datadog.rb
deimos-temp-fork-0.0.6 lib/deimos/metrics/datadog.rb
deimos-temp-fork-0.0.5 lib/deimos/metrics/datadog.rb
deimos-temp-fork-0.0.4 lib/deimos/metrics/datadog.rb
deimos-temp-fork-0.0.3 lib/deimos/metrics/datadog.rb
deimos-temp-fork-0.0.2 lib/deimos/metrics/datadog.rb
deimos-temp-fork-0.0.1 lib/deimos/metrics/datadog.rb
deimos-ruby-1.10.2 lib/deimos/metrics/datadog.rb
deimos-ruby-1.10.1 lib/deimos/metrics/datadog.rb
deimos-ruby-1.10.0 lib/deimos/metrics/datadog.rb
deimos-ruby-1.9.2 lib/deimos/metrics/datadog.rb