NAME
OpenTracing::Role::ScopeManager - Role for OpenTracing implementations.
SYNOPSIS
package OpenTracing::Implementation::MyBackendService::ScopeManager;
use Moo;
with 'OpenTracing::Role::ScopeManager'
sub build_scope{
my $self = shift;
my $options = { @_ };
my $current_scope = $self->get_active_scope;
my $scope = OpenTracing::Implementation::DataDog::Scope->new(
span => $options->{ span },
finish_span_on_close => $options->{ finish_span_on_close },
on_close => sub {
$self->set_active_scope( $current_scope );
}
);
return $scope
}
1;
DESCRIPTION
This Moo::Role
provides the consuming class with most, if not all, of the methods being described in OpenTracing::Interface::ScopeManager.
IMPLEMENTED OPENTRACING METHODS
The following methods from OpenTracing::Interface have been implemented. See their documentation for more details.
activate_span
Set the specified Span as the active instance for the current context (usually a thread).
See "activate_span" in OpenTracing::Interface::ScopeManager.
get_active_scope
Return the currently active Scope
which can be used to access the currently active Span
, using $scope->get_span
.
See "get_active_scope" in OpenTracing::Interface::ScopeManager.
WARNING
Never use any of attributes or methods below in any integration!
Only methods mentioned in the Public OpenTracing::Interface are safe to be used in any integration or when instrumenting applications.
ATTRIBUTES
active_scope
A Span type.
REQUIRED METHODS
The following method(s) are required to be implemented by a consuming class.
build_scope
This method should return a Scope
- Expected Named Parameters
-
span
-
A OpenTracing compliant
Span
object. finish_span_on_close
-
A
Bool
type.
Note
Unlike the OpenTracing API interface specification, build_scope
does not let it up for discusion, span
and finish_span_on_close
are expected named parameters.
SEE ALSO
- OpenTracing::Types
-
Type constraints for checking Interfaces
- OpenTracing::Interface::ScopeManager
-
A role that defines the ScopeManager interface
AUTHOR
Theo van Hoesel <tvanhoesel@perceptyx.com>
COPYRIGHT AND LICENSE
'OpenTracing API for Perl' is Copyright (C) 2019 .. 2020, Perceptyx Inc
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This library 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.