OpenTracing-Implementation-DataDog
view release on metacpan or search on metacpan
lib/OpenTracing/Implementation/DataDog/Tracer.pm view on Meta::CPAN
package OpenTracing::Implementation::DataDog::Tracer;
use strict;
use warnings;
our $VERSION = 'v0.47.2';
=head1 NAME
OpenTracing::Implementation::DataDog::Tracer - Keep track of traces
=head1 SYNOPSIS
use aliased 'OpenTracing::Implementation::DataDog::Tracer';
use aliased 'OpenTracing::Implementation::DataDog::Client';
use aliased 'OpenTracing::Implementation::DataDog::ScopeManager';
my $TRACER = Tracer->new(
client => Client->new(),
);
and later
sub foo {
my $scope = $TRACER->start_active_span( 'Operation Name' => %options );
...
$scope->close;
return $foo
}
=cut
use syntax 'maybe';
use Moo;
use MooX::Should;
with 'OpenTracing::Role::Tracer';
use aliased 'OpenTracing::Implementation::DataDog::Client';
use aliased 'OpenTracing::Implementation::DataDog::HTTPPropagator';
use aliased 'OpenTracing::Implementation::DataDog::ScopeManager';
use aliased 'OpenTracing::Implementation::DataDog::Span';
use aliased 'OpenTracing::Implementation::DataDog::SpanContext';
use Hash::Merge;
use Ref::Util qw/is_plain_hashref/;
use Types::Standard qw/Object Str/;
=head1 DESCRIPTION
This is a L<OpenTracing SpanContext|OpenTracing::Interface::SpanContext>
compliant implementation with DataDog specific extentions
=cut
=head1 EXTENDED ATTRIBUTES
=cut
=head2 C<scope_manager>
A L<OpenTracing::Types::ScopeManger> that now defaults to a
L<DataDog::ScopeManger|OpenTracing::Implementation::DataDog::ScopeManager>
=cut
has '+scope_manager' => (
default => sub { ScopeManager->new },
);
=head1 DATADOG SPECIFIC ATTRIBUTES
=cut
=head2 C<client>
A client that has a C<send_span> method that will get called on a `on_finish`.
See L<DataDog::Client|OpenTracing::Implementation::DataDog::Client> for more.
It also accepts a plain hash refference with key-value pairs suitable to
construct a client object.
=cut
has client => (
is => 'lazy',
should => Object,
handles => [qw/send_span/],
coerce
=> sub { is_plain_hashref $_[0] ? Client->new( %{$_[0]} ) : $_[0] },
default => sub { {} }, # XXX this does not return an Object !!!
);
( run in 1.531 second using v1.01-cache-2.11-cpan-39bf76dae61 )