Module: Datadog::CI::Contrib::Minitest::Hooks
- Defined in:
- lib/datadog/ci/contrib/minitest/hooks.rb
Overview
Lifecycle hooks to instrument Minitest::Test
Instance Method Summary collapse
Instance Method Details
#after_teardown ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/datadog/ci/contrib/minitest/hooks.rb', line 40 def after_teardown span = Thread.current[:_datadog_test_span] return super unless span Thread.current[:_datadog_test_span] = nil case result_code when "." CI::Recorder.passed!(span) when "E", "F" CI::Recorder.failed!(span, failure) when "S" CI::Recorder.skipped!(span) span.set_tag(CI::Ext::Test::TAG_SKIP_REASON, failure.) end span.finish super end |
#before_setup ⇒ Object
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 |
# File 'lib/datadog/ci/contrib/minitest/hooks.rb', line 13 def before_setup super return unless configuration[:enabled] test_name = "#{class_name}##{name}" path, = method(name).source_location test_suite = Pathname.new(path.to_s).relative_path_from(Pathname.pwd).to_s span = CI::Recorder.trace( configuration[:operation_name], { span_options: { resource: test_name, service: configuration[:service_name] }, framework: Ext::FRAMEWORK, framework_version: CI::Contrib::Minitest::Integration.version.to_s, test_name: test_name, test_suite: test_suite, test_type: Ext::TEST_TYPE } ) Thread.current[:_datadog_test_span] = span end |