All Projects → philkra → Elastic Apm Laravel

philkra / Elastic Apm Laravel

Elastic APM Client for Laravel

Projects that are alternatives of or similar to Elastic Apm Laravel

Scout Elasticsearch Driver
This package offers advanced functionality for searching and filtering data in Elasticsearch.
Stars: ✭ 1,047 (+1050.55%)
Mutual labels:  elastic, laravel
Laravel Aws Eb
Ready-to-deploy configuration to run Laravel on AWS Elastic Beanstalk.
Stars: ✭ 247 (+171.43%)
Mutual labels:  elastic, laravel
Elastic Scout Driver Plus
Extension for Elastic Scout Driver
Stars: ✭ 90 (-1.1%)
Mutual labels:  elastic, laravel
elastic-apm-laravel
Laravel APM agent for Elastic v2 intake API
Stars: ✭ 64 (-29.67%)
Mutual labels:  apm, elastic
elastic-apm-agent-php
Elastic APM agent for PHP
Stars: ✭ 37 (-59.34%)
Mutual labels:  apm, elastic
elastic-apm-agent
Elastic Application Performance Monitoring (APM) agent for PHP
Stars: ✭ 48 (-47.25%)
Mutual labels:  apm, elastic
elastic-apm-mule3-agent
Elastic APM agent for Mule 3.x
Stars: ✭ 18 (-80.22%)
Mutual labels:  apm, elastic
Elastic Apm Php Agent
PHP Agent for Elastic APM
Stars: ✭ 283 (+210.99%)
Mutual labels:  elastic, apm
Elastic Scout Driver
Elasticsearch driver for Laravel Scout
Stars: ✭ 74 (-18.68%)
Mutual labels:  elastic, laravel
Laravel Nullable Fields
Handles saving empty fields as null for Eloquent models
Stars: ✭ 88 (-3.3%)
Mutual labels:  laravel
Laravel Prefixed Ids
Friendly prefixed IDs for Laravel models
Stars: ✭ 88 (-3.3%)
Mutual labels:  laravel
Trello Clone Vue Laravel
This is a Trello clone built using Laravel and Vue. You can read about how it was created in the series.
Stars: ✭ 88 (-3.3%)
Mutual labels:  laravel
Laravel Electron
Making Laravel desktop application using Electron Js
Stars: ✭ 89 (-2.2%)
Mutual labels:  laravel
Lingo
A Gui To Manage Laravel Translation Files
Stars: ✭ 88 (-3.3%)
Mutual labels:  laravel
Laravel Rest Api
Powerful RestAPI plugin for Laravel
Stars: ✭ 90 (-1.1%)
Mutual labels:  laravel
Mqtt Laravel
A simple Laravel Library to connect/publish/subscribe to MQTT broker
Stars: ✭ 88 (-3.3%)
Mutual labels:  laravel
Laravel Enum
Simple, extensible and powerful enumeration implementation for Laravel.
Stars: ✭ 1,278 (+1304.4%)
Mutual labels:  laravel
Icon Workshop
图标工场 - 移动应用图标生成工具,一键生成所有尺寸的应用图标和启动图
Stars: ✭ 1,303 (+1331.87%)
Mutual labels:  laravel
Laravel Totem
Manage Your Laravel Schedule From A Web Dashboard
Stars: ✭ 1,299 (+1327.47%)
Mutual labels:  laravel
Blog System In Laravel
Complete Blog System in Laravel
Stars: ✭ 89 (-2.2%)
Mutual labels:  laravel

PHP Elastic APM for Laravel & Lumen

IMPORTANT Looking for a maintainer/owner. If you want to take over the project, please open an issue here.

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\ElasticApmLaravel\Middleware\RecordTransaction::class,
];

Lumen

In bootstrap/app.php register PhilKra\ElasticApmLaravel\Middleware\RecordTransaction::class as middleware:

$app->middleware([
    PhilKra\ElasticApmLaravel\Middleware\RecordTransaction::class
]);

Service Provider

Laravel

No need to register service provider manually. It is registered automatically by package discovery.

Lumen

In bootstrap/app.php register \PhilKra\ElasticApmLaravel\Providers\ElasticApmServiceProvider::class as service provider:

$app->register(\PhilKra\ElasticApmLaravel\Providers\ElasticApmServiceProvider::class);

Spans

Laravel

A Transaction object is made available via the dependency container and can be used to start a new span at any point in the application. The Span will automatically add itself to the Transaction when it is ended.

// Use any normal Laravel method of resolving the dependency
$transaction = app(\PhilKra\ElasticApmLaravel\Apm\Transaction::class);

$span = $transaction->startNewSpan('My Span', 'app.component_name');

// do some stuff

$span->end();

Lumen

pending

Error/Exception Handling

Laravel

In app/Exceptions/Handler, add the following to the report method:

ElasticApm::captureThrowable($exception);
ElasticApm::send();

Make sure to import the facade at the top of your file:

use ElasticApm;

Lumen

not tested yet.

Agent Configuration

Laravel

The following environment variables are supported in the default configuration:

Variable Description
APM_ACTIVE true or false defaults to true. If false, the agent will collect, but not send, transaction data.
APM_APPNAME Name of the app as it will appear in APM.
APM_APPVERSION Version of the app as it will appear in APM.
APM_SERVERURL URL to the APM intake service.
APM_SECRETTOKEN Secret token, if required.
APM_APIVERSION APM API version, defaults to v1 (only v1 is supported at this time).
APM_USEROUTEURI true or false defaults to false. The default behavior is to record the URL as sent in the request. This can result in excessive unique entries in APM. Set to true to have the agent use the route URL instead.
APM_QUERYLOG true or false defaults to 'true'. Set to false to completely disable query logging, or to auto if you would like to use the threshold feature.
APM_THRESHOLD Query threshold in milliseconds, defaults to 200. If a query takes longer then 200ms, we enable the query log. Make sure you set APM_QUERYLOG=auto.
APM_BACKTRACEDEPTH Defaults to 25. Depth of backtrace in query span.
APM_RENDERSOURCE Defaults to true. Include source code in query span.

You may also publish the elastic-apm.php configuration file to change additional settings:

php artisan vendor:publish --tag=config

Once published, open the config/elastic-apm.php file and review the various settings.

Laravel Test Setup

Laravel provides classes to support running unit and feature tests with PHPUnit. In most cases, you will want to explicitly disable APM during testing since it is enabled by default. Refer to the Laravel documentation for more information (https://laravel.com/docs/5.7/testing).

Because the APM agent checks it's active status using a strict boolean type, you must ensure your APM_ACTIVE value is a boolean false rather than simply a falsy value. The best way to accomplish this is to create an .env.testing file and include APM_ACTIVE=false, along with any other environment settings required for your tests. This file should be safe to include in your SCM.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].