Code Monkey home page Code Monkey logo

elastic-apm-laravel's Introduction

PHP Elastic APM for Laravel & Lumen

Laravel package of the https://github.com/philkra/elastic-apm-php-agent library, automatically handling transactions and errors/exceptions. If using Illuminate\Support\Facades\Auth the user Id added to the context. Tested with Laravel 5.6.* and the philkra/elastic-apm-php-agent version 6.2.*.

Install

composer require philkra/elastic-apm-laravel

Middleware

Laravel

Register as (e.g.) global middleware to be called with every request. https://laravel.com/docs/5.6/middleware#global-middleware

Register the middleware in app/Http/Kernel.php

protected $middleware = [
    // ... more middleware
    \PhilKra\Middleware\Elastic\ApmAgent::class,
];

Lumen

In bootstrap/app.php register PhilKra\Middleware\Elastic\ApmAgent::class as middleware:

$app->middleware([
    PhilKra\Middleware\Elastic\ApmAgent::class
]);

Error/Exception Handling

Laravel

Replace the default exception handler with overloading APM handler. The APM class is extending Laravel's "default" exception handler app/Exceptions/Handler. In bootstrap/app.php remove the default handler App\Exceptions\Handler::class with PhilKra\Exceptions\Elastic\ApmAgent::class.

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    PhilKra\Exceptions\Elastic\ApmAgent::class
);

Lumen

not tested yet.

elastic-apm-laravel's People

Contributors

philkra avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.