Sha256: 2c4b354e291a524e75ea9f4225b83c7d9d35322ea4467a5eac56e542ca4922f7

Contents?: true

Size: 737 Bytes

Versions: 6

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true

require 'test_helper'

class LoggerBackendTest < Minitest::Test
  def setup
    logger = Logger.new(@io = StringIO.new)
    logger.formatter = lambda { |_, _, _, msg| "#{msg}\n" }
    @backend = StatsD::Instrument::Backends::LoggerBackend.new(logger)
    @metric1 = StatsD::Instrument::Metric.new(type: :c, name: 'mock.counter', tags: { a: 'b', c: 'd' })
    @metric2 = StatsD::Instrument::Metric.new(type: :ms, name: 'mock.measure', value: 123, sample_rate: 0.3)
  end

  def test_logs_metrics
    @backend.collect_metric(@metric1)
    @backend.collect_metric(@metric2)
    assert_equal <<~LOG, @io.string
      [StatsD] mock.counter:1|c|#a:b,c:d
      [StatsD] mock.measure:123|ms|@0.3
    LOG
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
statsd-instrument-2.9.2 test/logger_backend_test.rb
statsd-instrument-2.9.1 test/logger_backend_test.rb
statsd-instrument-2.9.0 test/logger_backend_test.rb
statsd-instrument-2.8.0 test/logger_backend_test.rb
statsd-instrument-2.7.1 test/logger_backend_test.rb
statsd-instrument-2.7.0 test/logger_backend_test.rb