PHP code example of yakovlef / telegraf-metrics-bundle
1. Go to this page and download the library: Download yakovlef/telegraf-metrics-bundle 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/ */
yakovlef / telegraf-metrics-bundle example snippets
use Yakovlef\TelegrafMetricsBundle\Collector\MetricsCollectorInterface;
class UserController
{
public function __construct(
private MetricsCollectorInterface $metricsCollector
) {}
public function register(): Response
{
// Your business logic here...
// Send metrics
$this->metricsCollector->collect('user_registration', [
'count' => 1
], [
'source' => 'web', //source for example web, mobile, api
'country' => 'US' //country of the user
], );
return new JsonResponse(['status' => 'success']);
}
}