Sha256: fad096568d728fcfe69f1cf8a28984bcc4c34cc6e35c9f14c980a5fafab6efed

Contents?: true

Size: 977 Bytes

Versions: 41

Compression:

Stored size: 977 Bytes

Contents

# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2021

require 'test_helper'

class InstrumentedLoggerTest < Minitest::Test
  def setup
    clear_all!
  end

  def test_log_warn_error
    subject = Instana::InstrumentedLogger.new('/dev/null')

    Instana::Tracer.start_or_continue_trace(:test_logging) do
      subject.warn('warn')
      subject.debug('test')
      subject.error('error')
    end

    spans = ::Instana.processor.queued_spans

    warn_span, error_span, = *spans

    assert_equal :log, warn_span[:n]
    assert_equal 'warn', warn_span[:data][:log][:message]
    assert_equal 'Warn', warn_span[:data][:log][:level]

    assert_equal :log, error_span[:n]
    assert_equal 'error', error_span[:data][:log][:message]
    assert_equal 'Error', error_span[:data][:log][:level]
  end

  def test_no_trace
    subject = Instana::InstrumentedLogger.new('/dev/null')
    subject.warn('warn')

    assert_equal [], ::Instana.processor.queued_spans
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
instana-1.217.1 test/tracing/instrumented_logger_test.rb
instana-1.217.0 test/tracing/instrumented_logger_test.rb
instana-1.216.0 test/tracing/instrumented_logger_test.rb
instana-1.215.1 test/tracing/instrumented_logger_test.rb
instana-1.215.0 test/tracing/instrumented_logger_test.rb
instana-1.214.4 test/tracing/instrumented_logger_test.rb
instana-1.214.3 test/tracing/instrumented_logger_test.rb
instana-1.214.2 test/tracing/instrumented_logger_test.rb
instana-1.214.1 test/tracing/instrumented_logger_test.rb
instana-1.214.0 test/tracing/instrumented_logger_test.rb
instana-1.213.3 test/tracing/instrumented_logger_test.rb
instana-1.213.2 test/tracing/instrumented_logger_test.rb
instana-1.213.1 test/tracing/instrumented_logger_test.rb
instana-1.213.0 test/tracing/instrumented_logger_test.rb
instana-1.212.0 test/tracing/instrumented_logger_test.rb
instana-1.211.0 test/tracing/instrumented_logger_test.rb
instana-1.210.1 test/tracing/instrumented_logger_test.rb
instana-1.210.0 test/tracing/instrumented_logger_test.rb
instana-1.209.8 test/tracing/instrumented_logger_test.rb
instana-1.209.7 test/tracing/instrumented_logger_test.rb