open-telemetry/opentelemetry-auto-psr3
Composer 安装命令:
composer require open-telemetry/opentelemetry-auto-psr3
包简介
OpenTelemetry auto-instrumentation for PSR-3 (Logger Interface).
README 文档
README
This is a read-only subtree split of https://github.com/open-telemetry/opentelemetry-php-contrib.
OpenTelemetry PSR-3 auto-instrumentation
Please read https://opentelemetry.io/docs/instrumentation/php/automatic/ for instructions on how to install and configure the extension and SDK.
Overview
Auto-instrumentation hooks are registered via composer, and depending on the mode, will:
- automatically inject trace id and span id into log message context of any psr3 logger; or
- transform the message into the OpenTelemetry LogRecord format, for export to an OpenTelemetry logging-compatible backend
Mode
The package can operate in two modes, controlled by the environment variable OTEL_PHP_PSR3_MODE:
inject
Inject trace_id and span_id of the active trace span into the context of each logged message. Depending on the PSR-3 implementation,
the values may be written to the log output, or may be available for interpolation into the log message.
For example:
putenv('OTEL_PHP_PSR3_MODE=inject'); require 'vendor/autoload.php'; $logger = /* create logger */ $logger->info('trace_id={trace_id} span_id={span_id}');
export
The logged output will be processed and emitted by the logger as normal, but the output will also be encoded using the OpenTelemetry log model and can be exported to an OpenTelemetry-compatible backend.
putenv('OTEL_PHP_PSR3_MODE=export'); putenv('OTEL_PHP_AUTOLOAD_ENABLED=true'); putenv('OTEL_LOGS_EXPORTER=console'); require 'vendor/autoload.php'; $logger = /* create logger */ $logger->info('Hello, OTEL');
Configuration
The extension can be disabled via runtime configuration:
OTEL_PHP_DISABLED_INSTRUMENTATIONS=psr3
open-telemetry/opentelemetry-auto-psr3 适用场景与选型建议
open-telemetry/opentelemetry-auto-psr3 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.3M 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「PSR3」 「instrumentation」 「tracing」 「opentelemetry」 「open-telemetry」 「otel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 open-telemetry/opentelemetry-auto-psr3 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 open-telemetry/opentelemetry-auto-psr3 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 open-telemetry/opentelemetry-auto-psr3 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Hero for your Laminas and Mezzio application to trap php errors & exceptions
Monolog JSON Formatter for Google StackDriver integration
Observability component.
Stickee instrumentation module - monitor application performance and statistics.
OpenTelemetry auto-instrumentation for PHP Session functions
A collection of monolog handlers using PSR-18 http client
统计信息
- 总下载量: 1.3M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 35
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2023-06-27