Sha256: 6242858a700108b19c2070007a179dd2dd80f61f7a0cb3a7b41584e4b7a896d3
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
# So that the NewRelic appender will load the mock $LOAD_PATH.unshift File.dirname(__FILE__) require_relative '../test_helper' # Unit Test for SemanticLogger::Appender::NewRelic module Metric class NewRelicTest < Minitest::Test describe SemanticLogger::Appender::NewRelic do before do @appender = SemanticLogger::Metric::NewRelic.new @message = 'AppenderNewRelicTest log message' end it 'logs counter metric' do name = amount = nil NewRelic::Agent.stub(:increment_metric, ->(name_, amount_) { name = name_, amount = amount_ }) do @appender.info(message: @message, metric: 'User/authenticated') end assert_equal 'Custom/User/authenticated', name.first assert_equal 1, amount end it 'logs duration metric' do name = duration = nil NewRelic::Agent.stub(:record_metric, ->(name_, duration_) { name = name_, duration = duration_ }) do @appender.measure_info(message: @message, metric: 'User/authenticate') do sleep 0.001 end end assert_equal 'Custom/User/authenticate', name.first assert duration end end end end
Version data entries
4 entries across 4 versions & 1 rubygems