danilovl/open-telemetry-bundle
HttpClient with HttpTracingMiddleware).Illuminate\Http\Request, Illuminate\Database), custom span processors or decorators would be required (see Key Questions).php artisan queue:work) would need custom instrumentation (e.g., via TraceableHookCompilerPass equivalent).OTEL_PHP_AUTOLOAD_ENABLED, which may conflict with Laravel’s auto-loading. A custom compiler pass would be needed to replicate the bundle’s initialization logic.| Risk Area | Mitigation Strategy |
|---|---|
| Symfony Dependency | Use Symfony’s Laravel Bridge (e.g., symfony/http-foundation for HTTP) or abstract Symfony-specific code behind interfaces. |
| Performance Overhead | Start with minimal instrumentation (e.g., HTTP + Doctrine) and profile. Disable unused modules (e.g., messenger if not used). |
| Custom Instrumentation | Extend the bundle’s Traceable attribute or provider factories for Laravel-native services (e.g., Eloquent queries). |
| OTLP Exporter | Ensure the OTLP collector (e.g., Jaeger, Tempo) is configured to receive data. Fallback to console exporter for testing. |
| Backward Compatibility | Test with Laravel 10+ (PHP 8.1+) and Symfony 6.4+ components to avoid version skew. |
symfony/http-client for HTTP tracing)?QueryObserver or Traceable attribute for repositories.)Illuminate\Queue\Worker)?#[Traceable] annotations, or is a custom macro needed?| Laravel Component | Bundle Instrumentation | Integration Strategy |
|---|---|---|
| HTTP Requests | http_server |
Use symfony/http-foundation + HttpTracingMiddleware (decorate Illuminate\Http\Request). |
| Database (Eloquent) | doctrine |
Custom QueryObserver or wrap Illuminate\Database\Connection with tracing. |
| Redis | redis/predis |
Decorate Illuminate\Redis\Connections\Connection with TracingPhpRedis. |
| Queues | messenger/async |
Replace Laravel’s queue workers with Symfony Messenger + MessageBusTracingMiddleware. |
| Console Commands | console |
Use TraceableHookCompilerPass to wrap command methods with spans. |
| Events | events |
Decorate Illuminate\Events\Dispatcher with TracingEventDispatcher. |
| HTTP Client | http_client |
Use symfony/http-client + HttpTracingMiddleware (replace Guzzle/HTTP client). |
OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4318
OTEL_SERVICE_NAME=laravel-app
OTEL_PHP_AUTOLOAD_ENABLED=false
composer require danilovl/open-telemetry-bundle
config/bundles.php (if using Symfony’s kernel).config/packages/open_telemetry.yaml):
danilovl_open_telemetry:
service:
name: 'laravel-app'
instrumentation:
http_server: { enabled: true, tracing: { enabled: true } }
doctrine: { enabled: true, tracing: { enabled: true } }
redis, messenger).Traceable attribute (PHP 8+).TraceableHookCompilerPass).// app/Providers/OpenTelemetryServiceProvider.php
use Danilovl\OpenTelemetryBundle\CompilerPass\TraceableHookCompilerPass;
public function register(): void
{
$this->app->register(TraceableHookCompilerPass::class);
}
OTEL_PHP_AUTOLOAD_ENABLED before loading the bundle.OpenTelemetryCompilerPass early (e.g., in AppServiceProvider::boot()) to ensure all DI tags are resolved.$this->app->make('kernel')->getContainer()->addCompilerPass(
new \Danilovl\OpenTelemetryBundle\DependencyInjection\Compiler\OpenTelemetryCompilerPass()
);
$this->app->make(\Danilovl\OpenTelemetryBundle\OpenTelemetryInitializer::class)->initializeSdk();
| Task | Effort | Notes |
|---|---|---|
| Configuration Updates | Low | YAML-based config is straightforward; use environment variables for dynamic values. |
| Bundle Updates | Medium | Monitor for Symfony/Laravel version compatibility. |
| Custom Instrumentation | High | Requires PHP 8+ attributes or manual decorator registration. |
| Exporter Maintenance | Medium | OTLP collector requires updates (e.g., schema changes). |
| Debugging Traces | Low | Use OTEL_LOG_LEVEL=debug and check collector logs for malformed spans. |
How can I help you explore Laravel packages today?