OpenTracing::Implementation::DataDog::SpanContext - A DataDog Implementation
use aliased OpenTracing::Implementation::DataDog::SpanContext; my $span_context = SpanContext->new( service_name => "MyFancyService", service_type => "web", resource_name => "/clients/{client_id}/contactdetails", ); # # please do not add parameter values in the resource, # use tags instead, like: # $span->set_tag( client_id => $request->query_params('client_id') )
This is a OpenTracing SpanContext compliant implementation with DataDog specific extentions
trace_id
DataDog requires this to be a unsigned 64-bit integer
span_id
service_name
A required NonEmptyString where length <= 100.
NonEmptyString
length <= 100
Defaults to the value of the DD_SERVICE_NAME environment variable if set.
DD_SERVICE_NAME
The service-name will usually be the name of the application and could easilly be set by a intergration solution.
service_type
An enumeration on web, db, cache, and custom, which is the default.
web
db
cache
custom
DataDog has four different service types to make it more easy to visualize the data. See Service List at DataDog HQ
resource_name
A required NonEmptyString where length <= 5000.
length <= 5000
Good candidates for resource names are URL paths or databasenames and or tables.
Constructors are not to be used outside an implementation, they are not part of the OpenTracing API.
Only an integration solution should be bothered creating a 'root context'.
my $span_context = SpanContext->new( service_name => "MyFancyService", resource_name => "/clients/{client_id}/contactdetails", baggage_items => { $key => $value, .. }, );
Creates a new SpanContext object;
Besides all methods available from the OpenTracing::Roles::SpanContext, the following are DataDog specific added methods.
service_type_is_web
Returns a Bool wether or not the service_type is set to web.
Bool
service_type_is_db
Returns a Bool wether or not the service_type is set to db.
service_type_is_cache
Returns a Bool wether or not the service_type is set to cache.
service_type_is_ciustom
Returns a Bool wether or not the service_type is set to custom.
Since SpanContext is supposed to be an in-mutable object, and there are some occasions that DataDog settings need to added (i.e. a root span), there are a few cloning methods provided:
SpanContext
with_service_name
Creates a cloned object, with a new value for service_name.
$span_context_new = $root_span->with_service_name( 'MyAwesomeApp' );
A NonEmptyString where length <= 100.
A cloned DataDog::SpanContext
DataDog::SpanContext
with_service_type
Creates a cloned object, with a new value for service_type.
$span_context_new = $root_span->with_service_type( 'cache' );
An enumeration on web, db, cache, and custom
with_resource_name
Creates a cloned object, with a new value for resource_name.
$span_context_new = $root_span->with_resource_name( 'clients/?/index.cgi' );
A NonEmptyString where length <= 5000.
Sending traces to DataDog using Agent.
Role for OpenTracing Implementations.
Theo van Hoesel <tvanhoesel@perceptyx.com>
'OpenTracing::Implementation::DataDog' is Copyright (C) 2019 .. 2021, 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 package 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::Implementation::DataDog, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenTracing::Implementation::DataDog
CPAN shell
perl -MCPAN -e shell install OpenTracing::Implementation::DataDog
For more information on module installation, please visit the detailed CPAN module installation guide.