diff --git a/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/logger.rb b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/logger.rb index b8a13216f6..13d3006116 100644 --- a/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/logger.rb +++ b/instrumentation/logger/lib/opentelemetry/instrumentation/logger/patches/logger.rb @@ -23,7 +23,7 @@ def format_message(severity, datetime, progname, msg) severity_text: severity, severity_number: severity_number(severity), timestamp: datetime, - body: msg, + body: formatted_message, context: OpenTelemetry::Context.current ) formatted_message diff --git a/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger_test.rb b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger_test.rb index 449b4e5632..f9cb36830c 100644 --- a/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger_test.rb +++ b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/active_support_broadcast_logger_test.rb @@ -38,7 +38,8 @@ assert_equal 1, log_records.size assert_equal 'DEBUG', log_records.first.severity_text - assert_equal body, log_records.first.body + assert_includes log_records.first.body, 'DEBUG' + assert_includes log_records.first.body, body end end @@ -59,7 +60,8 @@ assert_equal 1, log_records.size assert_equal 'ANY', log_records.first.severity_text - assert_equal body, log_records.first.body + assert_includes log_records.first.body, 'ANY' + assert_includes log_records.first.body, body end end @@ -81,7 +83,8 @@ assert_equal 1, log_records.size assert_equal severity.upcase, log_records.first.severity_text - assert_equal body, log_records.first.body + assert_includes log_records.first.body, severity.upcase + assert_includes log_records.first.body, body end end end diff --git a/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/logger_test.rb b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/logger_test.rb index 7c91621601..1f85abce6a 100644 --- a/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/logger_test.rb +++ b/instrumentation/logger/test/opentelemetry/instrumentation/logger/patches/logger_test.rb @@ -42,7 +42,8 @@ Time.stub(:now, timestamp) do ruby_logger.debug(msg) - assert_equal(msg, log_record.body) + assert_includes(log_record.body, msg) + assert_includes(log_record.body, 'DEBUG') assert_equal('DEBUG', log_record.severity_text) assert_equal(5, log_record.severity_number) assert_equal(nano_timestamp, log_record.timestamp)