- What is open-telemetry/api used for in a Laravel application?
- It provides vendor-neutral interfaces for traces, metrics, logs, and context propagation so application code can emit telemetry without binding to a specific backend. In Laravel it is typically used for custom business spans, request and job context propagation, and instrumentation that compiles against OpenTelemetry contracts. It is a lightweight dependency, not a complete observability solution.
- Does installing open-telemetry/api enable telemetry in Laravel?
- No. The API package includes no-op implementations, so instrumented code runs without recording or exporting anything unless an SDK is installed. You need open-telemetry/sdk plus an exporter or collector to collect and send telemetry. This is a common production risk because teams may believe tracing is enabled when nothing is recorded.
- How do I install open-telemetry/api in a Laravel application?
- Install it with Composer, usually transitively when you add the OpenTelemetry SDK and approved instrumentation packages. Pin the API as part of the OpenTelemetry dependency set rather than adopting it alone. Then configure the SDK and exporter in a Laravel service provider and environment variables.
- Is open-telemetry/api a Laravel package?
- No, it is the PHP OpenTelemetry API layer from the upstream monorepo, not a Laravel-specific package. Laravel integration is feasible through a service provider, HTTP middleware, queue middleware, and Guzzle or HTTP-client instrumentation. The API itself only defines contracts and no-op defaults.
- Which PHP and Laravel versions are supported by open-telemetry/api?
- The package is PHP-based, and releases have dropped PHP 7.4 and 8.0 while later releases include PHP 8.4 fixes, so verify the supported PHP matrix for your chosen version. Laravel version support depends more on the SDK, exporters, and integration code than on the API package alone. Check Packagist for current compatibility because release-date metadata may be stale.
- How do I propagate trace context across Laravel HTTP requests and queued jobs?
- The API provides W3C trace-context and baggage contracts that let middleware extract incoming context and inject it into outbound calls and jobs. In Laravel, use HTTP middleware and queue middleware to carry context across request, job, scheduler, and outbound HTTP boundaries. This requires an SDK and configured propagators to be effective.
- Do I need the OpenTelemetry SDK and an exporter with open-telemetry/api?
- Yes, for real telemetry. The API gives you interfaces and no-op defaults, while the SDK handles collection, sampling, and export. Production setups typically add an OTLP exporter and possibly an OpenTelemetry Collector as a stable boundary.
- How do I test Laravel code that uses the OpenTelemetry API?
- Because the API provides no-op implementations, tests can run without a live collector or backend. You can inject test doubles or use the no-op tracer and meter to verify instrumentation code paths. For integration tests, configure an SDK with an in-memory or local exporter and assert the produced spans and metrics.
- What production concerns should I plan for with OpenTelemetry in Laravel?
- Plan sampling, PII redaction, baggage size and entry limits, and data-residency rules before enabling telemetry. Long-running workers and Laravel Octane need lifecycle checks because auto-instrumentation and hooks may behave differently than under standard PHP-FPM. Also define who owns SDK configuration, collector operation, dashboards, alerts, and on-call runbooks.
- Is open-telemetry/api actively maintained, and what alternatives exist for Laravel?
- It is a read-only git subtree split of the official OpenTelemetry PHP monorepo, so fixes and issue tracking happen upstream and you depend on the monorepo release cadence. Alternatives include vendor APM agents or Laravel-specific telemetry packages that offer turnkey setup; choose them if you are not standardizing on OpenTelemetry and OTLP. If you do standardize on OpenTelemetry, use the API with the SDK and a collector.