Class: CMDx::Telemetry::Event

Inherits:
Data
  • Object
show all
Defined in:
lib/cmdx/telemetry.rb

Overview

Immutable event payload passed to subscribers.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#cid ⇒ Object (readonly)

Returns the value of attribute cid

Returns:

  • (Object) —

    the current value of cid



11
12
13
# File 'lib/cmdx/telemetry.rb', line 11

def cid
  @cid
end

#name ⇒ Object (readonly)

Returns the value of attribute name

Returns:

  • (Object) —

    the current value of name



11
12
13
# File 'lib/cmdx/telemetry.rb', line 11

def name
  @name
end

#payload ⇒ Object (readonly)

Returns the value of attribute payload

Returns:

  • (Object) —

    the current value of payload



11
12
13
# File 'lib/cmdx/telemetry.rb', line 11

def payload
  @payload
end

#root ⇒ Object (readonly)

Returns the value of attribute root

Returns:

  • (Object) —

    the current value of root



11
12
13
# File 'lib/cmdx/telemetry.rb', line 11

def root
  @root
end

#task ⇒ Object (readonly)

Returns the value of attribute task

Returns:

  • (Object) —

    the current value of task



11
12
13
# File 'lib/cmdx/telemetry.rb', line 11

def task
  @task
end

#tid ⇒ Object (readonly)

Returns the value of attribute tid

Returns:

  • (Object) —

    the current value of tid



11
12
13
# File 'lib/cmdx/telemetry.rb', line 11

def tid
  @tid
end

#timestamp ⇒ Object (readonly)

Returns the value of attribute timestamp

Returns:

  • (Object) —

    the current value of timestamp



11
12
13
# File 'lib/cmdx/telemetry.rb', line 11

def timestamp
  @timestamp
end

#type ⇒ Object (readonly)

Returns the value of attribute type

Returns:

  • (Object) —

    the current value of type



11
12
13
# File 'lib/cmdx/telemetry.rb', line 11

def type
  @type
end

#xid ⇒ Object (readonly)

Returns the value of attribute xid

Returns:

  • (Object) —

    the current value of xid



11
12
13
# File 'lib/cmdx/telemetry.rb', line 11

def xid
  @xid
end

Class Method Details

.build(task, name, root: false, payload: EMPTY_HASH) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cmdx/telemetry.rb', line 12

def self.build(task, name, root: false, payload: EMPTY_HASH)
  new(
    xid: Chain.current.xid,
    cid: Chain.current.id,
    root:,
    type: task.class.type,
    task: task.class,
    tid: task.tid,
    name:,
    payload:,
    timestamp: Time.now.utc
  )
end