LogflareEx (logflare_ex v0.2.0-dev.082a725d)
Documentation for LogflareEx
.
Summary
Functions
Creates a client for interacting with Logflare.
Returns a count of all queued events.
Performs a flush for a given client. Attempts to clear the queue of events for the given client.
Sends a batched event.
Sends events in batches. Configuration of the batching is dependent on the provided client.
Send a singular event to Logflare.
Sends events directly to the Logflare API without local caching. All batching configurations on the client will be ignored.
Functions
client(opts)
Creates a client for interacting with Logflare.
See LogflareEx.Client
.
count_queued_events()
@spec count_queued_events() :: non_neg_integer()
Returns a count of all queued events.
flush(client)
@spec flush(LogflareEx.Client.t()) :: :ok
Performs a flush for a given client. Attempts to clear the queue of events for the given client.
send_batched_event(client, event)
Sends a batched event.
send_batched_events(client, events)
@spec send_batched_events(LogflareEx.Client.t(), [map()]) :: :ok
@spec send_batched_events(LogflareEx.Client.t(), [map()]) :: :ok
Sends events in batches. Configuration of the batching is dependent on the provided client.
Batched events are cached locally and flushed at regular intervals.
Example
# create a client
iex> client = LogflareEx.client()
%LogflareEx.Client{...}
# singular event
iex> LogflareEx.send_batched_event(client, %{...})
:ok
# list of events
iex> LogflareEx.send_batched_event(client, [%{...}, ...])
:ok
send_event(client, event)
@spec send_event(LogflareEx.Client.t(), map()) :: {:ok, map()} | {:error, Tesla.Env.t()}
Send a singular event to Logflare.
See send_events/2
No local caching is performed. This is less efficient than batching events.
send_events(client, batch)
@spec send_events(LogflareEx.Client.t(), [map()]) :: {:ok, map()} | {:error, Tesla.Env.t()}
Sends events directly to the Logflare API without local caching. All batching configurations on the client will be ignored.
It is advised to use send_batched_events/2
instead to spread out API requests.
Example
iex> client = LogflareEx.client()
%LogflareEx.Client{...}
# singular event
iex> LogflareEx.send_event(client, %{my: "event"})
{:ok, %{"message"=> "Logged!}}
# multiple events
iex> LogflareEx.send_events(client, [%{my: "event"}, ...])
{:ok, %{"message"=> "Logged!}}
# a tesla result will be returned on error
iex> client |> LogflareEx.send_event(%{my: "event"})
{:error, %Tesla.Env{...}}