mete v1.0.3 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.3"} to your list of dependencies in mix.exs:

def deps do
  [
    # ...
    {:mete, "~> 1.0.3"}
  ]
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.

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

Link to this section Types

Link to this type

fields()

View Source
fields() :: Mete.Protocol.field_set()
Link to this type

measurement()

View Source
measurement() :: Mete.Protocol.measurement()
Link to this type

tags()

View Source
tags() :: Mete.Protocol.tag_set()
Link to this type

timestamp()

View Source
timestamp() :: Mete.Protocol.timestamp()
Link to this type

value()

View Source
value() :: Mete.Protocol.value()

Link to this section Functions

Link to this function

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

View Source
measure(measurement(), tags(), [Mete.Protocol.field()], (() -> 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 measurement.

write("query", [exec: 20, queue: 33])
Link to this function

write_meter(measurement, tags \\ [])

View Source

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