auxmoney/opentracing-bundle-doctrine-dbal

Symfony Opentracing 扩展包,用于 Doctrine DBAL 和 ORM

v1.2.3 2023-05-03 06:05 UTC

This package is auto-updated.

Last update: 2024-09-03 09:57:45 UTC


README

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

此扩展包为 Doctrine DBAL 连接添加了对 OpentracingBundle 的自动追踪。

安装

先决条件

此扩展包仅是一个附加插件,不应独立安装。有关安装 OpentracingBundle 的更多信息,请参阅其文档

依赖项

安装 OpentracingBundle 后

  • 需要依赖项
    composer req auxmoney/opentracing-bundle-doctrine-dbal

启用扩展包

如果您使用 Symfony Flex,您已设置完毕!

如果您没有使用它,则需要手动启用扩展包

  • 将扩展包添加到您的应用程序中
    # Symfony 3: AppKernel.php
    $bundles[] = new Auxmoney\OpentracingDoctrineDBALBundle\OpentracingDoctrineDBALBundle();
    # Symfony 4+: bundles.php
    Auxmoney\OpentracingDoctrineDBALBundle\OpentracingDoctrineDBALBundle::class => ['all' => true],

配置

您可以配置环境变量,但是默认配置对于大多数基于 DBAL 的应用程序来说将正常运行。如果您无法在项目中更改环境变量,您可以改用直接覆盖容器参数。

提示:您可以使用 trueonyes1 来启用环境变量。

用法

当使用 Doctrine DBAL(或更高层次的包,如 Doctrine ORM)查询数据库时,会自动生成并添加到跟踪中的查询反射跨度。生成的标签可以包含

限制

  • db.row_count:此值的正确性很大程度上取决于数据库驱动程序 Doctrine\DBAL\Driver\Statement 的实现。例如,如果您使用 PDO 驱动程序,请记住:“对于大多数数据库,PDOStatement::rowCount() 不会返回 SELECT 语句影响的行数。”。有关此特定主题的更多信息,请参阅官方 PHP 文档。如果您得到的结果与预期不同,请查阅所使用驱动程序的文档。

开发

确保在推送代码更改之前运行

    composer run-script quality

该脚本运行的工具也在 CI 流水中运行。