AppOptex v0.1.0 AppOptex View Source

Client library for sending and reading AppOptics API measurements. To auth AppOptics make sure to set the APPOPTICS_TOKEN environment variable. This can also be overridden in the Application config.

Link to this section Summary

Functions

Asynchronously send the contents of the queue to AppOptics and clear it.

Get the global tags that will be applied to all measurements.

Send one measurement with tags. The measurements are sent to AppOptics asynchronously.

Send one measurement with tags. The measurements are sent to AppOptics asynchronously.

Send multiple measurements with tags. The measurements are sent to AppOptics asynchronously.

Asynchronously add to queue of measurements to be sent to AppOptics later.

Set the global tags that will be applied to all measurements. These can be overriden by tags provided in measurement/3 and measurements/2.

Recieve multiple measurements with tags. The measurements are read from AppOptics synchronously.

Return the current contents of the measurements queue. The queue format is a list of tuples, each tuple contains a measurements list and a tags map.

Link to this section Functions

Asynchronously send the contents of the queue to AppOptics and clear it.

Examples

iex> AppOptex.flush_queue()
:ok

Get the global tags that will be applied to all measurements.

Examples

iex> AppOptex.get_global_tags()
%{my_tag: "value"}
Link to this function

measurement(measurement, tags) View Source

Send one measurement with tags. The measurements are sent to AppOptics asynchronously.

  • measurement - Map of the measurement data
  • tags - A map of tags to send with the measurement. Cannot be empty.

Examples

iex> AppOptex.measurement(%{name: "my.mertic", value: 10}, %{my_tag: "value"})
:ok
Link to this function

measurement(name, value, tags) View Source

Send one measurement with tags. The measurements are sent to AppOptics asynchronously.

  • name - Name of the measurement
  • value - Value of the measurement
  • tags - A map of tags to send with the measurement. Cannot be empty.

Examples

iex> AppOptex.measurement("my.mertic", 10, %{my_tag: "value"})
:ok
Link to this function

measurements(measurements, tags) View Source

Send multiple measurements with tags. The measurements are sent to AppOptics asynchronously.

  • measurements - a batch of metrics to send as a list of maps.
  • tags - A map of tags to send with the measurement. Cannot be empty.

Examples

iex> AppOptex.measurements([%{name: "my.mertic", value: 1}, %{name: "my.other_mertic", value: 5}], %{my_tag: "value"})
:ok
Link to this function

push_to_queue(measurements, tags) View Source

Asynchronously add to queue of measurements to be sent to AppOptics later.

Examples

iex> AppOptex.push_to_queue([%{name: "my.metric", value: 1}], %{test: true})
:ok

Set the global tags that will be applied to all measurements. These can be overriden by tags provided in measurement/3 and measurements/2.

  • tags - maps of tags to set.

Examples

iex> AppOptex.put_global_tags(%{my_tag: "value"})
:ok
Link to this function

read_measurements(metric_name, resolution, params) View Source

Recieve multiple measurements with tags. The measurements are read from AppOptics synchronously.

  • metric name - the name of the metric you want measurements on.
  • resolution - the resolution of the measurements in seconds.
  • params - A map of parameters to restrict the result to possible values include:

    • start_time - Unix Time of where to start the time search from. This parameter is optional if duration is specified.
    • end_time - Unix Time of where to end the search. This parameter is optional and defaults to current wall time.
    • duration - How far back to look in time, measured in seconds. This parameter can be used in combination with endtime to set a starttime N seconds back in time. It is an error to set starttime, endtime and duration.

Examples

iex> AppOptex.client.read_measurements("my.other_mertic", 60, %{duration: 999999})
%{
  "attributes" => %{"created_by_ua" => "hackney/1.15.1"},
  "links" => [],
  "name" => "my.other_mertic",
  "resolution" => 60,
  "series" => [
    %{
      "measurements" => [%{"time" => 1554720060, "value" => 10.0}],
      "tags" => %{"my_tag" => "value"}
    }
  ]
}

Return the current contents of the measurements queue. The queue format is a list of tuples, each tuple contains a measurements list and a tags map.

Examples

iex> AppOptex.read_queue
[{[%{name: "my.metric", value: 1}], %{test: true}}]