
=head1 NAME

OpenTracing::Role::Scope - Role for OpenTracing implementations.



=head1 SYNOPSIS

    package OpenTracing::Implementation::MyBackendService::Scope;
    
    use Moo;
    
    with 'OpenTracing::Role::Scope'
    
    sub close => { ... }
    
    1;

=cut



=head1 DESCRIPTION

This C<Moo::Role> provides the consuming class with most, if not all, of the
methods being described in L<OpenTracing::Interface::Scope>.



=head1 IMPLEMENTED OPENTRACING METHODS

The following methods from
L<OpenTracing::Interface|OpenTracing::Interface::Scope>
have been implemented. See their documentation for more details.



=head2 C<close>

Mark the end of the active period for the current thread and L<Scope>,
updating the C<ScopeManager::active()> in the process.

See L<OpenTracing::Interface::Scope/"close">.



=head2 C<get_span>

Returns the C<Span> that's been scoped by this C<Scope>

See L<OpenTracing::Interface::Scope/"get_span">.



=head1 WARNING

B<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.



==head1 ATTRIBUTES



=head2 C<span>

A L<Span|OpenTracing::Types/"Span"> type.



=head2 C<finish_span_on_close>

A L<Bool|Types::Standard/"Bool"> type.

See
L<< C<start_active_span>|OpenTracing::Interface::Tracer/"start_active_span" >>.



=head2 C<closed>

A L<Bool|Types::Standard/"Bool"> type, that keeps the state of this scope, so
one can not close a scope more than once, and unintentially would call the code
in the C<on_close> closure.



=head2 C<on_close>

Maybe a L<CodeRef|Types::Standard/"CodeRef"> that will gets executed when
C<close> gets called. Itss only parameter, is the C<Scope> invocant itself.

Before this code reference gets called, its C<span> may recieve a C<finish>
call, depending wether or not C<finish_span_on_close> has been set or not.

Its usefulnes currently is for dealing with scope and a C<ScopeManager>.



=head1 SEE ALSO

=over

=item L<OpenTracing::Types>

Type constraints for checking Interfaces

=item L<OpenTracing::Interface::Scope>

A role that defines the Scope interface

=back



=head1 AUTHOR

Theo van Hoesel <tvanhoesel@perceptyx.com>



=head1 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.

=cut



1;
