Class: DatadogFormatter
- Inherits:
-
RSpec::Core::Formatters::JsonFormatter
- Object
- RSpec::Core::Formatters::JsonFormatter
- DatadogFormatter
- Defined in:
- lib/rspec/datadog.rb
Constant Summary collapse
- BASE_TAGS =
Override this to add custom base tags - name of the system under test, for example
[]
- KEYS_TO_EMIT =
[:full_description, :status, :file_path, :line_number].freeze
Instance Method Summary collapse
- #close(_notification = nil) ⇒ Object
-
#initialize(output) ⇒ DatadogFormatter
constructor
A new instance of DatadogFormatter.
Constructor Details
#initialize(output) ⇒ DatadogFormatter
Returns a new instance of DatadogFormatter.
23 24 25 26 27 28 |
# File 'lib/rspec/datadog.rb', line 23 def initialize(output) # Initialize Dogapi client @dog = Dogapi::Client.new(ENV['DATADOG_API_KEY'], ENV['DATADOG_APPLICATION_KEY']) super end |
Instance Method Details
#close(_notification = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rspec/datadog.rb', line 30 def close(_notification=nil) # Set now to a value shared by all events for this test run now = Time.now.to_i datadog_events = @output_hash[:examples].map do |example| = ( example.slice(*KEYS_TO_EMIT) ) Dogapi::Event.new("#{example[:full_description]}: #{example[:status]}", :msg_title => "RSpec example", :tags => BASE_TAGS + , :date_happened => now ) end datadog_events.each do |event| emit_event(event) end end |