Module: Datadog::Contrib::RSpec::Example::InstanceMethods
- Defined in:
- lib/ddtrace/contrib/rspec/example.rb
Overview
Instance methods for configuration
Instance Method Summary collapse
Instance Method Details
#run(example_group_instance, reporter) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ddtrace/contrib/rspec/example.rb', line 12 def run(example_group_instance, reporter) return super unless configuration[:enabled] test_name = full_description.strip if [:description].empty? # for unnamed it blocks this appends something like "example at ./spec/some_spec.rb:10" test_name += " #{description}" end = { app: Ext::APP, resource: test_name, service: configuration[:service_name], span_type: Datadog::Ext::AppTypes::TEST, tags: .merge(Datadog.configuration.) } tracer.trace(configuration[:operation_name], ) do |span| span.set_tag(Datadog::Ext::Test::TAG_FRAMEWORK, Ext::FRAMEWORK) span.set_tag(Datadog::Ext::Test::TAG_NAME, test_name) span.set_tag(Datadog::Ext::Test::TAG_SUITE, file_path) span.set_tag(Datadog::Ext::Test::TAG_TYPE, Ext::TEST_TYPE) span.set_tag(Datadog::Ext::Test::TAG_SPAN_KIND, Datadog::Ext::AppTypes::TEST) # Measure service stats Contrib::Analytics.set_measured(span) result = super case execution_result.status when :passed span.set_tag(Datadog::Ext::Test::TAG_STATUS, Datadog::Ext::Test::Status::PASS) when :failed span.status = 1 span.set_tag(Datadog::Ext::Test::TAG_STATUS, Datadog::Ext::Test::Status::FAIL) span.set_error(execution_result.exception) else if execution_result.example_skipped? span.set_tag(Datadog::Ext::Test::TAG_STATUS, Datadog::Ext::Test::Status::SKIP) end end result end end |