Graphite.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 25 / 25 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Graphite/JSONCodec.pm ↑ Summary
1 package Net::Async::Graphite;
2  
3 3 our $VERSION = '0.1_1';
4  
5 =head1 NAME
6  
7 Net::Async::Graphite - Request data from graphite
8  
9 =head1 SYNOPSIS
10  
11 use Net::Async::Graphite;
12  
13 my $graphite = Net::Async::Graphite->new(
14 endpoint => 'https://graphite.example.com/',
15 );
16  
17 # Find (requires graphite-api)
18 my $metrics = $graphite->metrics_asperl('foo.*.datum')->get;
19  
20 # Download
21 my $data = $graphite->render_asperl('foo.*.datum')->get;
22  
23 # Draw
24 my $png = $graphite->render(png => 'foo.*.datum')->get;
25 # or my $png = $graphite->png('foo.*.datum')->get;
26  
27 # Draw with gnuplot (requires gnuplot)
28 my $ascii = $graphite->plot('foo.*.datum')->get;
29 print $ascii;
30  
31 =head1 DESCRIPTION
32  
33 An interface to Graphite's data-request APIs graphite-web and
34 graphite-api (which include's graphite-web's /render API).
35  
36 Preliminary support exists in this version for most of the
37 functionality of C</render>, C</metrics/expand>, C</metrics/find> and
38 C</metrics/index.json> which is described in detail in
39 L<Net::Async::Graphite::API>.
40  
41 There is also support to pass the raw data obtained from C</render>
42 into gnuplot, which includes the ability to format it for terminal
43 output. This support will probably be made optional at some point or
44 maybe split into its own package.
45  
46 =head1 BUGS
47  
48 No attempt is made to configure a timeout for the HTTP request.
49  
50 See individual components for their bugs that I know about.
51  
52 =cut
53  
54 3 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 3 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 =head1 OBJECT
62  
63 Net::Async::Graphite is an object built from individual roles using
64 L<Moo>. It uses L<IO::Async> internally to provide an asynchronous
65 interface to the remote API and so all methods return a L<Future>
66 object.
67  
68 If you don't know about L<Future> or don't want to, you must only
69 remember to call C<get> on the return value of any
70 L<Net::Async::Graphite> method:
71  
72 my $data_when_it_comes = $graphite->render('me.tr.ic');
73 ...; # Later
74 my $data_finally = $data_when_it_comes->get();
75  
76 # or
77  
78 my $data_now = $graphite->render('me.tr.ic')->get();
79  
80 L<Net::Async::Graphite>'s API consists of all of the methods,
81 attributes and accessors defined in its roles (and theirs (and theirs
82 (etc.))) which do not begin with an C<_>. Being perl you are welcome
83 to use these private methods, and even dig around inside the object's
84 guts if you wish, but they do not constitute any part of the stable[*]
85 API. You are thus also welcome to deal with the ensuing breakage.
86  
87 [*] Hahaha.
88  
89 L<Net::Async::Graphite>'s functionality comes from these roles:
90  
91 =over
92  
93 =item L<Net::Async::Graphite::API>
94  
95 Interface between perl and Graphite's APIs (C</metrics> and
96 C</render>). Of most interest are:
97  
98 =begin comment
99  
100 usename and password don't both need a description but then it looks silly.
101  
102 =end comment
103  
104 =over
105  
106 =item username
107  
108 Mixed in by L<Net::Async::Graphite::HTTPClient>.
109  
110 =item password
111  
112 Mixed in by L<Net::Async::Graphite::HTTPClient>.
113  
114 =item endpoint
115  
116 =item metrics()
117  
118 =item render()
119  
120 =item find_target_from_spec()
121  
122 =back
123  
124 =item L<Net::Async::Graphite::Draw>
125  
126 Render data in various ways after it has been downloaded. Note that
127 Graphite's C</render> API include its own drawing routines which are
128 not related to or affected by this role. This role uses data obtained
129 from C</render> API call with C<format=raw>; the relationship ends
130 there.
131  
132 Of most interest are:
133  
134 =over
135  
136 =item last_value()
137  
138 =item plot()
139  
140 =back
141  
142 =cut
143  
144 3 with 'Net::Async::Graphite::API';
145  
146 3 with 'Net::Async::Graphite::Draw';
147  
148 =back
149  
150 =head1 ATTRIBUTES
151  
152 I don't know if I want these.
153  
154 =over
155  
156 =item default_from
157  
158 =item default_until
159  
160 Default values for C<from=> and C<until=> URI parameters.
161  
162 =cut
163  
164 3 has default_from => is => rw => predicate => 1;
165  
166 3 has default_until => is => rw => predicate => 1;
167  
168 3 1;
169  
170 =back
171  
172 =head1 SEE ALSO
173  
174 L<Net::Async::Graphite::API>
175  
176 L<Net::Async::Graphite::Draw>
177  
178 L<Future>
179  
180 L<Moo>
181  
182 L<Net::Async::HTTP>
183  
184 =head1 AUTHOR
185  
186 Matthew King <matthew.king@cloudbeds.com>
187  
188 =cut
« Graphite/JSONCodec.pm ↑ Summary