From fada1aeb2fe2c0805555c22a79ea88b27bde14b6 Mon Sep 17 00:00:00 2001 From: Christopher Holmes Date: Mon, 15 Nov 2021 21:42:32 +0000 Subject: [PATCH] add test failure message to otel status description --- .../rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb | 2 +- .../test/opentelemetry/instrumentation/rspec/formatter_test.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb b/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb index 2fe575d672..59d88840b0 100644 --- a/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb +++ b/instrumentation/rspec/lib/opentelemetry/instrumentation/rspec/formatter.rb @@ -75,7 +75,7 @@ def example_finished(notification) if (exception = result.exception) span.record_exception(exception) span.set_attribute('rspec.example.failure_message', exception.message) if exception.is_a? ::RSpec::Expectations::ExpectationNotMetError - span.status = OpenTelemetry::Trace::Status.error + span.status = OpenTelemetry::Trace::Status.error(exception.message) end end end diff --git a/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/formatter_test.rb b/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/formatter_test.rb index 02022fcd2d..f081e33fa7 100644 --- a/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/formatter_test.rb +++ b/instrumentation/rspec/test/opentelemetry/instrumentation/rspec/formatter_test.rb @@ -184,6 +184,7 @@ def run_example(&blk) \e[0m MESSAGE _(subject.attributes['rspec.example.failure_message']).must_equal message + _(subject.status.description).must_equal message _(subject.events.first.attributes['exception.message']).must_equal message end