Class: Inspec::Telemetry::Collector
- Inherits:
-
Object
- Object
- Inspec::Telemetry::Collector
- Includes:
- Singleton
- Defined in:
- lib/inspec/utils/telemetry/collector.rb
Overview
A Singleton collection of data series objects.
Instance Method Summary collapse
-
#add_data_series(data_series) ⇒ True
Add a data series to the collection.
-
#disable_telemetry ⇒ True
A way to disable the telemetry system.
-
#find_or_create_data_series(name) ⇒ Inspec::Telemetry::DataSeries
Finds the data series object with the specified name and returns it.
-
#initialize ⇒ Collector
constructor
A new instance of Collector.
-
#list_data_series ⇒ Array
The entire data series collection.
-
#reset ⇒ True
Blanks the contents of the data series collection.
-
#telemetry_enabled? ⇒ True, False
Is the Telemetry system enabled or disabled? Always true until we add configuration parsing.
Constructor Details
#initialize ⇒ Collector
Returns a new instance of Collector.
9 10 11 12 |
# File 'lib/inspec/utils/telemetry/collector.rb', line 9 def initialize @data_series = [] @enabled = true end |
Instance Method Details
#add_data_series(data_series) ⇒ True
Add a data series to the collection.
16 17 18 |
# File 'lib/inspec/utils/telemetry/collector.rb', line 16 def add_data_series(data_series) @data_series << data_series end |
#disable_telemetry ⇒ True
A way to disable the telemetry system.
29 30 31 |
# File 'lib/inspec/utils/telemetry/collector.rb', line 29 def disable_telemetry @enabled = false end |
#find_or_create_data_series(name) ⇒ Inspec::Telemetry::DataSeries
Finds the data series object with the specified name and returns it. If it does not exist then creates a new data series with that name and returns it.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/inspec/utils/telemetry/collector.rb', line 43 def find_or_create_data_series(name) ds = @data_series.select { |data_series| data_series.name.eql?(name) } if ds.empty? new_data_series = Inspec::Telemetry::DataSeries.new(name) @data_series << new_data_series new_data_series else ds.first end end |
#list_data_series ⇒ Array
The entire data series collection.
35 36 37 |
# File 'lib/inspec/utils/telemetry/collector.rb', line 35 def list_data_series @data_series end |
#reset ⇒ True
Blanks the contents of the data series collection.
56 57 58 |
# File 'lib/inspec/utils/telemetry/collector.rb', line 56 def reset @data_series = [] end |
#telemetry_enabled? ⇒ True, False
Is the Telemetry system enabled or disabled? Always true until we add configuration parsing.
23 24 25 |
# File 'lib/inspec/utils/telemetry/collector.rb', line 23 def telemetry_enabled? @enabled end |