Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Api Laravel Package

open-telemetry/api

OpenTelemetry API for PHP: vendor-neutral interfaces for tracing, metrics, and context propagation. Use it to instrument libraries/apps and connect to any OpenTelemetry SDK/exporter. Part of the OpenTelemetry PHP project (subtree split).

View on GitHub
Deep Wiki
Context7

[READONLY] The API for OpenTelemetry PHP

Frequently asked questions about Api
How do I integrate OpenTelemetry API into a Laravel application for distributed tracing?
Start by installing the package via Composer (`composer require open-telemetry/api`). Then, use Laravel’s service container to bind the `TracerInterface` and instrument HTTP requests via middleware. For example, create middleware to auto-start spans for incoming requests, leveraging the `Span` API to track execution flow across services.
Which Laravel versions are officially supported by this package?
The OpenTelemetry API for PHP supports Laravel applications running PHP 8.1 or higher. Ensure your Laravel version aligns with the PHP version requirements, as the package itself is framework-agnostic but designed for modern PHP ecosystems.
Can I use this package with existing Monolog or Sentry logging in Laravel?
Yes, you can extend Monolog handlers to forward logs to OpenTelemetry’s `Logger` API. This allows you to maintain existing logging setups while adding OpenTelemetry instrumentation. The package provides interfaces like `Logger` to integrate seamlessly with your current logging infrastructure.
What exporters (e.g., OTLP, Jaeger) work with this API, and how do I configure them?
This API is vendor-neutral, so you can pair it with any OpenTelemetry exporter like `open-telemetry/exporter-otlp` for OTLP or `open-telemetry/exporter-jaeger` for Jaeger. Configuration depends on your backend choice; for example, OTLP requires setting up an OTLP endpoint in your exporter configuration.
How do I measure custom metrics (e.g., queue job duration) in Laravel using this package?
Use the `Meter` API to create custom metrics like counters or histograms. For queue jobs, hook into Laravel’s `JobProcessed` event and record metrics using the `MeterProvider`. This allows you to track performance metrics without modifying core Laravel logic.
Is there a performance overhead when using OpenTelemetry in production?
Instrumentation adds minimal overhead (nanoseconds per span), but high-cardinality metrics may require sampling to avoid performance issues. For production, consider sampling strategies (e.g., 10% of traces) and monitor resource usage to balance observability and cost.
How do I propagate context (e.g., trace IDs) across microservices in Laravel?
Use the `Context` API to propagate W3C Trace Context and baggage across HTTP requests, queues, or external API calls. Laravel’s middleware can inject context into outgoing requests, ensuring traces remain consistent across distributed services.
Are there alternatives to this package for OpenTelemetry in PHP?
The OpenTelemetry PHP API is the official, vendor-neutral standard. Alternatives like custom wrappers or proprietary APM tools may exist, but they lack standardization and interoperability. This package ensures compatibility with any OpenTelemetry SDK or exporter.
How do I test OpenTelemetry instrumentation in a Laravel application?
Start with a minimal setup: instrument a single route or controller and verify traces appear in your backend (e.g., Jaeger or OTLP collector). Use mock exporters in tests to avoid external dependencies, and validate context propagation with tools like `curl` or Postman.
What are the breaking changes or deprecated interfaces I should watch for in this package?
The package has deprecated interfaces like `InstrumentationInterface` and `ConfigurationResolver`, with active development (e.g., `Logger::logRecordBuilder()`). Monitor the [releases](https://github.com/opentelemetry-php/api/releases) for updates and ensure your Laravel app aligns with semantic conventions (e.g., semconv 1.38.0) to avoid data schema mismatches.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata