NAME

OpenTracing::Role::Tracer - Role for OpenTracin implementations.

SYNOPSIS

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;

DESCRIPTION

This Moo::Role provides the consuming class with most, if not all, of the methods being described in OpenTracing::Interface::Tracer.

IMPLEMENTED OPENTRACING METHODS

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.

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.

See "start_active_span" in OpenTracing::Interface::Tracer.

start_span

Starts, but does not activate a Span

See "start_span" in OpenTracing::Interface::Tracer.

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

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

See ScopeManager.

default_span_context_args

An optional HashRef that defaults to an empty hash reference.

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.

See build_context.

REQUIRED METHODS

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.

The first argument of the method call, is as usual, the Tracer invocant self.

Expected Named Parameters
operation_name

A required <Str> representing the name of this span

child_of

A required span or SpanContext that this decends from

context

The required current SpanContext the new <Span> belongs to at the time of creation.

start_time

An optional PositiveOrZeroNum, the (fractional) number of seconds since epoch

tags

An optional <HashRef> of <Str>.

Returns
MUST return a Span

build_context

An implementation specific build method that allows the implementation to do its own settings and requirements, where needed.

The first argument of the method call, is as usual, the Tracer invocant self.

It will get followed by the (dereferenced) list of default_span_context_args.

Returns
MUST return a Span

extract_context

See extract_context for a description.

inject_context

See extract_context for a description.

SEE ALSO

OpenTracing::Types

Type constraints for checking Interfaces

OpenTracing::Interface::Tracer

A role that defines the Tracer 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.