mmo / opentelemetry-auto-yii2-web
OpenTelemetry auto-instrumentation for Yii2 web app
Package info
github.com/morawskim/opentelemetry-auto-yii2-web
pkg:composer/mmo/opentelemetry-auto-yii2-web
Requires
- php: ^8.2
- ext-opentelemetry: *
- open-telemetry/api: ^1.0
- open-telemetry/sem-conv: ^1.36
Requires (Dev)
- open-telemetry/sdk: ^1.0
This package is auto-updated.
Last update: 2026-03-21 13:57:44 UTC
README
This package provides automatic instrumentation for the Yii2 web applications using OpenTelemetry.
Requirements
- PHP 8.2+
- OpenTelemetry PHP Extension (
ext-opentelemetry)
Installation
You can install the package via Composer:
composer require mmo/opentelemetry-auto-yii2-web
Usage
The instrumentation is automatically registered via Composer's autoloading mechanism (using _register.php). As long as the package is installed and the opentelemetry extension is loaded, it will hook into Yii2's core methods.
Disabling Instrumentation
You can disable this specific instrumentation by setting the OTEL_PHP_DISABLED_INSTRUMENTATIONS environment variable:
export OTEL_PHP_DISABLED_INSTRUMENTATIONS=mmo-yii2-web
How it works
The library uses the OpenTelemetry hook() function to intercept key Yii2 methods:
- Inline Actions: Wraps
runWithParamsin a span to monitor action logic execution. - View Rendering: Wraps
renderin a span to measure time spent rendering templates. - View File Path: Hooks into
findViewFileto enrich the current span with the exact path of the rendered file.
License
This project is licensed under the MIT License. See the LICENSE.txt file for details.