| 1 | package OpenTracing::Implementation::DataDog::Utils; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | OpenTracing::Implementation::DataDog::Utils - DataDog Utilities | ||
| 6 | |||
| 7 | =cut | ||
| 8 | |||
| 9 | 29 | our $VERSION = 'v0.47.2'; | |
| 10 | |||
| 11 | ; | ||
| 12 | |||
| 13 | 29 | ▶ | use Exporter qw/import/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | 29 | 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 | ▶ | sub nano_seconds { int( $_[0] * 1_000_000_000 ) } |
|
Subroutine
nano_seconds: called CC=1 SCAR=0.0
Pod
documented
| |||
| 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 | ▶ | use Math::BigInt::Random::OO; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 47 | # | ||
| 48 | # $random | ||
| 49 | # | ||
| 50 | # our internal BigInt::Random generator, we only instantiate once | ||
| 51 | # | ||
| 52 | 29 | my $RANDOM = Math::BigInt::Random::OO->new( length_bin => 63 ); | |
| 53 | |||
| 54 | 110 | ▶ | sub random_bigint { $RANDOM->generate() } |
|
Subroutine
random_bigint: called CC=1 SCAR=0.0
Pod
documented
| |||
| 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 | 29 | 1; | |