Honeylixir.Response (honeylixir v0.6.1) View Source

Struct and factory functions for generating certain kinds of Responses.

Link to this section Summary

Types

t()

Response object with data about an event after a send attempt.

Functions

Creates a Honeylixir.Response for an event was sent but not accepted by Honeycomb.

Creates a Honeylixir.Response for an event that was attempted to be sent but failed due to unforeseen HTTP issues, such as a refused connection.

Creates a Honeylixir.Response for an event that got dropped due to queue overflow.

Creates a Honeylixir.Response for an event that got sampled.

Creates a Honeylixir.Response for an event was successfully sent.

Link to this section Types

Specs

t() :: %Honeylixir.Response{
  body: nil | String.t(),
  duration: float(),
  err: nil | :overflow | :sampled | :http_error,
  metadata: map(),
  status_code: nil | integer()
}

Response object with data about an event after a send attempt.

  • metadata - the metadata from the Event a user can use to correlate this response with a specific event
  • duration - time in ms it took to send the event, HTTP time only.
  • status_code - status code for this event from Honeycomb
  • body - the body associated with this event
  • err - set if an error occurs in sending, such as a max queue size overflow or when the event is sampled

Link to this section Functions

Link to this function

failure_response(event, duration, status_code, body)

View Source

Specs

failure_response(Honeylixir.Event.t(), float(), integer(), String.t()) :: t()

Creates a Honeylixir.Response for an event was sent but not accepted by Honeycomb.

Examples

iex> event = Honeylixir.Event.create()
iex> event = %{event | metadata: %{id: 1}}
iex> Honeylixir.Response.failure_response(event, 10.2232, 401, "unknown api key")
%Honeylixir.Response{metadata: %{id: 1}, duration: 10.2232, status_code: 401, body: "unknown api key", err: nil}
Link to this function

http_error_response(event, duration)

View Source

Specs

http_error_response(Honeylixir.Event.t(), float()) :: t()

Creates a Honeylixir.Response for an event that was attempted to be sent but failed due to unforeseen HTTP issues, such as a refused connection.

Examples

iex> event = Honeylixir.Event.create()
iex> event = %{event | metadata: %{id: 1}}
iex> Honeylixir.Response.http_error_response(event, 10.2232)
%Honeylixir.Response{metadata: %{id: 1}, duration: 10.2232, status_code: nil, body: nil, err: :http_error}
Link to this function

overflow_response(event)

View Source

Specs

overflow_response(Honeylixir.Event.t()) :: t()

Creates a Honeylixir.Response for an event that got dropped due to queue overflow.

Examples

iex> event = Honeylixir.Event.create()
iex> event = %{event | metadata: %{id: 1}}
iex> Honeylixir.Response.overflow_response(event)
%Honeylixir.Response{metadata: %{id: 1}, duration: 0, status_code: nil, body: nil, err: :overflow}

Specs

sampled_response(Honeylixir.Event.t()) :: t()

Creates a Honeylixir.Response for an event that got sampled.

Examples

iex> event = Honeylixir.Event.create()
iex> event = %{event | metadata: %{id: 1}}
iex> Honeylixir.Response.sampled_response(event)
%Honeylixir.Response{metadata: %{id: 1}, duration: 0, status_code: nil, body: nil, err: :sampled}
Link to this function

success_response(event, duration, status_code)

View Source

Specs

success_response(Honeylixir.Event.t(), float(), integer()) :: t()

Creates a Honeylixir.Response for an event was successfully sent.

Examples

iex> event = Honeylixir.Event.create()
iex> event = %{event | metadata: %{id: 1}}
iex> Honeylixir.Response.success_response(event, 10.2232, 202)
%Honeylixir.Response{metadata: %{id: 1}, duration: 10.2232, status_code: 202, body: "", err: nil}