The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

OpenTracing::Implementation::DataDog::SpanContext - A DataDog Implementation

SYNOPSIS

    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') )

DESCRIPTION

This is a OpenTracing SpanContext compliant implementation with DataDog specific extentions

EXTENDED ATTRIBUTES

trace_id

DataDog requires this to be a unsigned 64-bit integer

span_id

DataDog requires this to be a unsigned 64-bit integer

DATADOG SPECIFIC ATTRIBUTES

service_name

A required NonEmptyString where length <= 100.

Defaults to the value of the DD_SERVICE_NAME environment variable if set.

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.

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.

Good candidates for resource names are URL paths or databasenames and or tables.

CONSTRUCTORS

Warning:

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'.

new

    my $span_context = SpanContext->new(
        service_name  => "MyFancyService",
        resource_name => "/clients/{client_id}/contactdetails",
        baggage_items => { $key => $value, .. },
    );

Creates a new SpanContext object;

INSTANCE METHODS

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.

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.

CLONE METHODS

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:

with_service_name

Creates a cloned object, with a new value for service_name.

    $span_context_new = $root_span->with_service_name( 'MyAwesomeApp' );

Required Positional Parameter(s)

service_name

A NonEmptyString where length <= 100.

Returns

A cloned 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' );

Required Positional Parameter(s)

service_type

An enumeration on web, db, cache, and custom

Returns

A cloned DataDog::SpanContext

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' );

Required Positional Parameter(s)

resource_name

A NonEmptyString where length <= 5000.

Returns

A cloned DataDog::SpanContext

SEE ALSO

OpenTracing::Implementation::DataDog

Sending traces to DataDog using Agent.

OpenTracing::Role::SpanContext

Role for OpenTracing Implementations.

AUTHOR

Theo van Hoesel <tvanhoesel@perceptyx.com>

COPYRIGHT AND LICENSE

'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.