PHP code example of utopia-php / telemetry

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

    

utopia-php / telemetry example snippets




eate a Telemetry instance using OpenTelemetry adapter.
use Utopia\Telemetry\Adapter\OpenTelemetry;

$telemetry = new OpenTelemetry('http://localhost:4138', 'namespace', 'app', 'unique-instance-name');
$counter = $telemetry->createUpDownCounter('http.server.active_requests', '{request}');

$counter->add(1);
$counter->add(2);

// Periodically collect metrics and send them to the configured OpenTelemetry endpoint.
$telemetry->collect();

// Example using Swoole
\Swoole\Timer::tick(60_000, fn () => $telemetry->collect());
bash
composer