PHP code example of cboxdk / telemetry-native

1. Go to this page and download the library: Download cboxdk/telemetry-native 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/ */

    

cboxdk / telemetry-native example snippets


$handle = cbox_telemetry_begin([
    'trace_id' => $traceId,
    'span_id'  => $spanId,
    'unit'     => 'http',
    'sampled'  => true,
    'profile'  => true,
]);

// … the request or job happens …

$result = cbox_telemetry_finish($handle, 

$result = cbox_telemetry_finish(0, 

[
    'duration_ns' => 1_842_000_000,
    'operations'  => ['pdo.connect' => ['count' => 1, 'total_ns' => 83_200_000, 'max_ns' => 83_200_000]],
    'counters'    => ['profiler.samples' => 814, 'profiler.dropped' => 0, 'gc.runs' => 3, …],
    'profile'     => [
        'sample_count'  => 814,
        'period_ns'     => 1_000_000,
        'clock'         => 'cpu',
        'frames'        => [['function' => 'App\\Services\\Pricing::calculate', 'file' => '…', 'line' => 82], …],
        'top_functions' => [['frame_id' => 1, 'samples' => 284], …],
        'stacks'        => null,
    ],
]
ini
cbox_telemetry.auto = 1