<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">## COPYRIGHT NOTICE

'OpenTracing API for Perl' is Copyright (C) 2019, Perceptyx Inc, Theo van Hoesel

# OpenTracing API for Perl

This package describes the OpenTracing API for Perl

## Required Reading

In order to understand the Perl platform API, one must first be familiar with
[the OpenTracing project](http://opentracing.io/)
and
[terminology](http://opentracing.io/documentation/pages/spec)
more generally.

## Usage

### Initialize the Tracer Singleton

```perl
use OpenTracing::Implementation qw/YourTracingService/;
```

### Access the Tracer Singleton

```perl
use OpenTracing::GlobalTracer qw/$TRACER/;
```

### Direct control over Tracing instead of using singletons

```perl
use YourImplementation::Tracer;

my $TRACER = YourImplementation::Tracer-&gt;new( %options );
```

### Add a new span inside a subroutine

```perl
sub some_work {
    my $opentracing_scope =
        $TRACER-&gt;start_active_span( 'some_operation_name' );
    
    ...
    
    $opentracing_scope-&gt;close
    
    return ...
}
```

### Inject a SpanContext into an outgoing request:

```perl
my $opentracing_spancontext = $TRACER-&gt;get_active_span-&gt;get_context;

use HTTP::Headers;
my $http_headers = HTTP::Headers-&gt;new( ... );

my $cntx_headers = $TRACER-&gt;inject_context(
    OPENTRACING_FORMAT_HTTP_HEADERS =&gt; $http_headers,
    $opentracing_spancontext,
);

my $request = HTTP::Request-&gt;new(
    GET =&gt; 'https://...', $cntx_headers
);
my response = LWP::UserAgent-&gt;request( $request );
```

### Extract a SpanContext from an incoming request

```perl
use YourFramework;

get '/some_service' =&gt; sub {
    my $http_headers = YourFramework-&gt;request-&gt;headers;
    
    my $opentracing_context = $TRACER-&gt;extract_context(
        OPENTRACING_FORMAT_HTTP_HEADERS =&gt; $http_headers
    );
    
    ...
    
}
```

## Description

This package - `OpenTracing::Interface` - describes the API definition for
OpenTransport implementations written in the Perl5 language.

This being Perl, and strongly influenced by TIMTOWDI principals, this package
does not intent to be a base class that tracer implementors need to subclass.
Moreover, the specification is written as POD. Write your own implementation
however you want as long as it adheres to the written POD specification.

A set of L&lt;Role::Tiny&gt; roles are provided, that can be consumed into your own
implementations that will ensure that required methods are present. Those roles
also do type checking ( using `Type::Tiny` and friends )on input params and
returned values. Other than that, those roles do nothing and can be ignored.


## LICENSE INFORMATION

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.

</pre></body></html>