NAME
OpenTracing::Interface::ScopeManager - A role that defines the ScopeManager
SYNOPSIS
package OpenTracing::Implementation::MyBackendService::ScopeManager;
sub activate_span {
...
}
sub get_active_scope {
...
}
BEGIN {
use Role::Tiny::With;
with 'OpenTracing::Interface::ScopeManager'
if $ENV{OPENTRACING_INTERFACE};
} # check at compile time, perl -c will work
1;
DESCRIPTION
This 'role' describes the interface for any OpenTracing ScopeManager implementation.
The ScopeManager interface abstracts both the activation of Span instances via activate_Span and access to an active Scope via get_active_scope.
INSTANCE METHODS
activate_span( $span, %options )
Set the specified Span as the active instance for the current context (usually a thread).
my $span = $tracer->start_span( 'some operation'
ignore_active_span => 1
);
my $manager = $tracer->get_scope_manager;
my $scope = $manager->activate_span( $span,
finish_span_on_close => 0
);
The returned Scope represents the active state for the span. Once its active period is due, $scope->close() ought to be called. Observe the span will be automatically finished when $scope->close() is called.
Required Positional Parameters
- Span
-
An object that does the
Spaninterface.
Named Options
- finish_span_on_close
-
A
Boolwhen set to false, theSpanwill not be automatically finished when theScopehas been closed. This is 'true' by default.
Returns
An object that implements the Scope interface.
get_active_scope
Return the currently active Scope which can be used to access the currently active Span, using $scope->get_span.
my $manager = $tracer->get_scope_manager;
my $scope = $manager->get_activate_scope;
Parameters
none
Returns
The Scope that is currently active.
SEE ALSO
- OpenTracing::Interface
-
Describes the API definition for OpenTransport implementations written in the Perl5 language.
- OpenTracing::Types
-
A library of Type::Tiny type constraints that provides Duck Type checks for all common elements that conform OpenTracing::Interface
CAVEATS
This description is using around method modifiers that basically wraps them around the real implementation. These method modifiers provide a 'readable' and reusable interface, describing the inputs and outputs, using type constraints.
Consumers of this role, or implementors of the interface are MUST implement each method mentioned below. Not doing so will result in compilation errors.
Since this role does nothing else than checking input and output, it is useful during development. Most likely it can be switched off safely in production environments.