Honeylixir.Event (honeylixir v0.4.0) View Source

Used for managing Events and holding their data. It also has a send function that really just kicks off the sending process which happens asynchronously.

Link to this section Summary

Types

An RFC3339 formatted timestamp

t()

A struct containing all the data of an event.

Functions

Adds a map of fields into the existing set.

Add a single key/value pair to the event.

Adds to the metadata of the event.

Creates an event using the current timestamp, configured values for sending, and no initial fields other than service_name if configured.

create/1 accepts either a timestamp or a set of fields to initialize the Honeylixir.Event.

Accepts both a timestamp in RFC3339 format and a map of key/values to initialize the Event struct with.

Used for acknowledging the event is ready for sending, passing it off to be sent asynchronously. Currently nothing stops a user from sending the same event twice.

Link to this section Types

Specs

rfc_timestamp() :: String.t()

An RFC3339 formatted timestamp

"2020-09-29 04:36:15Z"

Specs

t() :: %Honeylixir.Event{
  api_host: String.t(),
  dataset: String.t() | atom(),
  fields: map(),
  metadata: map(),
  sample_rate: integer(),
  team_writekey: String.t(),
  timestamp: rfc_timestamp()
}

A struct containing all the data of an event.

By default, an event is constructed with the values in the configuration defined in Honeylixir. Any field can be overwritten via regular struct assigning of values.

event = Honeylixir.Event.create()
event = %{event | api_host: "something-else.com"}

An Event also includes two other fields:

  • fields - The set of fields which will be sent to Honeycomb as the event body
  • metadata - A map of extra data that may be provided as part of a response.

Link to this section Functions

Specs

add(t(), map()) :: t()

Adds a map of fields into the existing set.

Examples

iex> event = Honeylixir.Event.create()
iex> Honeylixir.Event.add(event, %{"another" => "field", "service_name" => "foobar"}).fields
%{"service_name" => "foobar", "another" => "field"}
Link to this function

add_field(event, field, value)

View Source (since 0.1.0)

Specs

add_field(t(), String.t(), any()) :: t()

Add a single key/value pair to the event.

Examples

iex> event = Honeylixir.Event.create()
iex> Honeylixir.Event.add_field(event, "key", "other").fields
%{"service_name" => "honeylixir-tests", "key" => "other"}
Link to this function

add_metadata(event, metadata)

View Source

Specs

add_metadata(t(), map()) :: t()

Adds to the metadata of the event.

This information is NOT passed along to LaunchDarkly and should only be used by the consuming application to keep track of an event.

Examples

iex> event = Honeylixir.Event.create()
iex> Honeylixir.Event.add_metadata(event, %{"some_key" => "some_value"}).metadata
%{"some_key" => "some_value"}

Specs

create() :: t()

Creates an event using the current timestamp, configured values for sending, and no initial fields other than service_name if configured.

event = Honeycomb.Event.create()
Link to this function

create(fields_or_timestamp)

View Source (since 0.1.0)

Specs

create(rfc_timestamp() | map()) :: t()

create/1 accepts either a timestamp or a set of fields to initialize the Honeylixir.Event.

event = Honeylixir.Event.create("2020-09-29 04:36:15Z")
event = Honeylixir.Event.create(%{"field1" => "value1"})
Link to this function

create(timestamp, fields)

View Source (since 0.1.0)

Specs

create(rfc_timestamp(), map()) :: t()

Accepts both a timestamp in RFC3339 format and a map of key/values to initialize the Event struct with.

Specs

send(t()) :: :ok

Used for acknowledging the event is ready for sending, passing it off to be sent asynchronously. Currently nothing stops a user from sending the same event twice.

If the event is sampled, a Honeylixir.Response is sent via :telemetry immediately.