WardrikEvents.CloudEvent (wardrik_events v0.1.0-rc.1)

Copy Markdown

Builds events as Wardrik sends them: CloudEvents maps with string keys and the payload under "data".

Summary

Types

t()

A CloudEvent, with string keys.

Functions

Returns the source of the audit's changes.

Builds an event of type about subject.

Puts the event's place in its log as the sequence extension, padded to 12 digits.

Returns the source of an agent's events.

Returns the trace id in the event's traceparent, which is its run's id. Returns nil if there's none.

Types

t()

@type t() :: %{required(String.t()) => term()}

A CloudEvent, with string keys.

Functions

audit_source(deployment)

@spec audit_source(String.t()) :: String.t()

Returns the source of the audit's changes.

new(type, subject, data, opts)

@spec new(String.t(), String.t(), map(), keyword()) :: t()

Builds an event of type about subject.

WardrikEvents.CloudEvent.new("run.started", "runs/0af7...", data,
  deployment: "acme-prod",
  agent_id: "acme/triage",
  time: DateTime.utc_now()
)

type leaves out the wardrik. prefix, which is added.

Options

  • :time - required. When it happened.
  • :deployment - the deployment's name. Required unless :source is set.
  • :agent_id - the agent the event is about. Required unless :source is set.
  • :source - the event's source, for an event that isn't an agent's.
  • :span - the WardrikCore.Span it happened in. A new root span unless set.

sequenced(event, sequence)

@spec sequenced(t(), pos_integer()) :: t()

Puts the event's place in its log as the sequence extension, padded to 12 digits.

source(deployment, agent_id)

@spec source(String.t(), String.t()) :: String.t()

Returns the source of an agent's events.

trace_id(arg1)

@spec trace_id(t()) :: String.t() | nil

Returns the trace id in the event's traceparent, which is its run's id. Returns nil if there's none.