open-telemetry/exporter-otlp
OpenTelemetry OTLP exporter for PHP. Send traces to an OpenTelemetry Collector via HTTP (JSON/protobuf) or gRPC (with transport-grpc). Requires a protobuf runtime; for production, install the protobuf PECL extension for best performance.
open-telemetry/exporter-otlp package is a critical component for a Laravel/PHP-based system if observability (metrics, logs, traces) is a priority. It enables OpenTelemetry Protocol (OTLP) exports, aligning with modern distributed tracing and monitoring standards.open-telemetry/auto-instrumentation) but requires explicit setup. Laravel’s monolithic architecture may need manual instrumentation (e.g., middleware, service containers).config/app.php or a custom provider).Illuminate\Http\Middleware).open-telemetry/context).pecl install grpc).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| gRPC Dependency | High | Fallback to HTTP/JSON if gRPC is unavailable. |
| Context Propagation | Medium | Test baggage context in async jobs/queues. |
| Performance Overhead | Medium | Benchmark trace collection in staging. |
| Vendor Lock-in | Low | OTLP is open standard; backend swappable. |
| Laravel Ecosystem Gaps | High | May need custom packages (e.g., spatie/laravel-otel). |
curl for HTTP/JSON.open-telemetry/auto-instrumentation) for automatic trace collection.spatie/laravel-otel (if available) for simplified setup.Phase 1: Instrumentation
open-telemetry/exporter-otlp and open-telemetry/sdk to composer.json.$this->app->bind(\OpenTelemetry\SDK\Common\ResourceInfo::class, function () {
return new \OpenTelemetry\SDK\Common\ResourceInfo([
'service.name' => 'laravel-app',
'service.version' => '1.0.0',
]);
});
use OpenTelemetry\API\Trace\Span;
use OpenTelemetry\API\Trace\TracerInterface;
public function handle($request, Closure $next) {
$tracer = app(TracerInterface::class);
$span = $tracer->spanBuilder('http.request')->startSpan();
try {
return $next($request);
} finally {
$span->end();
}
}
Phase 2: OTLP Backend Setup
otlp-config.yaml for collector:
receivers:
otlp:
protocols:
grpc:
http:
processors:
batch:
exporters:
logging:
loglevel: debug
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging]
Phase 3: Validation
| Component | Compatibility Notes |
|---|---|
| Laravel Queues | Requires open-telemetry/context for baggage propagation. |
| Lumen | Same as Laravel but may need manual DI. |
| Symfony Components | Works if using Symfony’s HTTP kernel. |
| gRPC vs HTTP/JSON | gRPC preferred; HTTP/JSON has higher latency. |
10% of traces) to reduce overhead during ramp-up.open-telemetry/exporter-otlp for breaking changes (e.g., OTLP spec updates).^8.1) to avoid compatibility drift..env) for easy updates.otel-cli to inspect spans.dd() may not work in async contexts; use structured logging instead.1:10) to limit trace volume at scale.traceparent header) is preserved.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| OTLP Backend Unavailable | Traces lost; no observability. | Local logging fallback (exporters: [logging]). |
| gRPC Connection Drops | HTTP/JSON fallback required. | Configure retry logic in exporter. |
| High Trace Volume | Backend throttling/errors. | Implement sampling early. |
| Context Corruption | Broken distributed traces. | Test with otel-baggage headers. |
| Laravel Cache Issues | Trace IDs not propagated. | Use Symfony\Component\HttpFoundation\Request directly. |
How can I help you explore Laravel packages today?