2017 © Pedro Peláez
 

library laravel-datadog-helper

A Laravel Datadog helper package.

image

chaseconey/laravel-datadog-helper

A Laravel Datadog helper package.

  • Tuesday, July 24, 2018
  • by chaseconey
  • Repository
  • 2 Watchers
  • 22 Stars
  • 41,918 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 7 Versions
  • 21 % Grown

The README.md

laravel-datadog-helper

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads] StyleCI, (*1)

Laravel Datadog Helper helps you get your application metrics integrated into Laravel as fast as possible., (*2)

Requirements

  • Laravel >= 5
  • Datadog API Key

Features

  • Adds Datadog facade that wraps the official DataDog/php-datadogstatsd library
  • Provides middleware for tracking response time metrics automatically
  • Allows prefixing all metrics that are sent for the whole application with common prefix

Installation

Require this package with composer., (*3)

composer require chaseconey/laravel-datadog-helper

Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider., (*4)

If you would like to install the request metric tracking middleware, add the Datadog middleware class like so:, (*5)

``` php, (*6)

// app/Http/Kernel.php, (*7)

protected $middleware = [ ..., (*8)

\ChaseConey\LaravelDatadogHelper\Middleware\LaravelDatadogMiddleware::class

];, (*9)


### Without Auto-Discovery (or Laravel < 5.5) If you don't use auto-discovery, or you are using an older version of Laravel, add the ServiceProvider to the providers array in `config/app.php` ``` php // config/app.php 'providers' => [ ... ChaseConey\LaravelDatadogHelper\LaravelDatadogHelperServiceProvider::class, ];

If you want to use the facade, add this to your facades in config/app.php:, (*10)

``` php, (*11)

// config/app.php, (*12)

'aliases' => [ ..., (*13)

'Datadog' => ChaseConey\LaravelDatadogHelper\Datadog::class

];, (*14)


For configuration options, copy the package config to your local config with the publish command: ```shell php artisan vendor:publish --provider="ChaseConey\LaravelDatadogHelper\LaravelDatadogHelperServiceProvider"

Middleware

This package comes with a handy middleware that you can add to any Laravel project to get up and running in Datadog as fast as possible., (*15)

  • Metric Name: request_time
  • Value: The time it takes Laravel to respond to request
  • Tags::
    • status_code
    • url (toggle via datadog.middleware_disable_url_tag config option)
    • any custom tags you have added to datadog.global_tags

With just these metrics here are a couple of example graphs that you can make:, (*16)

, (*17)

Datadog Graph Config JSON
, (*18)

#### Max Request Time by URL ```json { "viz": "heatmap", "requests": [ { "q": "max:app.example.request_time.max{*} by {url}", "type": null, "style": { "palette": "dog_classic", "type": "solid", "width": "normal" }, "aggregator": "avg", "conditional_formats": [] } ], "autoscale": true } ``` #### Top Pages Hit ```json { "viz": "toplist", "requests": [ { "q": "top(sum:app.example.request_time.count{*} by {url}.as_count(), 10, 'sum', 'desc')", "type": null, "style": { "palette": "warm", "type": "solid", "width": "normal" }, "conditional_formats": [] } ] } ``` #### Slowest Endpoints/Pages ```json { "viz": "toplist", "requests": [ { "q": "top(max:app.example.request_time.max{*} by {url}, 10, 'max', 'desc')", "type": null, "style": { "palette": "dog_classic", "type": "solid", "width": "normal" }, "conditional_formats": [ { "palette": "white_on_red", "value": 5, "comparator": ">" }, { "palette": "white_on_green", "value": 5, "comparator": " , (*19)

, (*20)

Examples

This library wraps the official DataDog/php-datadogstatsd library. All functions are inherited from the core implementation provided by this library with the exception of replacing Datadogstatsd with Datadog (the facade)., (*21)

For example:, (*22)

Instead of doing Datadogstatsd::increment('my.sweet.metrics'), you would use Datadog::increment('my.sweet.metrics')., (*23)

For a full set of usage examples, check out the library's usage README., (*24)

Change log

Please see CHANGELOG for more information what has changed recently., (*25)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*26)

Credits

License

The MIT License (MIT). Please see License File for more information., (*27)

The Versions

24/07 2018

dev-master

9999999-dev https://github.com/chaseconey/laravel-datadog-helper

A Laravel Datadog helper package.

  Sources   Download

MIT

The Requires

 

The Development Requires

chaseconey laravel-datadog-helper

24/07 2018
23/02 2018
15/12 2017
15/09 2017
14/01 2017
02/08 2016