PHP

PHP A language-specific implementation of OpenTelemetry in PHP.

You are viewing the English version of this page because it has not yet been fully translated. Interested in helping out? See Contributing.

这是 OpenTelemetry PHP 的文档。 OpenTelemetry 是一个可观测性框架,这个框架提供了 API、SDK 以及一系列工具,用于辅助生成以及收集应用程序的遥感数据,比如指标(metrics)、日志(logs) 和链路追踪(trace),通过本文档,你会了解如何开始使用 OpenTelemetry PHP。

状态以及版本发布

OpenTelemetry PHP 的当前主要功能组件状态如下:

链路追踪(Traces)指标(Metrics)日志(Logs)
StableStableStable

我们可以在 Releases 中找到所有已发布的版本,包括 latest release

Further Reading

Requirements

OpenTelemetry SDK for PHP aims to support all officially supported PHP versions according to www.php.net/supported-versions, and support will be dropped for PHP versions within 12 months of that version going End of Life.

Auto-instrumentation requires PHP version 8.0+.

Dependencies

Some of the SDK and Contrib packages have a dependency on both a HTTP Factories (PSR-17) and a php-http/async-client implementation. You can find appropriate composer packages implementing given standards on packagist.org.

See http-factory-implementations to find a PSR-17 (HTTP factories) implementation, and async-client-implementations to find a php-http/async-client implementation.

Optional PHP extensions

ExtensionPurpose
ext-grpcRequired to use gRPC as a transport for the OTLP exporter
ext-mbstringMore performant than the fallback, symfony/polyfill-mbstring
ext-zlibIf you want to compress exported data
ext-ffiFiber-based context storage
ext-protobufSignificant performance improvement for otlp+protobuf exporting

ext-ffi

Fibers support can be enabled by setting the OTEL_PHP_FIBERS_ENABLED environment variable to true. Using fibers with non-CLI SAPIs may require preloading of bindings. One way to achieve this is setting ffi.preload to src/Context/fiber/zend_observer_fiber.h and setting opcache.preload to vendor/autoload.php.

ext-protobuf

The native protobuf library is significantly slower than the extension. We strongly encourage the use of the extension.

Setup

OpenTelemetry for PHP is distributed via packagist, in a number of packages. We recommend that you install only the packages that you need, which as a minimum is usually API, Context, SDK and an exporter.

We strongly encourage that your code only depend on classes and interfaces in the API package.


Getting Started

Get up and running with OpenTelemetry for PHP.

Instrumentation

Manual instrumentation for OpenTelemetry PHP

Using instrumentation libraries

Exporters

Context

Learn how the context API works in instrumented applications.

Propagation

Context propagation for the PHP API

Resources

SDK

API reference

Examples

Registry

Instrumentation libraries, exporters and other useful components for OpenTelemetry PHP