[Bps-public-commit] app-aws-cloudwatch-monitor branch version-0.02 updated. 7a9caad09e42438ce6d91ed3a4d9890fde1e23f2
BPS Git Server
git at git.bestpractical.com
Tue May 17 22:43:46 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "app-aws-cloudwatch-monitor".
The branch, version-0.02 has been updated
via 7a9caad09e42438ce6d91ed3a4d9890fde1e23f2 (commit)
via 6040caaf0cf461fb75e45c0681679ea357bcb9de (commit)
via bc0e02319609f61f927760023013c5c83acf0bd5 (commit)
from 0cbc65c24a27cd26f8fdc1c35196b014d78f391d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 7a9caad09e42438ce6d91ed3a4d9890fde1e23f2
Merge: 0cbc65c 6040caa
Author: Blaine Motsinger <blaine at bestpractical.com>
Date: Tue May 17 17:43:28 2022 -0500
Merge branch '0.02/optimize-datetime' into version-0.02
commit 6040caaf0cf461fb75e45c0681679ea357bcb9de
Author: Blaine Motsinger <blaine at bestpractical.com>
Date: Fri May 13 16:08:50 2022 -0500
Replace DateTime with Time::Piece in deps
diff --git a/Makefile.PL b/Makefile.PL
index 501179e..abd072b 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -36,7 +36,6 @@ WriteMakefile(
'Config::Tiny' => 0,
'Compress::Zlib' => 0,
'constant' => 0,
- 'DateTime' => 0,
'Digest::SHA' => 0,
'Exporter' => 0,
'File::Basename' => 0,
@@ -50,6 +49,7 @@ WriteMakefile(
'parent' => 0,
'Pod::Usage' => '1.67', # rewrite in 1.62, bugfixes in 1.67
'strict' => 0,
+ 'Time::Piece' => 0,
'Try::Tiny' => 0,
'URI::Escape' => 0,
'warnings' => 0,
commit bc0e02319609f61f927760023013c5c83acf0bd5
Author: Blaine Motsinger <blaine at bestpractical.com>
Date: Fri May 13 13:37:12 2022 -0500
Optimize datetime
DateTime is expensive to use, both in execution time and memory.
Since aws-cloudwatch-monitor only needs the localtime epoch,
switching DateTime with Time::Piece is much more efficient.
diff --git a/lib/App/AWS/CloudWatch/Monitor.pm b/lib/App/AWS/CloudWatch/Monitor.pm
index 60eb77c..e786e0d 100644
--- a/lib/App/AWS/CloudWatch/Monitor.pm
+++ b/lib/App/AWS/CloudWatch/Monitor.pm
@@ -93,7 +93,7 @@ sub run {
foreach my $metric ( @{$metrics} ) {
push( @{ $metric->{Dimensions} }, { 'Name' => 'InstanceId', 'Value' => $instance_id } );
- $metric->{Timestamp} = App::AWS::CloudWatch::Monitor::CloudWatchClient::get_offset_time(NOW);
+ $metric->{Timestamp} = App::AWS::CloudWatch::Monitor::CloudWatchClient::get_timestamp();
push( @{ $param->{Input}{MetricData} }, $metric );
}
diff --git a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
index 85eb584..918bcc5 100644
--- a/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
+++ b/lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm
@@ -36,7 +36,7 @@ use base 'Exporter';
our @EXPORT = qw();
use File::Basename;
use App::AWS::CloudWatch::Monitor::AwsSignatureV4;
-use DateTime;
+use Time::Piece;
use Digest::SHA qw(hmac_sha256_base64);
use URI::Escape qw(uri_escape_utf8);
use Compress::Zlib;
@@ -554,17 +554,16 @@ sub prepare_credentials {
return { "code" => OK };
}
-=item get_offset_time
+=item get_timestamp
-Retrieves the current UTC time minus the offset (in hours).
+Retrieves the local timestamp.
=cut
-sub get_offset_time {
- my $offset = shift;
- my $dt = DateTime->now();
- $dt->subtract( hours => $offset );
- return $dt->epoch;
+sub get_timestamp {
+ my $t = localtime;
+ my $timestamp = $t->epoch;
+ return $timestamp;
}
=item print_out
-----------------------------------------------------------------------
Summary of changes:
Makefile.PL | 2 +-
lib/App/AWS/CloudWatch/Monitor.pm | 2 +-
lib/App/AWS/CloudWatch/Monitor/CloudWatchClient.pm | 15 +++++++--------
3 files changed, 9 insertions(+), 10 deletions(-)
hooks/post-receive
--
app-aws-cloudwatch-monitor
More information about the Bps-public-commit
mailing list