mete v1.0.5 Mete View Source

[/miːt/] - Old English metan 'measure'

Basic measuring tool and telemetry writer using InfluxDB.

Usage

Add Mete to your application by adding {:mete, "~> 1.0.5"} to your list of dependencies in mix.exs:

def deps do
  [
    # ...
    {:mete, "~> 1.0.5"}
  ]
end

Options

  • :host - hostname of the server running the InfluxDB endpoint, defaults to localhost
  • :port - port on which the InfluxDB server runs the respective input, defaults to 8089
  • :protocol - either :udp, or :http. Defaults to :udp.
  • :database - has to be configured when using :http
  • :tags - can be used to configure application-wide tags expects a Keywordlist of strings or atoms, defaults to []
  • :batch - InfluxDB supports batching measurements, can be deactivated with false activated with true or directly configure the byte-size of the payloads with an integer

ToDo

  • Configurable handling of integer/float values.
  • Configurable handling of timestamps
  • Support for mfa's for measure.
  • base default batch size on connection parameters

Link to this section Summary

Functions

Evaluates the given function, measures, and subsequently writes the elapsed real time.

Adds a meter point under the given atom to the process.

Reads the current process tags.

Alters the current process tags according the given keyword list.

Writes a single measurement. A measurement consists of a measurement, tags and fields.

Calculates the delta for the process meter points and writes them under the measurement.

Link to this section Types

Link to this section Functions

Link to this function

measure(measurement, tags \\ [], fields \\ [], func)

View Source
measure(measurement(), tags(), fields() | [], (() -> any())) :: any()

Evaluates the given function, measures, and subsequently writes the elapsed real time.

iex> measure("query", fn -> "some query result" end)
"some query result"

Adds a meter point under the given atom to the process.

Reads the current process tags.

Link to this function

tags(keyword)

View Source
tags(tags()) :: :ok

Alters the current process tags according the given keyword list.

The given keyword list will be merged into the existing tags, tags set to nil will remove that tag from the tag list.

Link to this function

write(measurement, tags \\ [], fields)

View Source
write(measurement(), tags(), fields() | value()) :: :ok

Writes a single measurement. A measurement consists of a measurement, tags and fields.

Requires a name of the measurement either as a string or atom. Atoms are always converted to strings. Tags can be given either as a keyword list of strings or atoms, or tuple lists with string keys.

Fields can be either atoms, strings, boolean, integer, or floats. If measurements are not known to influx the according table will be created or altered. If a field should change its value from integer or float (or any other type) for some reason this will lead to datalos since the new fields wont match the present table.

Examples:

iex> write("temp", [region: "EU", foo: "bar"], c: 42.0, f: 107.6)
:ok

If the value is without a name it defaults to :value thus ...

iex> write("temp", 42)
:ok

is equivalent to ...

iex> write("temp", value: 42)
:ok
Link to this function

write_meter(measurement, tags \\ [])

View Source

Calculates the delta for the process meter points and writes them under the measurement.