PHP code example of motadata-apm / custom-instrumentation
1. Go to this page and download the library: Download motadata-apm/custom-instrumentation 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/ */
motadata-apm / custom-instrumentation example snippets
use Motadata\Apm\CustomInstrumentation;
try {
CustomInstrumentation::setInt('apm.user.id', 98765);
CustomInstrumentation::setInt('apm.order.id', 12345);
CustomInstrumentation::setFloat('apm.order.amount', 199.99);
CustomInstrumentation::set('apm.request.success', true);
CustomInstrumentation::setString('apm.user.name', 'john.doe');
CustomInstrumentation::setStringArray('apm.tags', ['api', 'production', 'critical']);
} catch (Exception $exception) {
error_log('Failed to set custom attributes: ' . $exception->getMessage());
}