This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Nette extension for Elastic APM

dev-master 2019-06-23 10:56 UTC

This package is auto-updated.

Last update: 2021-05-23 15:55:46 UTC




     apm: Efabrica\NetteElasticAmp\ApmExtension
    enabled: true # optional
    config: # required (APM agent configuration)
        appName       : "Name of this application" # required
        appVersion    : "Application version" # optional, default: ''
        serverUrl     : "APM Server Endpoint" # optional, default:
        secretToken   : "Secret token for APM Server" # optional, default: null
        hostname      : "Hostname to transmit to the APM Server" # optinal, default: gethostname()
        active        : "Activate the APM Agent" # optional, default: true
        timeout       : "Guzzle Client timeout" # optional, default: 5
        apmVersion    : "APM Server Intake API version" # optional, default: 'v1'
        env           : "$_SERVER vars to send to the APM Server, empty set sends all. Keys are case sensitive" # optional, default: []
        cookies       : "Cookies to send to the APM Server, empty set sends all. Keys are case sensitive" # optional, default: []
        httpClient    : "Extended GuzzleHttp\\Client" # optional, default: []
        backtraceLimit: "Depth of a transaction backtrace" # optional, default: unlimited
    spanGenerators: # optional, default: NetteDatabaseQuerySpanGenerator::class
        - Efabrica\NetteElasticAmp\SpanGenerator\NetteDatabaseQuerySpanGenerator()

How to create new SpanGenerators

Each span generator have to register processSpan() method on APM agent for events we want to capture.

public static function register(ContainerBuilder $containerBuilder, ServiceDefinition $apmTransaction): void
    // Some code ...
        $service->onEventStart[] = function ($param1, $param2) :void {
            (?)->processSpan(?, ?, $param1, $param2);
        }', [$apmTransaction, self::class, 'start']);
        $service->onEventEnd[] = function ($param1, $param2) :void {
            (?)->processSpan(?, ?, $param1, $param2);
        }', [$apmTransaction, self::class, 'end']);

public function process(float $transactionStart, string $method, array $params): array
    switch($method) {
        case 'start':
            // do something ...
            return $spans; // array with spans
        case 'end':
            // do something else ...
            return $spans; // array with spans