open-telemetry/opentelemetry-logger-monolog
Monolog handler that bridges your Laravel or PHP application's logs with OpenTelemetry, exporting records through the OTLP logging SDK so they can be correlated with traces and metrics in your observability backend.
Architecture fit
HandlerInterface implementation that converts Monolog records into OpenTelemetry log records and pushes them through an OTel LoggerProvider (with Processor/Exporter supplied by the application). It is not a framework, not an auto-instrumentation agent, and it does not bootstrap the SDK.logging.php channel model as a custom handler behind a monolog-driver channel, or via Log::extend for a first-class otel channel name. The architectural weight lives in the OTel SDK bootstrap (resource detection, OTLP exporter, batch processor, shutdown flush) which we own either way.Integration feasibility
LoggerProvider service provider. Realistically 1–3 engineer-days including collector wiring and validation, not a multi-sprint effort.register_shutdown_function flush on the BatchLogRecordProcessor; under Octane you need a per-request flush and a reset of the provider/context to avoid leaking state and losing records at worker recycle.trace_id/span_id only appear if an active span exists in the OTel Context at log time. That means middleware ordering, span creation inside the request lifecycle, and queue/console contexts where no span exists at all — the handler cannot invent that.ext-grpc) or HTTP/protobuf (ext-protobuf or a pure-PHP fallback). Confirm the runtime image has the extension, or budget for a container rebuild across every service.Technical risk
Key questions
trace_id/span_id and trace_flags automatically, or must we supply them via Monolog's extra/context?Stack fit
stack channels, which is the safest adoption shape: existing file/stderr channel retained, OTel handler appended as a second member of the stack.Migration path
console/file exporter only, no backend. Prove the handler emits correct severity and exception attributes.stack. Ship a correlation middleware that opens a root span. Compare OTel records to file logs for a week on volume, PII surface, and trace linkage.Compatibility
composer update passenger.ext-grpc/ext-protobuf in every runtime image before committing.LoggerProvider singleton reuse under Octane: a stale provider is a silent data-loss vector, not a crash.Sequencing
Maintenance
Support
Scaling
warning+ in production initially) and keep the existing local channel for verbose debugging.maxQueueSize, scheduleDelayMillis, export timeout) must be tuned per workload; queue saturation silently drops records under load, which is exactly when you need them.Failure modes
emergency → debug) end-to-end.Ramp-up
Verdict for a TPM
Technically low-risk, organisationally medium-risk. The opportunity score is credible: high leverage per unit of effort if OpenTelemetry is already the sanctioned standard for traces — the handler is then the cheapest available route to trace-correlated logs. If OTel is not already committed, this package is not the reason to adopt it; it is a follow-on, and the 9-star/0-dependent profile means the correct posture is pin hard, vendor the class, and treat the collector as the real system under management.
How can I help you explore Laravel packages today?