Class: Inspec::Telemetry::Collector

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/inspec/utils/telemetry/collector.rb

Overview

A Singleton collection of data series objects.

Instance Method Summary collapse

Constructor Details

#initializeCollector

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.

Returns:

  • (True)


16
17
18
# File 'lib/inspec/utils/telemetry/collector.rb', line 16

def add_data_series(data_series)
  @data_series << data_series
end

#disable_telemetryTrue

A way to disable the telemetry system.

Returns:

  • (True)


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_seriesArray

The entire data series collection.

Returns:

  • (Array)


35
36
37
# File 'lib/inspec/utils/telemetry/collector.rb', line 35

def list_data_series
  @data_series
end

#resetTrue

Blanks the contents of the data series collection.

Returns:

  • (True)


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.

Returns:

  • (True, False)


23
24
25
# File 'lib/inspec/utils/telemetry/collector.rb', line 23

def telemetry_enabled?
  @enabled
end