NAME
OpenTracing::Implementation::DataDog::Client - A Client that sends off the spans
SYNOPSIS
use alias OpenTracing::Implementation::DataDog::Client;
my $datadog_client = ->new(
http_user_agent => LWP::UserAgent->new();
host => 'localhost',
port => '8126',
path => 'v0.3/traces',
); # these are defaults
and later:
$datadog_client->send_span( $span );
DESCRIPTION
The main responsabillity of this Client
is to provide the send_span
method, that will send the data to the local running DataDog agent.
It does this by calling to_struct that massages the generic OpenTracing data, like baggage_items
from SpanContext and tags
from Span
, together with the DataDog specific data like resource_name
.
This structure will be send of as a JSON string to the local installed DataDog agent.
OPTIONAL ATTRIBUTES
The attributes below can be set during instantiation, but none are required and have sensible defaults, that may actually play nice with known DataDog environment variables
http_user_agent
A HTTP User Agent that connects to the locally running DataDog agent. This will default to a LWP::UserAgent, but any User Agent will suffice, as long as it has a required delegate method request
, that takes a HTTP::Request object and returns a HTTP::Response compliant response object.
scheme
The scheme being used, should be either http
or https
, defaults to http
host
The host-name where the DataDog agent is running, which defaults to localhost
or the value of either DD_HOST
or DD_AGENT_HOST
environment variable if set.
port
The port-number the DataDog agent is listening at, which defaults to 8126
or the value of the DD_TRACE_AGENT_PORT
environment variable if set.
env
The environment name to pass to the agent. By default, no environment is passed.
path
The path the DataDog agent is expecting requests to come in, which defaults to v0.3/traces
.
DELEGATED INSTANCE METHODS
The following method(s) are required by the DataDog::Tracer:
send_span
This method gets called by the DataDog::Tracer to send a Span with its specific DataDog::SpanContext.
This will typically get called during on_finish
.
Required Positional Arguments
$span
-
A OpenTracing Span compliant object, that will be serialised (using to_struct and converted to JSON).
Returns
A boolean, that comes from is_succes
.
INSTANCE METHODS
to_struct
Gather required data from a single span and its context, tags and baggage items.
Required Positional Arguments
Returns
a hashreference with the following keys:
trace_id
span_id
resource
service
type
(optional)name
start
duration
parent_id
(optional)error
(TODO)meta
(optional)metrics
Notes
This data structure is specific for sending it through the DataDog agent and therefore can not be a intance method of the DataDog::Span object.
SEE ALSO
- OpenTracing::Implementation::DataDog
-
Sending traces to DataDog using Agent.
- DataDog Docs API Tracing
-
The DataDog Agent API Documentation.
- LWP::UserAgent
-
Web user agent class
- JSON::Maybe::XS
-
Use Cpanel::JSON::XS with a fallback to JSON::XS and JSON::PP
- HTTP::Request
-
HTTP style request message
- HTTP::Response
-
HTTP style response message
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.