auxmoney/opentracing-bundle-monolog
monolog/monolog + spatie/laravel-monolog).UBER-TRACE-ID) into log records, enabling end-to-end traceability across microservices or Laravel services.spatie/laravel-monolog or laravel/log.opentracing/opentracing-php or open-telemetry/opentelemetry-php). Laravel applications using Laravel Horizon or Sentry may need additional setup.Bundle system, which may require refactoring for Laravel (e.g., replacing Kernel hooks with Laravel’s ServiceProvider boot methods).opentracing-context field?spatie/laravel-monolog)? If not, additional setup is needed.spatie/laravel-activitylog + custom tracing)?opentracing/opentracing-php or open-telemetry/opentelemetry-php). If using Laravel Horizon, it may already have tracing support.opentracing/opentracing-php and auxmoney/opentracing-bundle-core.open-telemetry/opentelemetry-php and adapt the Monolog processor.spatie/laravel-monolog (if not already present) and configure it as the default logger.composer require spatie/laravel-monolog monolog/monolog
// app/Providers/AppServiceProvider.php
use Monolog\Processor\ProcessorInterface;
class TracingProcessor implements ProcessorInterface
{
public function __invoke(array $record): array
{
$spanContext = \OpenTracing::globalTracer()->getActiveSpan()?->getContext()->toTraceId();
$record['extra']['opentracing-context'] = json_encode(['UBER-TRACE-ID' => $spanContext]);
return $record;
}
}
config/logging.php:
'processors' => [
App\Providers\TracingProcessor::class,
],
$tracer = new \OpenTracing\Tracer(
new \OpenTracing\SpanContext(),
new \OpenTracing\NoopReporter()
);
\OpenTracing::setGlobalTracer($tracer);
auxmoney/opentracing-bundle-core and opentracing/opentracing. Monitor for deprecations (e.g., OpenTracing → OpenTelemetry).opentracing-context to logs may require updates to log parsers (e.g., Filebeat, Fluentd) or query filters in tools like Kibana.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Tracer not initialized | Logs lack trace context; debugging harder. | Ensure tracer is initialized early in the request lifecycle. |
| Monolog processor fails | Logs may be malformed or missing context. | Add error handling in the processor; log failures to a separate channel. |
| OpenTracing API changes | Custom processor breaks if APIs deprecate. | Monitor OpenTracing/OpenTelemetry updates; refactor to use stable interfaces. |
| Log storage cannot index trace IDs | Trace correlation fails in observability tools. | Validate log schema compatibility with storage (e.g., ELK mapping). |
| High log volume + trace context | Increased storage costs or parsing delays. | Sample logs or exclude trace context from non-critical logs. |
How can I help you explore Laravel packages today?