1. Go to this page and download the library: Download google/cloud-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/ */
google / cloud-trace example snippets
use Google\Cloud\Trace\TraceClient;
$traceClient = new TraceClient();
// Create a Trace
$trace = $traceClient->trace();
$span = $trace->span([
'name' => 'main'
]);
$span->setStartTime();
// some expensive operation
$span->setEndTime();
$trace->setSpans([$span]);
$traceClient->insert($trace);
// List recent Traces
foreach($traceClient->traces() as $trace) {
var_dump($trace->traceId());
}
use Google\Cloud\Trace\TraceClient;
$client = new TraceClient();
$trace = $client->trace();
$span = $trace->span(['name' => 'main']);
$trace->setSpans([$span]);
$client->insert($trace);
use OpenCensus\Trace\Exporter\StackdriverExporter;
use OpenCensus\Trace\Tracer;
Tracer::start(new StackdriverExporter());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.