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 ⇒ Object
-
#initialize(output) ⇒ DatadogFormatter
constructor
A new instance of DatadogFormatter.
Constructor Details
#initialize(output) ⇒ DatadogFormatter
Returns a new instance of DatadogFormatter.
14 15 16 17 18 19 |
# File 'lib/rspec/datadog.rb', line 14 def initialize(output) super # Initialize Dogapi client @dog = Dogapi::Client.new(ENV['DATADOG_API_KEY'], ENV['DATADOG_APPLICATION_KEY']) end |
Instance Method Details
#close ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rspec/datadog.rb', line 21 def close # 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 |