Sha256: 1a74e1bc232546510f124e2fc6e784129bbd5b03fe334d6023c0a192130032bc

Contents?: true

Size: 749 Bytes

Versions: 36

Compression:

Stored size: 749 Bytes

Contents

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)
    assert_equal @io.string, "[StatsD] increment mock.counter:1 #a:b #c:d\n"
    @io.string = ""

    @backend.collect_metric(@metric2)
    assert_equal @io.string, "[StatsD] measure mock.measure:123 @0.3\n"
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
statsd-instrument-2.1.0 test/logger_backend_test.rb
statsd-instrument-2.0.12 test/logger_backend_test.rb
statsd-instrument-2.0.11 test/logger_backend_test.rb
statsd-instrument-2.0.10 test/logger_backend_test.rb
statsd-instrument-2.0.9 test/logger_backend_test.rb
statsd-instrument-2.0.8 test/logger_backend_test.rb
statsd-instrument-2.0.7 test/logger_backend_test.rb
statsd-instrument-2.0.6 test/logger_backend_test.rb
statsd-instrument-2.0.5 test/logger_backend_test.rb
statsd-instrument-2.0.4 test/logger_backend_test.rb
statsd-instrument-2.0.3 test/logger_backend_test.rb
statsd-instrument-2.0.2 test/logger_backend_test.rb
statsd-instrument-2.0.1 test/logger_backend_test.rb
statsd-instrument-2.0.0 test/logger_backend_test.rb
statsd-instrument-2.0.0beta2 test/logger_backend_test.rb
statsd-instrument-2.0.0beta test/logger_backend_test.rb