Sha256: 18994f3c2ecc653e50c44988e0e33f213434ee653a9ded6469a274c7d7bda585

Contents?: true

Size: 804 Bytes

Versions: 10

Compression:

Stored size: 804 Bytes

Contents

# frozen_string_literal: true

module StatsD
  module Instrument
    module Helpers
      def capture_statsd_datagrams(client: nil, &block)
        client ||= StatsD.singleton_client
        client.capture(&block)
      end

      # For backwards compatibility
      alias_method :capture_statsd_calls, :capture_statsd_datagrams

      def self.add_tag(tags, key, value)
        tags = tags.dup || {}

        if tags.is_a?(String)
          tags = tags.empty? ? "#{key}:#{value}" : "#{tags},#{key}:#{value}"
        elsif tags.is_a?(Array)
          tags << "#{key}:#{value}"
        elsif tags.is_a?(Hash)
          tags[key] = value
        else
          raise ArgumentError, "add_tag only supports string, array or hash, #{tags.class} provided"
        end

        tags
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
statsd-instrument-3.5.5 lib/statsd/instrument/helpers.rb
statsd-instrument-3.5.4 lib/statsd/instrument/helpers.rb
statsd-instrument-3.5.3 lib/statsd/instrument/helpers.rb
statsd-instrument-3.5.2 lib/statsd/instrument/helpers.rb
statsd-instrument-3.5.1 lib/statsd/instrument/helpers.rb
statsd-instrument-3.5.0 lib/statsd/instrument/helpers.rb
statsd-instrument-3.4.0 lib/statsd/instrument/helpers.rb
statsd-instrument-3.3.0 lib/statsd/instrument/helpers.rb
statsd-instrument-3.2.1 lib/statsd/instrument/helpers.rb
statsd-instrument-3.2.0 lib/statsd/instrument/helpers.rb