~mna/tulip

The tulip.pkg.metrics module exports the metrics package.

#Configuration

  • allowed_metrics: array of string = if set, only those metrics will be allowed.
  • host: string = the address of the statsd-compatible UDP server to send metrics to.
  • port: number = the port of the statsd-compatible UDP server to send metrics to.
  • write_timeout: number = write timeout of metrics in seconds.
  • format: string = the metric encoding format (mostly impacts tags), defaults to 'librato', can also be 'datadog'.
  • [w]middleware.counter.name, [w]middleware.timer.name: string = the name of the counter/timer metrics to record in the [w]middleware.
  • [w]middleware.counter.sample, [w]middleware.timer.sample: number = the sample rate of the counter/timer metric.

If there is no [w]middleware.counter or [w]middleware.timer config, then that metric is not recorded, and if there is no [w]middleware table, then the [w]middleware is not registered.

#API Extensions

Registering this package provides the following method and field extensions.

#ok, err = App:metrics(name, type[, value[, t]])

Reports a metric to the configured UDP server, in the statsd protocol.

Args:

  • name: string = name of the metric
  • type: string = 'counter', 'gauge', 'timer' or 'set'.
  • value: number|nil = the value to register, defaults to 1.
  • t: table|nil = a dictionary of key-value strings to register as dimensions (labels, tags) associated with the sample. If the table has an ['@'] field, its value is the sampling rate of the metric. Tags are added in the Librato style, see https://github.com/prometheus/statsd_exporter#tagging-extensions

Returns:

  • ok: boolean = true on success
  • err: Error|nil = error message if ok is falsy

#Registered Middleware

The following middleware are registered and can be referenced by name in the configuration.

#tulip.pkg.metrics

Records web metrics based on the configuration. If a counter is configured, records the request count. If a timer is configured, records the request duration. The path, method and status code are recorded as labels.

#Registered Wmiddleware

The following wmiddleware (worker middleware) are registered and can be referenced by name in the configuration.

#tulip.pkg.metrics

Records worker metrics based on the configuration. If a counter is configured, records the messages count. If a timer is configured, records the message processing duration. The queue name is recorded as label.

Back to index

About this wiki

commit 3ebfbd288b8e5c95fdf8ce2027a0e94cfa1c8976
Author: Martin Angers <martin.n.angers@gmail.com>
Date:   2021-02-25T14:07:12-05:00

Update to reflect Request:validate_body
Clone this wiki
https://git.sr.ht/~mna/tulip-wiki (read-only)
git@git.sr.ht:~mna/tulip-wiki (read/write)