PHP code example of leocavalcante / newrelic-telemetry-sdk
1. Go to this page and download the library: Download leocavalcante/newrelic-telemetry-sdk 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/ */
leocavalcante / newrelic-telemetry-sdk example snippets
use NewRelic\Adapter;
use NewRelic\Metric;
$metric_api = new Metric\API(new Adapter\Curl(getenv('NR_API_KEY')));
$metric_api->setCommonAttrs(['service.name' => 'PHP-SDK']);
$metric_api->send(new Metric\Gauge('memory.heap', 2.3));
$response = $metric_api->commit();
if ($response->isOk()) {
echo sprintf("Request ID: %s\n", $response->getId());
} else {
echo sprintf("Metric send error: %s\n", $response->getMessage());
}
Co\run(static function () {
go(static function () {
(new Co\Http\Client('swoole.co.uk'))->get('/');
});
});