test/formatters/signalfx_test.rb in semantic_logger-4.2.0 vs test/formatters/signalfx_test.rb in semantic_logger-4.2.1

- old
+ new

@@ -21,19 +21,19 @@ end let :logs do 3.times.collect do |i| l = log.dup - l.metric = "/user/login#{i+1}" + l.metric = "/user/login#{i + 1}" l end end let :same_logs do - 3.times.collect do |i| + 3.times.collect do |_i| l = log.dup - l.metric = "/user/login" + l.metric = '/user/login' l end end let :dimensions do @@ -71,38 +71,38 @@ assert counters = hash['counter'], hash assert counter = counters.first, hash assert_equal counter_metric_name, counter['metric'], counter assert_equal 1, counter['value'], counter assert_equal (log.time.to_i * 1_000).to_i, counter['timestamp'], counter - assert counter.has_key?('dimensions') + assert counter.key?('dimensions') end it 'send gauge metric when log includes duration' do log.duration = 1234 hash = result assert counters = hash['gauge'], hash assert counter = counters.first, hash assert_equal average_metric_name, counter['metric'], counter assert_equal 1234, counter['value'], counter assert_equal (log.time.to_i * 1_000).to_i, counter['timestamp'], counter - assert counter.has_key?('dimensions') + assert counter.key?('dimensions') end it 'also sends counter metric when gauge metric is sent' do log.duration = 1234 hash = result assert counters = hash['counter'], hash assert counter = counters.first, hash assert_equal counter_metric_name, counter['metric'], counter assert_equal 1, counter['value'], counter assert_equal (log.time.to_i * 1_000).to_i, counter['timestamp'], counter - assert counter.has_key?('dimensions') + assert counter.key?('dimensions') end it 'only forwards whitelisted dimensions from named_tags' do log.named_tags = {user_id: 47, tracking_number: 7474, session_id: 'hsdhngsd'} - formatter.dimensions = [:user_id, :application] + formatter.dimensions = %i[user_id application] hash = result assert counters = hash['counter'], hash assert counter = counters.first, hash assert_equal({'class' => 'user', 'action' => 'login', 'environment' => 'test', 'user_id' => '47', 'host' => SemanticLogger.host, 'application' => SemanticLogger.application}, counter['dimensions'], counter) end @@ -154,11 +154,11 @@ assert_equal average_metric_name, gauges[2]['metric'] end describe 'send custom' do let :logs do - 3.times.collect do |i| + 3.times.collect do |_i| l = log.dup l.metric = 'Filter/count' l.dimensions = dimensions l end @@ -173,11 +173,10 @@ assert_equal 3, counter['value'], counter assert_equal (log.time.to_i * 1_000).to_i, counter['timestamp'], counter assert_equal all_dimensions, counter['dimensions'] end end - end describe 'format batch logs with aggregation' do let :result do JSON.parse(formatter.batch(same_logs, appender)) @@ -190,11 +189,9 @@ assert_equal 1, counters.size assert_equal counter_metric_name, counters[0]['metric'] assert_equal 3, counters[0]['value'] end end - end - end end end