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

#cidObject (readonly)

Returns the value of attribute cid

Returns:

  • (Object)

    the current value of cid



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

def cid
  @cid
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



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

def name
  @name
end

#payloadObject (readonly)

Returns the value of attribute payload

Returns:

  • (Object)

    the current value of payload



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

def payload
  @payload
end

#rootObject (readonly)

Returns the value of attribute root

Returns:

  • (Object)

    the current value of root



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

def root
  @root
end

#taskObject (readonly)

Returns the value of attribute task

Returns:

  • (Object)

    the current value of task



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

def task
  @task
end

#tidObject (readonly)

Returns the value of attribute tid

Returns:

  • (Object)

    the current value of tid



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

def tid
  @tid
end

#timestampObject (readonly)

Returns the value of attribute timestamp

Returns:

  • (Object)

    the current value of timestamp



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

def timestamp
  @timestamp
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



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

def type
  @type
end

#xidObject (readonly)

Returns the value of attribute xid

Returns:

  • (Object)

    the current value of xid



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

def xid
  @xid
end

Class Method Details

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



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

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