File Coverage

blib/lib/OpenTracing/Implementation/DataDog/Utils.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 2 2 100.0
total 14 14 100.0


line stmt bran cond sub pod time code
1             package OpenTracing::Implementation::DataDog::Utils;
2              
3             =head1 NAME
4              
5             OpenTracing::Implementation::DataDog::Utils - DataDog Utilities
6              
7             =cut
8              
9             our $VERSION = 'v0.47.0';
10              
11             ;
12              
13 29     29   221 use Exporter qw/import/;
  29         92  
  29         2552  
14              
15             our @EXPORT_OK = qw/nano_seconds random_bigint/;
16              
17             =head1 EXPORTS OK
18              
19             The following subroutines can be imported into your namespance:
20              
21             =cut
22              
23              
24              
25             =head2 nano_seconds
26              
27             To turn floatingpoint times into number of nano seconds
28              
29             =cut
30              
31 28     28 1 664 sub nano_seconds { int( $_[0] * 1_000_000_000 ) }
32              
33              
34              
35             =head2 random_bigint
36              
37             Returns a random 63 bits L<Math::BigInt>. Some architectures do not support
38             native 64 bit integers, but that is what DataDog expects.
39              
40             NOTE: special care needs to be taken when rendering to JSON, as the GO language
41             is not forgiving for double qouted values when using big numbers.
42             Use C<<JSON->allow_bignum>>.
43              
44             =cut
45              
46 29     29   15327 use Math::BigInt::Random::OO;
  29         1561217  
  29         2744  
47             #
48             # $random
49             #
50             # our internal BigInt::Random generator, we only instantiate once
51             #
52             my $RANDOM = Math::BigInt::Random::OO->new( length_bin => 63 );
53              
54 110     110 1 509 sub random_bigint { $RANDOM->generate() }
55              
56              
57              
58             =head1 SEE ALSO
59              
60             =over
61              
62             =item L<OpenTracing::Implementation::DataDog>
63              
64             Sending traces to DataDog using Agent.
65              
66             =back
67              
68              
69              
70             =head1 AUTHOR
71              
72             Theo van Hoesel <tvanhoesel@perceptyx.com>
73              
74              
75              
76             =head1 COPYRIGHT AND LICENSE
77              
78             'OpenTracing::Implementation::DataDog'
79             is Copyright (C) 2019 .. 2021, Perceptyx Inc
80              
81             This library is free software; you can redistribute it and/or modify it under
82             the terms of the Artistic License 2.0.
83              
84             This package is distributed in the hope that it will be useful, but it is
85             provided "as is" and without any express or implied warranties.
86              
87             For details, see the full text of the license in the file LICENSE.
88              
89              
90             =cut
91              
92             1;