Skip to content

Commit

Permalink
fix influxdb from being given scientific notation
Browse files Browse the repository at this point in the history
InfluxDB cannot handle scientific notation, so we have to use bigint to
ensure that it doesn't get it...
  • Loading branch information
preaction committed Nov 18, 2017
1 parent a7b27de commit f2ed409
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Changelog for ETL-Yertl

{{ $NEXT }}

[Fixed]

- Fixed a problem with timestamps on InfluxDB being expressed in
scientific notation.

0.037 2017-10-27 17:27:41-05:00 America/Chicago

[Fixed]
Expand Down
1 change: 1 addition & 0 deletions lib/ETL/Yertl/Adapter/influxdb.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use List::Util qw( first );
use IO::Async::Loop;
use Time::Piece ();
use Scalar::Util qw( looks_like_number );
use bigint;

=method new
Expand Down
16 changes: 10 additions & 6 deletions t/adapter/influxdb.t
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,22 @@ subtest 'write ts' => sub {
);

my $time = time;
no warnings 'once';
local *CORE::GLOBAL::time = sub { $time };
$db->write_ts( @points );

ok $mock->called, 'mock POST called';
my $args = $mock->method_arguments;
is $args->[0], 'http://localhost:8086/write?db=mydb', 'POST URL correct';
my @lines = (
"cpu_load 5m=1.23 1483228800000000000",
"cpu_load 5m=1.25 1483229100000000000",
"cpu_load 1m=1.26 " . ( $time * 10**9 ),
);
is $args->[1], join( "\n", @lines ), 'influxdb line protocol points correct';
{
use bigint;
my @lines = (
"cpu_load 5m=1.23 1483228800000000000",
"cpu_load 5m=1.25 1483229100000000000",
"cpu_load 1m=1.26 " . ( $time * 10**9 ),
);
is $args->[1], join( "\n", @lines ), 'influxdb line protocol points correct';
}
cmp_deeply { @{ $args }[ 2..$#$args ] },
{ content_type => 'text/plain' },
'additional options are correct';
Expand Down

0 comments on commit f2ed409

Please sign in to comment.