PHP code example of jcchavezs / dd-trace
1. Go to this page and download the library: Download jcchavezs/dd-trace library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jcchavezs / dd-trace example snippets
use DdTrace\Tracer;
use GuzzleHttp\Exception\RequestException;
$tracer = Tracer::noop();
$client = new GuzzleHttp\Client();
$span = $tracer->createRootSpan("http.client.request", "example.com", "/user/{id}");
$url = "http://example.com/user/123";
try {
$response = $client->get($url);
$span->setMeta("http.status", $response->getStatusCode());
$span->setMeta("http.url", $url);
} catch (RequestException $e) {
$span->setError($e);
}
$span->finish();