OpenTracing::Role::Tracer - Role for OpenTracin implementations.
package OpenTracing::Implementation::MyBackendService::Tracer; use Moo; sub build_span { my $self = shift; my %opts = @_; Span->new( %opts, on_finish => sub { my $span = shift; $self->do_something_with_span( $span ) }, ) } sub build_context { ... } my $self = shift; my %opts = @_; SpanContext->new( %opts ) } sub extract_context { ... } sub inject_context { ... } ... with 'OpenTracing::Role::Tracer'; 1;
This Moo::Role provides the consuming class with most, if not all, of the methods being described in OpenTracing::Interface::Tracer.
Moo::Role
The following methods from OpenTracing::Interface have been implemented. See their documentation for more details.
get_scope_manager
Returns the current ScopeManager, which may be a NoOp but may not be undef.
ScopeManager
undef
See "get_scope_manager" in OpenTracing::Interface::Tracer.
get_active_span
This will return the 'active' span.
See "get_active_span" in OpenTracing::Interface::Tracer.
start_active_span
Starts AND activates a Span and returns its Scope.
Span
Scope
See "start_active_span" in OpenTracing::Interface::Tracer.
start_span
Starts, but does not activate a Span
See "start_span" in OpenTracing::Interface::Tracer.
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.
The attributes below become part of the consuming class, but because of its in-mutable design, those can not be set after instantiation, one will need to use the provided methods to clone with the data.
scope_manager
A required read-only ScopeManager that can get_active_scope and activate_span
get_active_scope
activate_span
See ScopeManager.
default_span_context_args
An optional HashRef that defaults to an empty hash reference.
HashRef
These key/value pairs are being used to build a new SpanContext object (using build_context for a rootspan if no active <SpanContext> is provided or available during start_span. These key/value pairs are typically implementation dependent.
SpanContext
build_context
See build_context.
The following method(s) are required to be implemented by a consuming class.
build_span
An implementation specific build method that allows the implementation to do its own settings and requirements, where needed. One typical responsabillity of the builder is to set the on_finish.
on_finish
The first argument of the method call, is as usual, the Tracer invocant self.
Tracer
operation_name
A required <Str> representing the name of this span
context
The required current SpanContext the new <Span> belongs to at the time of creation.
child_of
An optional span or SpanContext that this decends from
span
start_time
An optional PositiveOrZeroNum, the (fractional) number of seconds since epoch
PositiveOrZeroNum
tags
An optional <HashRef> of <Str>.
An implementation specific build method that allows the implementation to do its own settings and requirements, where needed.
It will get followed by the (dereferenced) list of default_span_context_args.
extract_context
See extract_context for a description.
inject_context
Type constraints for checking Interfaces
A role that defines the Tracer interface
Theo van Hoesel <tvanhoesel@perceptyx.com>
'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.
To install OpenTracing::Role, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenTracing::Role
CPAN shell
perl -MCPAN -e shell install OpenTracing::Role
For more information on module installation, please visit the detailed CPAN module installation guide.