open-telemetry/opentelemetry-sqlcommenter
最新稳定版本:0.1.0
Composer 安装命令:
composer require open-telemetry/opentelemetry-sqlcommenter
包简介
OpenTelemetry sqlcommenter.
README 文档
README
Note: This is a read-only subtree split of open-telemetry/opentelemetry-php-contrib.
OpenTelemetry SQL Commenter
OpenTelemetry SQL Commenter for PHP provides a SqlCommenter implementation, enabling you to inject trace and context comments into SQL queries for enhanced observability and distributed tracing.
Installation
Install via Composer:
composer require open-telemetry/opentelemetry-sqlcommenter
Usage
Inject comments into your SQL query as follows:
use OpenTelemetry\SqlCommenter\SqlCommenter; $comments = [ 'traceparent' => '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-00', 'custom' => 'value', ]; $query = SqlCommenter::inject($query, $comments);
Configuration
-
Context Propagators
Set the propagators to use (comma-separated):
OTEL_PHP_SQLCOMMENTER_CONTEXT_PROPAGATORS=tracecontext
Default:
'' -
SQL Commenter Attribute
Add SQL comments to
DbAttributes::DB_QUERY_TEXTin span attributes:otel.sqlcommenter.attribute = trueor via environment variable:
OTEL_PHP_SQLCOMMENTER_ATTRIBUTE=true
Default:
false -
Prepend Comments
Prepend comments to the query statement using either a configuration directive:
otel.sqlcommenter.prepend = trueor via environment variable:
OTEL_PHP_SQLCOMMENTER_PREPEND=true
Default:
false
Development
Install dependencies and run tests from the SqlCommenter subdirectory:
composer install ./vendor/bin/phpunit tests
统计信息
- 总下载量: 2.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2025-10-05