Sha256: c56258576a587697c49779938e753026b828c9c39871fff7342b1fa38dfc7978
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true require 'active_support' require 'gem_config' require 'datadog/statsd' module DogStatsd module Instrumentation module ClientProvider include GemConfig::Base with_configuration do has :enabled, classes: [TrueClass, FalseClass], default: true has :tags, classes: Array, default: [] has :tags_h, classes: Hash, default: {} has :namespace, classes: String has :host, classes: String, default: Datadog::Statsd::DEFAULT_HOST has :port, classes: Integer, default: Datadog::Statsd::DEFAULT_PORT has :opts, classes: Hash, default: {} has :max_buffer_size, classes: Integer, default: 50 end def self.new client = Datadog::Statsd.new( configuration.host, configuration.port, configuration.opts.merge(namespace: configuration.namespace, tags: configuration.tags + tagify(configuration.tags_h)), configuration.max_buffer_size ) def client.send_stats(stat, delta, type, opts={}) super if ClientProvider.configuration.enabled end client end def self.tagify(hash) hash.select { |_, value| value.present? }.map { |key, value| "#{key}:#{value}" } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dogstatsd-instrumentation-0.1.4 | lib/dogstatsd/instrumentation/client_provider.rb |