Sha256: efee339a376bfbb428c7bdc862c110ad60f905273244fd14e9f5788b46f5d314

Contents?: true

Size: 1.29 KB

Versions: 20

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require 'deimos/metrics/provider'

module Deimos
  module Metrics
    # A Metrics wrapper class for Datadog.
    class Datadog < Metrics::Provider
      # @param config [Hash]
      # @param logger [Logger]
      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],
          tags: config[:tags],
          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

20 entries across 20 versions & 1 rubygems

Version Path
deimos-ruby-1.24.2 lib/deimos/metrics/datadog.rb
deimos-ruby-1.24.1 lib/deimos/metrics/datadog.rb
deimos-ruby-1.24.0 lib/deimos/metrics/datadog.rb
deimos-ruby-1.23.3 lib/deimos/metrics/datadog.rb
deimos-ruby-1.23.2 lib/deimos/metrics/datadog.rb
deimos-ruby-1.23.1.pre.beta5 lib/deimos/metrics/datadog.rb
deimos-ruby-1.23.1.pre.beta4 lib/deimos/metrics/datadog.rb
deimos-ruby-1.23.1.pre.beta3 lib/deimos/metrics/datadog.rb
deimos-ruby-1.23.1.pre.beta2 lib/deimos/metrics/datadog.rb
deimos-ruby-1.23.1.pre.beta1 lib/deimos/metrics/datadog.rb
deimos-ruby-1.23.0 lib/deimos/metrics/datadog.rb
deimos-ruby-1.22.5 lib/deimos/metrics/datadog.rb
deimos-ruby-1.22.4 lib/deimos/metrics/datadog.rb
deimos-ruby-1.22.3 lib/deimos/metrics/datadog.rb
deimos-ruby-1.22.2 lib/deimos/metrics/datadog.rb
deimos-ruby-1.22.1 lib/deimos/metrics/datadog.rb
deimos-ruby-1.22 lib/deimos/metrics/datadog.rb
deimos-ruby-1.20.1 lib/deimos/metrics/datadog.rb
deimos-ruby-1.20.0 lib/deimos/metrics/datadog.rb
deimos-ruby-1.19.7 lib/deimos/metrics/datadog.rb