1. Go to this page and download the library: Download sarigue/curlmetry 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/ */
sarigue / curlmetry example snippets
use Curlmetry\Tracer;
use Curlmetry\Exporter\OtlpExporter;
use Curlmetry\Processor\SimpleSpanProcessor;
$exporter = new OtlpExporter('http://localhost:4318/v1/traces');
$processor = new SimpleSpanProcessor($exporter, 'curlmetry-demo');
$tracer = new Tracer($processor);
$tracer->startActiveSpan('http.request', function ($span) {
$span->setAttribute('http.method', 'GET');
$span->addEvent('processing', ['step' => 'controller']);
usleep(5000);
});
use Curlmetry\Psr\CurlHttpClient;
use Curlmetry\Psr\Request;
$client = new CurlHttpClient();
$request = new Request(
'POST',
'http://localhost:4318/v1/traces',
['Content-Type' => ['application/json']],
json_encode(['resourceSpans' => [...]])
);
$response = $client->sendRequest($request);
echo $response->getStatusCode();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.