Giter Site home page Giter Site logo

apm-doctrine-dbal's Introduction

Elastic APM for Doctrine DBAL

This library supports Span traces of SQL queries using Doctrine DBAL.

Installation

  1. 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

apm-doctrine-dbal's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.