Use iolists, where appropriate
[beam_stats.git] / src / beam_stats_msg_statsd_gauge.erl
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_iolist/1
13 ]).
14
15 -define(T, #?MODULE).
16
17 -type t() ::
18 ?T{}.
19
20 -spec of_msg_graphite(beam_stats_msg_graphite:t()) ->
21 t().
22 of_msg_graphite(
23 #beam_stats_msg_graphite
24 { path = Path
25 , value = Value
26 , timestamp = _Timestamp
27 }
28 ) ->
29 PathIOList = beam_stats_msg_graphite:path_to_iolist(Path),
30 cons(PathIOList, Value).
31
32 -spec cons(iolist(), non_neg_integer()) ->
33 t().
34 cons(Name, Value) ->
35 ?T
36 { name = Name
37 , value = Value
38 }.
39
40 -spec to_iolist(t()) ->
41 iolist().
42 to_iolist(
43 ?T
44 { name = Name
45 , value = Value
46 }
47 ) when Value >= 0 ->
48 ValueBin = integer_to_binary(Value),
49 [Name, <<":">>, ValueBin, <<"|g\n">>].
This page took 0.04836 seconds and 4 git commands to generate.