File: README.md

package info (click to toggle)
erlang-metrics 2.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 892 kB
  • sloc: erlang: 375; makefile: 2
file content (93 lines) | stat: -rw-r--r-- 2,724 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93


# metrics: A generic interface to different metrics systems in Erlang. #

Copyright (c) 2017-2018 BenoƮt Chesneau.

__Version:__ 2.5.0

# metrics

A generic interface to folsom, exometer, grapherl or any compliant interface. This
application has been extracted from
[hackney](https://github.com/benoitc/hackney).

Currently supported backend are:

- [Folsom](https://github.com/folsom-project/folsom): `metrics_folsom`
- [Exometer](https://github.com/Feuerlabs/exometer): `metrics_exometer`

> If you need the support for another backend, please [open a ticket](https://github.com/benoitc/erlang-metrics/issues).

[![Hex pm](http://img.shields.io/hexpm/v/metrics.svg?style=flat)](https://hex.pm/packages/metrics)

## Usage

### Set a backend

The backend can be set in the application environment using the `metrics_mod` setting or using `metrics:backend/1`.

### register a new metric:

```
metrics:new(counter, "c").
```

Depending on the backend the following metrics types can be passed: counter | histogram | gauge | meter | spiral

### update a metric

A counter can simply be incremented by 1 using `metrics:update/1`. or by passing a positive or negative integer like this:

```
metrics:update("c", {c, 1}).
```

Other metrics are updated via `metrics:update/2`.

## Example:

```erlang

1> application:ensure_all_started(metrics).
{ok,[metrics]}
2> application:ensure_all_started(folsom).
{ok,[bear,folsom]}
3> metrics:backend(metrics_folsom).
ok
4> metrics:new(counter, "c").
ok
5> metrics:update("c").
ok
6> folsom_metrics:get_metric_value("c").
1
7> metrics:update("c", {c, 1}).
ok
8> folsom_metrics:get_metric_value("c").
2

```

## Documentation

Full doc is available in the [`metrics`](http://github.com/benoitc/erlang-metrics/blob/master/doc/metrics.md) module.

## Build

```
$ rebar3 compile
```



## Modules ##


<table width="100%" border="0" summary="list of modules">
<tr><td><a href="http://github.com/benoitc/erlang-metrics/blob/master/doc/metrics.md" class="module">metrics</a></td></tr>
<tr><td><a href="http://github.com/benoitc/erlang-metrics/blob/master/doc/metrics_exometer.md" class="module">metrics_exometer</a></td></tr>
<tr><td><a href="http://github.com/benoitc/erlang-metrics/blob/master/doc/metrics_folsom.md" class="module">metrics_folsom</a></td></tr>
<tr><td><a href="http://github.com/benoitc/erlang-metrics/blob/master/doc/metrics_noop.md" class="module">metrics_noop</a></td></tr>
<tr><td><a href="http://github.com/benoitc/erlang-metrics/blob/master/doc/metrics_process_tracker.md" class="module">metrics_process_tracker</a></td></tr>
<tr><td><a href="http://github.com/benoitc/erlang-metrics/blob/master/doc/metrics_sup.md" class="module">metrics_sup</a></td></tr></table>