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.209.6 test/tracing/instrumented_logger_test.rb
instana-1.209.5 test/tracing/instrumented_logger_test.rb
instana-1.209.4 test/tracing/instrumented_logger_test.rb
instana-1.209.3 test/tracing/instrumented_logger_test.rb
instana-1.209.2 test/tracing/instrumented_logger_test.rb
instana-1.209.1 test/tracing/instrumented_logger_test.rb
instana-1.209.0.pre3 test/tracing/instrumented_logger_test.rb
instana-1.209.0.pre2 test/tracing/instrumented_logger_test.rb
instana-1.209.0.pre1 test/tracing/instrumented_logger_test.rb
instana-1.208.0 test/tracing/instrumented_logger_test.rb
instana-1.207.0 test/tracing/instrumented_logger_test.rb
instana-1.206.0 test/tracing/instrumented_logger_test.rb
instana-1.205.0 test/tracing/instrumented_logger_test.rb
instana-1.204.0 test/tracing/instrumented_logger_test.rb
instana-1.204.0.pre3 test/tracing/instrumented_logger_test.rb
instana-1.204.0.pre2 test/tracing/instrumented_logger_test.rb
instana-1.204.0.pre1 test/tracing/instrumented_logger_test.rb
instana-1.203.2 test/tracing/instrumented_logger_test.rb
instana-1.203.1 test/tracing/instrumented_logger_test.rb
instana-1.203.0 test/tracing/instrumented_logger_test.rb