OpenTelemetry is the closest thing observability has to a standard, and like most standards it's verbose and easy to over-adopt. For a Laravel team the useful question isn't "is OTel good" (it is) but "is it the right tool for the part of the system I'm instrumenting." For a single Laravel app the answer is often no; at a boundary between services it's often yes.
The pitch
Before OTel, every APM vendor had its own SDK. Switching vendors meant rewriting instrumentation. OTel decouples: your code emits OTel spans, a Collector forwards them to whatever backend you want. Today that might be Tempo; tomorrow Honeycomb; ten years from now, something not yet invented. Your instrumentation doesn't change.
The three pillars
- Traces: request waterfalls across services. The most mature OTel pillar.
- Metrics: counters, gauges, histograms. Solid but newer than tracing.
- Logs: structured log records with trace correlation. Stable in the PHP SDK, though support still varies across other languages.
Setting up OTel in Laravel
composer require \
open-telemetry/sdk \
open-telemetry/exporter-otlp \
open-telemetry/sem-conv use OpenTelemetry\API\Trace\Propagation\TraceContextPropagator;
use OpenTelemetry\Contrib\Otlp\OtlpHttpTransportFactory;
use OpenTelemetry\Contrib\Otlp\SpanExporter;
use OpenTelemetry\SDK\Common\Attribute\Attributes;
use OpenTelemetry\SDK\Resource\ResourceInfo;
use OpenTelemetry\SDK\Resource\ResourceInfoFactory;
use OpenTelemetry\SDK\Sdk;
use OpenTelemetry\SDK\Trace\SpanProcessor\BatchSpanProcessorBuilder;
use OpenTelemetry\SDK\Trace\TracerProvider;
use OpenTelemetry\SemConv\Attributes\DeploymentAttributes;
use OpenTelemetry\SemConv\Attributes\ServiceAttributes;
public function register(): void
{
$transport = (new OtlpHttpTransportFactory())->create(
'http://localhost:4318/v1/traces', 'application/x-protobuf'
);
$exporter = new SpanExporter($transport);
$resource = ResourceInfoFactory::defaultResource()->merge(
ResourceInfo::create(Attributes::create([
ServiceAttributes::SERVICE_NAME => config('app.name'),
DeploymentAttributes::DEPLOYMENT_ENVIRONMENT_NAME => config('app.env'),
]))
);
$tracerProvider = TracerProvider::builder()
->addSpanProcessor((new BatchSpanProcessorBuilder($exporter))->build())
->setResource($resource)
->build();
Sdk::builder()
->setTracerProvider($tracerProvider)
->setPropagator(TraceContextPropagator::getInstance())
->setAutoShutdown(true)
->buildAndRegisterGlobal();
} Run an OTel Collector alongside your app. Forward spans to Tempo, Jaeger, SigNoz, or any SaaS vendor that speaks OTLP.
OTel vs Nightwatch (Laravel's first-party package)
- OTel: vendor-neutral, polyglot, generic. You get portability at the cost of Laravel depth.
- Nightwatch: Laravel-specific, framework-aware, captures queries grouped by SQL, queue job classes, scheduled tasks with minimal code. Not portable to non-Laravel services.
A common split: use the Nightwatch package (via NightOwl or Nightwatch Cloud) for Laravel-native monitoring; add OTel only at service boundaries where you need cross-service traces.