OpenTracing::GlobalTracer - Easy Access to the Tracer Singleton
use OpenTracing::GlobalTracer qw/$TRACER/; my $foo_tracer = OpenTracing::Implementation::Foo::Tracer->new( ); OpenTracing::GlobalTracer->set_global_trace( $foo_tracer );
and in the various part of the code:
my $global_tracer = OpenTracing::GlobalTracer->get_global_tracer( ); my $span = $global_tracer->get_active_span; my $scope = $TRACER->start_active_span( $operation_name );
This module give easy access to the OpenTracing singleton.
During import, when `use`ing the module, it can take the name of a variable to use in the current scope.
The modules provide two methods, `set_global_tracer` and `get_global_tracer`.
If none is set (or cleared), per definition, it will give back a 'NoOp' implementation.
OpenTracing::GlobalTracer->set_global_trace( $tracer );
Sets the global tracer singleton.
my $global_tracer = OpenTracing::GlobalTracer->get_global_tracer( );
Returns a global tracer if some is set. If none is set, it will return the OpenTracing::Implementation::NoOp implementation, compliant to the definition to prevent crashing.
This variable can be set to override the default NoOp implementation.
When using the $TRACER variable, one still needs to be careful, it could be undef if no tracer wasn't initialised, or explicitly been erased. This may result in errors like "can't use method ... on undef".
$TRACER
undef
Theo van Hoesel <tvanhoesel@perceptyx.com>
'OpenTracing GlobalTracer' is Copyright (C) 2019, Perceptyx Inc
This package is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This package is distributed in the hope that it will be useful, but it is provided "as is" and without any express or implied warranties.
For details, see the full text of the license in the file LICENSE.
To install OpenTracing::GlobalTracer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenTracing::GlobalTracer
CPAN shell
perl -MCPAN -e shell install OpenTracing::GlobalTracer
For more information on module installation, please visit the detailed CPAN module installation guide.