Class: Chef::Telemetry
- Inherits:
-
Object
- Object
- Chef::Telemetry
- Defined in:
- lib/chef/telemetry.rb,
lib/chef/telemetry/event.rb,
lib/chef/telemetry/client.rb,
lib/chef/telemetry/session.rb,
lib/chef/telemetry/version.rb,
lib/chef/telemetry/decision.rb
Defined Under Namespace
Modules: Decision Classes: Client, Event, OptOutClient, Session
Constant Summary collapse
- VERSION =
"1.0.3".freeze
Instance Attribute Summary collapse
-
#install_context ⇒ Object
Returns the value of attribute install_context.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#product ⇒ Object
Returns the value of attribute product.
-
#product_version ⇒ Object
Returns the value of attribute product_version.
Instance Method Summary collapse
- #client ⇒ Object
- #deliver(data = {}) ⇒ Object
- #event ⇒ Object
-
#initialize(product: nil, origin: "command-line", product_version: "0.0.0", install_context: "omnibus") ⇒ Telemetry
constructor
A new instance of Telemetry.
- #opt_out? ⇒ Boolean
- #session ⇒ Object
Constructor Details
#initialize(product: nil, origin: "command-line", product_version: "0.0.0", install_context: "omnibus") ⇒ Telemetry
Returns a new instance of Telemetry.
10 11 12 13 14 15 16 17 18 |
# File 'lib/chef/telemetry.rb', line 10 def initialize(product: nil, origin: "command-line", product_version: "0.0.0", install_context: "omnibus") # Reference: https://github.com/chef/es-telemetry-pipeline/blob/0730c1e2605624a50d34bab6d036b73c31e0ab0e/schema/event.schema.json#L77 @product = product @origin = origin @product_version = product_version @install_context = install_context # Valid: habitat, omnibus end |
Instance Attribute Details
#install_context ⇒ Object
Returns the value of attribute install_context.
9 10 11 |
# File 'lib/chef/telemetry.rb', line 9 def install_context @install_context end |
#origin ⇒ Object
Returns the value of attribute origin.
9 10 11 |
# File 'lib/chef/telemetry.rb', line 9 def origin @origin end |
#product ⇒ Object
Returns the value of attribute product.
9 10 11 |
# File 'lib/chef/telemetry.rb', line 9 def product @product end |
#product_version ⇒ Object
Returns the value of attribute product_version.
9 10 11 |
# File 'lib/chef/telemetry.rb', line 9 def product_version @product_version end |
Instance Method Details
#client ⇒ Object
40 41 42 43 |
# File 'lib/chef/telemetry.rb', line 40 def client endpoint = ENV.fetch("CHEF_TELEMETRY_ENDPOINT", Client::TELEMETRY_ENDPOINT) @client ||= Client.new(endpoint) end |
#deliver(data = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/chef/telemetry.rb', line 20 def deliver(data = {}) unless opt_out? payload = event.prepare(data) client.await.fire(payload) end end |
#event ⇒ Object
27 28 29 30 |
# File 'lib/chef/telemetry.rb', line 27 def event @event ||= Event.new(product, session, origin, install_context, product_version) end |