2017 © Pedro Peláez
 

library elastic-apm-php-agent

image

pekopt/elastic-apm-php-agent

  • Tuesday, May 22, 2018
  • by PekopT
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 13 Forks
  • 0 Open issues
  • 9 Versions
  • 100 % Grown

The README.md

Elastic APM: PHP Agent

Build Status, (*1)

This is a PHP agent for Elastic.co's APM product: https://www.elastic.co/solutions/apm. Please note that this agent is still experimental and not ready for any production usage., (*2)

Note: This is fork. Original package repository - philkra/elastic-apm-php-agent, (*3)

Installation

The recommended way to install the agent is through Composer., (*4)

Run the following composer command, (*5)

php composer.phar require hotrush/elastic-apm-php-agent

After installing, you need to require Composer's autoloader:, (*6)

require 'vendor/autoload.php';

Usage

Initialize the Agent with minimal Config

$agent = new \Hotrush\Agent(['appName' => 'demo']);

When creating the agent, you can directly inject shared contexts registry. Contexts registry contains info about user, request, tags and custom., (*7)

$contexts = new \Hotrush\Context\ContextsRegistry();
$contexts->getUser()
    ->setId(123)
    ->setUsername('User')
    ->setEmail('email@domain.com');
$contexts->getTags()->addTag('tag_name', 'tag_value');
$contexts->getRequest()->setRequestData(['body' => ['foo' => 'bar']]);
$contexts->getCustom()->addCustom('custom_key', [
    'id' => 1,
    'name' => 'Hello',
]);
$agent = new \Hotrush\Agent([ 'appName' => 'with-custom-context' ], $contexts);

Capture Errors and Exceptions

The agent can capture all types or errors and exceptions that are implemented from the interface Throwable (http://php.net/manual/en/class.throwable.php)., (*8)

$agent->captureThrowable( new Exception() );

Transaction without minimal Meta data and Context

$trxName = 'Demo Simple Transaction';
$agent->startTransaction($trxName);
// Do some stuff you want to watch ...
$agent->stopTransaction($trxName);

Transaction with Meta data and Contexts

$trxName = 'Demo Transaction with more Data';
$agent->startTransaction($trxName);
// Do some stuff you want to watch ...
$agent->stopTransaction($trxName, [
    'result' => '200',
    'type'   => 'demo'
]);
$agent->getTransaction($trxName)->getContextsRegistry()->getUser()->setId(123);
$agent->getTransaction($trxName)->getContextsRegistry()->getTags()->addTag('tag', 'value');
$agent->getTransaction($trxName)->getContextsRegistry()->getTags()->setTags( [ 'k1' => 'v1', 'k2' => 'v2' ] );  

Tests

vendor/bin/phpunit

The Versions

22/05 2018

dev-php56

dev-php56

  Sources   Download

MIT

The Requires

 

The Development Requires

22/05 2018

0.2.5

0.2.5.0

  Sources   Download

MIT

The Requires

 

The Development Requires

16/05 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

16/05 2018

0.2.4

0.2.4.0

  Sources   Download

MIT

The Requires

 

The Development Requires

23/04 2018

0.2.3

0.2.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

04/04 2018

0.2.2

0.2.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

04/04 2018

0.2.1

0.2.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

03/04 2018

0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

02/02 2018

0.1.2

0.1.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires