OpenTelemetry for PHP

OpenTelemetry for PHP allows you to instrument your Laravel, Symfony, and custom PHP applications. The libraries support generating spans, traces, and sending data via OTLP.

Installation

Install the required PHP packages via Composer:

composer require open-telemetry/opentelemetry 
composer require open-telemetry/exporter-otlp

For full installation instructions:
👉 OpenTelemetry PHP Getting Started

Auto-Instrumentation

Auto-instrumentation lets you automatically trace common libraries such as HTTP clients, database drivers, and more without needing to modify your code. OpenTelemetry provides auto-instrumentation libraries for many popular languages, making it fast to get started with tracing.

OpenTelemetry PHP currently focuses on manual instrumentation, but there are some framework-specific community efforts (e.g., Laravel).

Future releases will bring more auto-instrumentation.

Manual Instrumentation

Manual instrumentation gives you full control over your traces, allowing you to create spans wherever needed. You can customize span names, attributes, and relationships to capture the most important parts of your application’s flow.

You can manually create spans in PHP:

use OpenTelemetry\API\Trace\TracerProvider;
$tracerProvider = TracerProvider::getDefaultTracerProvider(); $tracer = $tracerProvider->getTracer('my-service');
$span = $tracer->spanBuilder('my-operation')->startSpan(); // your application logic $span->end();

Learn more:
👉 PHP Manual Instrumentation Guide

Exporters

Once your application is instrumented, you need to export telemetry data. PlayerZero supports the OpenTelemetry Protocol (OTLP) over HTTP. You can configure your OpenTelemetry SDK to export traces, logs, and metrics to PlayerZero’s endpoint by setting the endpoint URL and API token.

Set the OTLP exporter environment variables or configure directly in code:

OTEL_EXPORTER_OTLP_ENDPOINT=https://sdk.playerzero.app/otlp 
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer <your-playerzero-token> 
OTEL_TRACES_EXPORTER=otlp 
OTEL_LOGS_EXPORTER=otlp 
OTEL_METRICS_EXPORTER=otlp

Official reference:
👉 PHP SDK Configuration

Optional: Using a Collector

Using an OpenTelemetry Collector is optional for most setups. A collector can help route telemetry to multiple destinations, perform transformations, or batch data efficiently. You might use a collector if you want to forward telemetry to both PlayerZero and another observability platform simultaneously.

You can optionally forward telemetry through a collector for more advanced control over routing and transformation before reaching PlayerZero.

For detailed language-specific instrumentation examples and full OpenTelemetry documentation, refer to the links below.