gopaljha / laravel-datadog
A simple package to wrap DataDog API for Timeseries metrics
Requires
- php: >=5.6.4
- laravel/framework: 5.3.*
README
Laravel DataDog
A simple package to use DataDog Series Metric using their API via TCP
Why?
Because some people cannot install the DataDog Agent or StatsD. So we have to use DataDog API to send data. Using the API losses the advantage of using UDP (unblocking) calls. This package gives you a nice way to send metric information and also make sure the jobs are queued.
Other packages
This package should only be used if you also find yourslef in the unique situation where you cannot use the DataDog Agent. Make sure you investigate the below packages first.
Installation
Pull in the package using Composer
composer require gopaljha/laravel-datadog
$providers = [ GopalJha\LaravelDataDog\LaravelDataDogServiceProvider::class, ]
Publish the config file
php artisan vendor:publish --provider="GopalJha\LaravelDataDog\LaravelDataDogServiceProvider" --tag=config
Set your DataDog API key in your .env
file using the key DATADOG_KEY
.
How to use
Increment a Metric
\DataDog::increment('app.pageview');
Increment a Metric with tagging and Host
A powerful feature of DataDog is the ability to tag things.
\DataDog::increment('app.pageview', ['tag' => 'one', 'tag' => 'two']);
You can also send a custom host if you require.
\DataDog::increment('app.pageview', ['tag' => 'one', 'tag' => 'two'], 'example.com');