pccomponentes / apm-guzzle
Elastic APM for Guzzle
Installs: 12 160
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 7
Forks: 1
Open Issues: 0
Requires
- php: ^7.4 | ^8.0
- guzzlehttp/guzzle: ^6.5 | ^7.0
- zoilomora/elastic-apm-agent-php: ^0.1 | ^1.0
Requires (Dev)
- pccomponentes/coding-standard: ^1.2.3
This package is auto-updated.
Last update: 2024-11-15 20:26:46 UTC
README
This library supports Span traces of HTTP calls and distributed traces with Guzzle.
Installation
-
Install via composer
composer require pccomponentes/apm-guzzle
Usage
In all cases, an already created instance of ElasticApmTracer is assumed.
Native PHP
<?php declare(strict_types=1); $apmMiddleware = PcComponentes\ElasticAPM\GuzzleHttp\ElasticApmMiddleware::trace( $apmTracer, /** \ZoiloMora\ElasticAPM\ElasticApmTracer instance. */ ); $handler = GuzzleHttp\HandlerStack::create(); $handler->push($apmMiddleware); $config = [ 'handler' => $handler, ]; $client = new GuzzleHttp\Client($config);
Service Container (Symfony)
http.client: class: GuzzleHttp\Client arguments: $config: handler: '@guzzle.handler' guzzle.handler: class: GuzzleHttp\HandlerStack factory: 'GuzzleHttp\HandlerStack::create' calls: - method: push arguments: ['@guzzle.middleware.apm', 'trace'] guzzle.middleware.apm: class: Closure factory: 'PcComponentes\ElasticAPM\GuzzleHttp\ElasticApmMiddleware::trace' arguments: $elasticApmTracer: '@apm.tracer' # \ZoiloMora\ElasticAPM\ElasticApmTracer instance.
License
Licensed under the MIT license
Read LICENSE for more information