line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
13
|
|
|
13
|
|
66
|
use strict; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
463
|
|
2
|
13
|
|
|
13
|
|
61
|
use warnings; |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
744
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Monitor::MetricsAPI::Metric::Timestamp; |
5
|
|
|
|
|
|
|
$Monitor::MetricsAPI::Metric::Timestamp::VERSION = '0.900'; |
6
|
13
|
|
|
13
|
|
66
|
use namespace::autoclean; |
|
13
|
|
|
|
|
20
|
|
|
13
|
|
|
|
|
99
|
|
7
|
13
|
|
|
13
|
|
834
|
use Moose; |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
72
|
|
8
|
13
|
|
|
13
|
|
89154
|
use DateTime; |
|
13
|
|
|
|
|
5557005
|
|
|
13
|
|
|
|
|
3317
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Monitor::MetricsAPI::Metric'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Monitor::MetricsAPI::Metric::Timestamp - Timestamp metric class for Monitor::MetricsAPI |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use Monitor::MetricsAPI; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $collector = Monitor::MetricsAPI->new( |
21
|
|
|
|
|
|
|
metrics => { auditing => { admin => { last_lockout => 'timestamp' } } } |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Later on, when a client is locked out of your admin functions because |
25
|
|
|
|
|
|
|
# of repeated authentication failures: |
26
|
|
|
|
|
|
|
$collector->metric('auditing/admin/last_lockout')->now; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Timestamp metrics allow you to record the time at which an event most recently |
31
|
|
|
|
|
|
|
occurred. The base set() method is disabled (a warning will be emitted if you |
32
|
|
|
|
|
|
|
call it, and no other action will be taken). All timestamp metrics initialize |
33
|
|
|
|
|
|
|
to an empty value, and are always displayed in reporting output as UTC in the |
34
|
|
|
|
|
|
|
ISO-8601 format. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
The following methods are specific to timestamp metrics. L<Monitor::MetricsAPI::Metric> |
41
|
|
|
|
|
|
|
defines methods which are common to all metric types. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 now |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Sets the value of the timestamp metric to the current time. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub now { |
50
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
11
|
$self->_set_dt(DateTime->now( time_zone => 'UTC' )); |
53
|
1
|
|
|
|
|
117
|
return $self->_set_value($self->dt->iso8601 . 'Z'); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 dt |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Returns a DateTime object, suitable for use in date calculations. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has 'dt' => ( |
63
|
|
|
|
|
|
|
is => 'ro', |
64
|
|
|
|
|
|
|
isa => 'DateTime', |
65
|
|
|
|
|
|
|
writer => '_set_dt', |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 set |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Overrides the set() method provided by the base Metric class. Emits a warning |
71
|
|
|
|
|
|
|
whenever called, and performs no other actions. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub set { |
76
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
warn "set method incorrectly called on timestamp metric " . $self->name; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHORS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Jon Sime <jonsime@gmail.com> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This software is copyright (c) 2015 by OmniTI Computer Consulting, Inc. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
90
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. See L<perlartistic>. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
93
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
94
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
99
|
|
|
|
|
|
|
1; |