Commit | Line | Data |
---|---|---|
9b9299d9 SK |
1 | -module(beam_stats_msg_statsd_gauge). |
2 | ||
3 | -include("include/beam_stats_msg_graphite.hrl"). | |
4 | -include("include/beam_stats_msg_statsd_gauge.hrl"). | |
5 | ||
6 | -export_type( | |
7 | [ t/0 | |
8 | ]). | |
9 | ||
10 | -export( | |
11 | [ of_msg_graphite/1 | |
12 | , to_bin/1 | |
13 | ]). | |
14 | ||
15 | -define(T, #?MODULE). | |
16 | ||
17 | -type t() :: | |
18 | ?T{}. | |
19 | ||
20 | of_msg_graphite( | |
21 | #beam_stats_msg_graphite | |
22 | { path = Path | |
23 | , value = Value | |
24 | , timestamp = _Timestamp | |
25 | } | |
26 | ) -> | |
27 | PathBin = beam_stats_msg_graphite:path_to_bin(Path), | |
28 | cons(PathBin, Value). | |
29 | ||
30 | -spec cons(binary(), non_neg_integer()) -> | |
31 | t(). | |
32 | cons(<<Name/binary>>, Value) -> | |
33 | ?T | |
34 | { name = Name | |
35 | , value = Value | |
36 | }. | |
37 | ||
38 | -spec to_bin(t()) -> | |
39 | binary(). | |
40 | to_bin( | |
41 | ?T | |
42 | { name = <<Name/binary>> | |
43 | , value = Value | |
44 | } | |
45 | ) when Value >= 0 -> | |
46 | ValueBin = integer_to_binary(Value), | |
47 | << Name/binary, ":", ValueBin/binary, "|g\n">>. |