Class: Contrast::Agent::Reporting::ObservedLibraryUsage

Inherits:
ApplicationReportingEvent show all
Defined in:
lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb

Overview

List of libraries that have been observed to have something loaded or executed.

Instance Attribute Summary collapse

Attributes inherited from ReportingEvent

#event_endpoint, #event_method

Instance Method Summary collapse

Methods inherited from ReportingEvent

#attach_headers

Methods inherited from ReportableHash

#event_json, #valid?

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Constructor Details

#initializeObservedLibraryUsage

Returns a new instance of ObservedLibraryUsage.



16
17
18
19
20
# File 'lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb', line 16

def initialize
  @event_endpoint = Contrast::Agent::Reporting::Endpoints.library_usage
  @observations = []
  super()
end

Instance Attribute Details

#observationsObject (readonly)

Returns the value of attribute observations.



14
15
16
# File 'lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb', line 14

def observations
  @observations
end

Instance Method Details

#file_nameObject



22
23
24
# File 'lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb', line 22

def file_name
  'library-observation'
end

#to_controlled_hashObject



26
27
28
29
# File 'lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb', line 26

def to_controlled_hash
  validate
  { observations: @observations.map(&:to_controlled_hash) }
end

#validateObject

Raises:

  • (ArgumentError)


31
32
33
34
35
# File 'lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb', line 31

def validate
  raise(ArgumentError, "#{ self } did not have observations. Unable to continue.") if observations.empty?

  nil
end