Class: Chef::Telemetry::Event
- Inherits:
-
Object
- Object
- Chef::Telemetry::Event
- Defined in:
- lib/chef/telemetry/event.rb
Constant Summary collapse
- SKELETON =
{ instance_id: "00000000-0000-0000-0000-000000000000", message_version: 1.0, payload_version: 1.0, license_id: "00000000-0000-0000-0000-000000000000", type: "track", }.freeze
Instance Attribute Summary collapse
-
#install_context ⇒ Object
readonly
Returns the value of attribute install_context.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#product_version ⇒ Object
readonly
Returns the value of attribute product_version.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
-
#initialize(product, session, origin = "command-line", install_context = "omnibus", product_version = "0.0.0") ⇒ Event
constructor
A new instance of Event.
- #prepare(event) ⇒ Object
- #timestamp ⇒ Object
Constructor Details
#initialize(product, session, origin = "command-line", install_context = "omnibus", product_version = "0.0.0") ⇒ Event
Returns a new instance of Event.
15 16 17 18 19 20 21 22 |
# File 'lib/chef/telemetry/event.rb', line 15 def initialize(product, session, origin = "command-line", install_context = "omnibus", product_version = "0.0.0") @product = product @session = session @origin = origin @product_version = product_version @install_context = install_context end |
Instance Attribute Details
#install_context ⇒ Object (readonly)
Returns the value of attribute install_context.
13 14 15 |
# File 'lib/chef/telemetry/event.rb', line 13 def install_context @install_context end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
13 14 15 |
# File 'lib/chef/telemetry/event.rb', line 13 def origin @origin end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
13 14 15 |
# File 'lib/chef/telemetry/event.rb', line 13 def product @product end |
#product_version ⇒ Object (readonly)
Returns the value of attribute product_version.
13 14 15 |
# File 'lib/chef/telemetry/event.rb', line 13 def product_version @product_version end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
13 14 15 |
# File 'lib/chef/telemetry/event.rb', line 13 def session @session end |
Instance Method Details
#prepare(event) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/chef/telemetry/event.rb', line 24 def prepare(event) time = event[:properties][:timestamp] = time body = SKELETON.dup body.tap do |b| b[:session_id] = session.id b[:origin] = origin b[:product] = product b[:product_version] = product_version b[:install_context] = install_context b[:timestamp] = time b[:payload] = event end end |
#timestamp ⇒ Object
39 40 41 |
# File 'lib/chef/telemetry/event.rb', line 39 def Time.now.utc.strftime("%FT%TZ") end |