Sha256: 63fb7bd00ab3dae6845e7ef02653020bfb96e0acb060429781ea5f4a14537baa

Contents?: true

Size: 695 Bytes

Versions: 8

Compression:

Stored size: 695 Bytes

Contents

require "inspec/utils/telemetry/collector"

module Inspec
  # A Global method to add a data series object to the Telemetry Collection.
  # `data_series_name`s are unique, so `:dependency_group` will always return
  # the same object.
  # `data_point` is optional, you may also supply a block with several data points.
  # All data points should allow #to_s
  def self.record_telemetry_data(data_series_name, data_point = nil)
    coll = Inspec::Telemetry::Collector.instance
    return unless coll.telemetry_enabled?
    ds = coll.find_or_create_data_series(data_series_name)
    return unless ds.enabled?

    if block_given?
      ds << yield
    else
      ds << data_point
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
inspec-core-4.7.3 lib/inspec/utils/telemetry/global_methods.rb
inspec-4.7.3 lib/inspec/utils/telemetry/global_methods.rb
inspec-core-4.6.9 lib/inspec/utils/telemetry/global_methods.rb
inspec-4.6.9 lib/inspec/utils/telemetry/global_methods.rb
inspec-core-4.6.4 lib/inspec/utils/telemetry/global_methods.rb
inspec-4.6.4 lib/inspec/utils/telemetry/global_methods.rb
inspec-core-4.6.3 lib/inspec/utils/telemetry/global_methods.rb
inspec-4.6.3 lib/inspec/utils/telemetry/global_methods.rb