pccomponentes / apm-doctrine-dbal
Elastic APM for Doctrine DBAL
Installs: 25 557
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 6
Forks: 3
Open Issues: 0
Requires
- php: ^7.4 | ^8.0
- aaronidas/apm-sql-lexer: ^0.0
- doctrine/dbal: ^2.10
- zoilomora/elastic-apm-agent-php: ^1.0
Requires (Dev)
README
This library supports Span traces of SQL queries using Doctrine DBAL.
Installation
-
Install via composer
composer require pccomponentes/apm-doctrine-dbal
Usage
In all cases, an already created instance of ElasticApmTracer is assumed.
Native PHP
<?php declare(strict_types=1); $sqlLogger = new PcComponentes\ElasticAPM\Doctrine\DBAL\Logging\SQLLogger( $apmTracer, /** \ZoiloMora\ElasticAPM\ElasticApmTracer instance. */ 'test', 'mysql', ); $configuration = new Doctrine\DBAL\Configuration(); $configuration->setSQLLogger($sqlLogger); $connection = Doctrine\DBAL\DriverManager::getConnection( [ 'url' => 'mysql://user:password@localhost:3306/test', 'driver' => 'pdo_mysql', 'charset' => 'UTF8', ], $configuration, ); /** ... Use the connection in your project */
Service Container (Symfony)
connection.dbal.test: class: Doctrine\DBAL\Connection factory: 'Doctrine\DBAL\DriverManager::getConnection' arguments: $params: url: 'mysql://user:password@localhost:3306/test' driver: pdo_mysql charset: UTF8 $config: '@connection.dbal.test.configuration' connection.dbal.test.configuration: class: Doctrine\DBAL\Configuration calls: - method: setSQLLogger arguments: - '@apm.dbal.test' apm.dbal.test: class: PcComponentes\ElasticAPM\Doctrine\DBAL\Logging\SQLLogger arguments: $elasticApmTracer: '@apm.tracer' # \ZoiloMora\ElasticAPM\ElasticApmTracer instance. $instance: 'test' $engine: 'mysql'
License
Licensed under the MIT license
Read LICENSE for more information