Giter Site home page Giter Site logo

auxmoney / opentracingbundle-doctrine-dbal Goto Github PK

View Code? Open in Web Editor NEW
3.0 5.0 7.0 226 KB

Doctrine extension for the auxmoney/OpentracingBundle-core

License: MIT License

PHP 98.74% Shell 1.26%
auxmoney opentracing opentracing-bundle symfony symfony-bundle distributed-tracing doctrine dbal

opentracingbundle-doctrine-dbal's Introduction

auxmoney OpentracingBundle - Doctrine DBAL

test GitHub release (latest SemVer) Codacy Badge Code Climate maintainability Scrutinizer code quality (GitHub/Bitbucket) GitHub

This bundle adds automatic spanning for Doctrine DBAL connections to the OpentracingBundle.

Installation

Prerequisites

This bundle is only an additional plugin and should not be installed independently. See its documentation for more information on installing the OpentracingBundle first.

Require dependencies

After you have installed the OpentracingBundle:

  • require the dependencies:
    composer req auxmoney/opentracing-bundle-doctrine-dbal

Enable the bundle

If you are using Symfony Flex, you are all set!

If you are not using it, you need to manually enable the bundle:

  • add bundle to your application:
    # Symfony 3: AppKernel.php
    $bundles[] = new Auxmoney\OpentracingDoctrineDBALBundle\OpentracingDoctrineDBALBundle();
    # Symfony 4+: bundles.php
    Auxmoney\OpentracingDoctrineDBALBundle\OpentracingDoctrineDBALBundle::class => ['all' => true],

Configuration

You can optionally configure environment variables, however, the default configuration will run fine out of the box for most DBAL based applications. If you cannot change environment variables in your project, you can alternatively overwrite the container parameters directly.

environment variable container parameter type default description
AUXMONEY_OPENTRACING_DOCTRINE_FULL_STATEMENT auxmoney_opentracing.doctrine.tag_full_statement string true whether to add a tag with the full SQL statement to the span
AUXMONEY_OPENTRACING_DOCTRINE_PARAMETERS auxmoney_opentracing.doctrine.tag_parameters string true whether to add a tag with the statement parameters to the span
AUXMONEY_OPENTRACING_DOCTRINE_ROW_COUNT auxmoney_opentracing.doctrine.tag_row_count string false whether to add a tag with the affected / returned rows to the span; see limitations section
AUXMONEY_OPENTRACING_DOCTRINE_USER auxmoney_opentracing.doctrine.tag_user string false whether to add a tag with the connection username to the span

Hint: you can use true, on, yes or 1 to enable an environment variable.

Usage

When querying databases using Doctrine DBAL (or higher level packages like Doctrine ORM), spans reflecting these queries are automatically generated and added to the trace. The generated tags can contain:

tag name contains
db.statement the executed statement
db.parameters the parameters of the executed statement, if present
db.row_count affected / returned rows of the executed statement; see limitations section
db.user the username of the decorated DBAL connection

Limitations

  • db.row_count: the correctness of this value depends heavily on the implementation of the Doctrine\DBAL\Driver\Statement of the driver for the database. For example, if you are using a PDO driver, keep in mind: "For most databases, PDOStatement::rowCount() does not return the number of rows affected by a SELECT statement.". See the official PHP documentation for more information on this particular topic. If you are getting different results than expected, consult the documentation for the used driver.

Development

Be sure to run

    composer run-script quality

every time before you push code changes. The tools run by this script are also run in the CI pipeline.

opentracingbundle-doctrine-dbal's People

Contributors

buzmakova avatar cawolf avatar dependabot[bot] avatar filisko avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

opentracingbundle-doctrine-dbal's Issues

Support for doctrine/dbal 3

Currently it is not possible to install that bundle with doctrine/dbal 3. Can you add support for that?

- auxmoney/opentracing-bundle-doctrine-dbal v1.2.3 requires doctrine/dbal ^2.11 -> found doctrine/dbal[2.11.0, ..., 2.13.9] but the package is fixed to 3.6.2 (lock file version) by a partial update and that version does not match.

Factory initiates the connection instead of just creating it

Here the call to $connection->getWrappedConnection() initiates the connection, whereas the factory should only create it :

$driverConnection = new TracingDriverConnection(
$connection->getWrappedConnection(),
$this->tracing,
$this->spanFactory,
$connection->getUsername()
);

This is an issue as a code creating a connection with invalid params should be safe until it uses it.
With this implementation it's not the case anymore, the createConnection method should delay connection later.

Here is the code of doctrine that initiates the connection :
https://github.com/doctrine/dbal/blob/01143c9cd4fc360a6e42017902fd9b591ca706bb/lib/Doctrine/DBAL/Connection.php#L1230-L1237

create spans only for statements running longer than x milliseconds

When using Doctrine ORM ind 3rd party frameworks like OroCRM, you can easily end up with hundreds of queries in older applications. Generating spans for all of these queries is possible, but not always desired.

Instead, having the possibility to ignore "faster" statements might sometimes help focusing on the issues that matter. Therefore, we would like to add a threshold for spans that run longer than a given time.

Unfortunately, due to jukylin/jaeger-php#85 , we are right now not able to implement this tracer agnostic. Depending on the outcome of the mentioned issue, we should revisit this feature request later.

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.