2017 © Pedro Peláez
 

library dd-opentracing

DataDog implementation for OpenTracing in PHP

image

jcchavezs/dd-opentracing

DataDog implementation for OpenTracing in PHP

  • Friday, May 19, 2017
  • by jcchavezs
  • Repository
  • 1 Watchers
  • 4 Stars
  • 91 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

DataDog OpenTracing PHP

Build Status Join the chat at https://gitter.im/dd-opentracing-php/Lobby, (*1)

DataDog implementation for OpenTracing in PHP, (*2)

Installation

Execute:, (*3)

composer require jcchavezs/dd-opentracing

Examples

use DdOpenTracing\Tracer;
use OpenTracing\Carriers\HttpHeaders;
use OpenTracing\GlobalTracer;
use OpenTracing\Propagator;
use OpenTracing\SpanContext;
use OpenTracing\SpanReference\ChildOf;
use OpenTracing\Tag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

$request = Request::createFromGlobals();

$client = new \GuzzleHttp\Client();
$logger = new \Monolog\Logger("log");
$encoderFactory = new \DdTrace\Encoders\JsonFactory;
$transport = new \DdTrace\Transports\Http($client, $logger, $encoderFactory);
$buffer = new \DdTrace\Buffer();
$ddTracer = new \DdTrace\Tracer($buffer, $logger, $transport);

$tracer = new Tracer($ddTracer, $logger);
$tracer->enableDebugLogging();

GlobalTracer::setGlobalTracer($tracer);

$spanContext = GlobalTracer::globalTracer()->extract(
    Propagator::HTTP_HEADERS,
    HttpHeaders::fromRequest($request)
);

usleep(200);

readFromDB($spanContext);

$response = Response::create("", 200);

$response->send();

// This flushes the traces, if the buffer could be persisted, a worker could flush the traces from time to time.
$tracer->tracer()->flushTraces();

function readFromDB(SpanContext $spanContext)
{
    $tracer = GlobalTracer::globalTracer();

    $component = Tag::create("component", "SELECT * FROM test_table");
    $peerService = Tag::create("peer.service", "test_service");

    $span = $tracer->startSpan("Db read", ChildOf::withContext($spanContext), null, $component, $peerService);

    usleep(3000);

    $span->finish();
}

The Versions

19/05 2017

dev-master

9999999-dev

DataDog implementation for OpenTracing in PHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

19/05 2017

0.3.1

0.3.1.0

DataDog implementation for OpenTracing in PHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

12/05 2017

0.3.0

0.3.0.0

DataDog implementation for OpenTracing in PHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

25/04 2017

0.2.1

0.2.1.0

DataDog implementation for OpenTracing in PHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

25/04 2017

0.2

0.2.0.0

DataDog implementation for OpenTracing in PHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

25/04 2017

0.1

0.1.0.0

DataDog implementation for OpenTracing in PHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires