OpenTracing::Implementation::DataDog::Client - A Client that sends off the spans
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 );
The main responsabillity of this Client is to provide the send_span method, that will send the data to the local running DataDog agent.
Client
send_span
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.
baggage_items
tags
Span
resource_name
This structure will be send of as a JSON string to the local installed DataDog agent.
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.
request
scheme
The scheme being used, should be either http or https, defaults to http
http
https
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.
localhost
DD_HOST
DD_AGENT_HOST
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.
8126
DD_TRACE_AGENT_PORT
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.
v0.3/traces
The following method(s) are required by the DataDog::Tracer:
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.
on_finish
$span
A OpenTracing Span compliant object, that will be serialised (using to_struct and converted to JSON).
A boolean, that comes from is_succes.
is_succes
to_struct
Gather required data from a single span and its context, tags and baggage items.
a hashreference with the following keys:
trace_id
span_id
resource
service
type
name
start
duration
parent_id
error
meta
metrics
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.
Sending traces to DataDog using Agent.
The DataDog Agent API Documentation.
Web user agent class
Use Cpanel::JSON::XS with a fallback to JSON::XS and JSON::PP
HTTP style request message
HTTP style response message
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.