# `WardrikEvents.CloudEvent`

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

# `t`

```elixir
@type t() :: %{required(String.t()) =&gt; term()}
```

A CloudEvent, with string keys.

# `audit_source`

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

Returns the `source` of the audit's changes.

# `new`

```elixir
@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`

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

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

# `source`

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

Returns the `source` of an agent's events.

# `trace_id`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
