[ GLOSSARY ]

OpenTelemetry in Laravel

QUICK ANSWER

What is OpenTelemetry and how do I use it in Laravel?

OpenTelemetry (OTel) is a vendor-neutral specification and SDK suite for emitting traces, metrics, and logs. In Laravel, install open-telemetry/sdk + an OTLP exporter, configure a tracer, and ship spans to an OTel Collector that forwards to your backend of choice (Tempo, Jaeger, SigNoz, Datadog, Honeycomb). Use OTel when portability or polyglot tracing matters. For Laravel-specific depth, the Nightwatch package (used by Nightwatch Cloud and NightOwl) captures framework context OTel's generic instrumentation doesn't.

Updated · 2026-04-13

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. Still stabilizing across the ecosystem.

Setting up OTel in Laravel

bash
composer require \
    open-telemetry/sdk \
    open-telemetry/exporter-otlp \
    open-telemetry/sem-conv

app/Providers/TelemetryServiceProvider.php

php
use OpenTelemetry\API\Globals;
use OpenTelemetry\Contrib\Otlp\SpanExporter;
use OpenTelemetry\SDK\Common\Export\Http\PsrTransportFactory;
use OpenTelemetry\SDK\Trace\SpanProcessor\BatchSpanProcessor;
use OpenTelemetry\SDK\Trace\TracerProvider;
use OpenTelemetry\SDK\Resource\ResourceInfo;
use OpenTelemetry\SDK\Resource\ResourceInfoFactory;
use OpenTelemetry\SemConv\ResourceAttributes;

public function register(): void
{
    $transport = (new PsrTransportFactory())->create(
        'http://localhost:4318/v1/traces', 'application/x-protobuf'
    );
    $exporter = new SpanExporter($transport);

    $resource = ResourceInfoFactory::defaultResource()->merge(
        ResourceInfo::create(Attributes::create([
            ResourceAttributes::SERVICE_NAME => config('app.name'),
            ResourceAttributes::DEPLOYMENT_ENVIRONMENT => config('app.env'),
        ]))
    );

    $tracerProvider = TracerProvider::builder()
        ->addSpanProcessor(new BatchSpanProcessor($exporter))
        ->setResource($resource)
        ->build();

    Globals::registerInitializer(fn () => $tracerProvider);
}

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 portability at the cost of Laravel depth.
  • Nightwatch: Laravel-specific, framework-aware, captures Eloquent patterns, 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.

Frequently asked questions

What is OpenTelemetry?

An open-source, vendor-neutral specification and SDK suite for emitting traces, metrics, and logs. It decouples instrumentation (the SDK in your app) from the backend (Jaeger, Tempo, Datadog, Honeycomb, etc.) — you can switch backends without re-instrumenting. Often abbreviated OTel.

Does Laravel support OpenTelemetry?

Yes, via the open-telemetry/sdk PHP package. There's no official Laravel OTel bundle yet — you install the base SDK, a tracer, and an exporter, then either manually instrument or use auto-instrumentation via PHP's opentelemetry extension. Setup is 3-5 composer packages plus config; functional but more manual than single-vendor Laravel SDKs.

When should I use OpenTelemetry instead of a vendor SDK?

Pick OTel when: (1) you want to switch observability vendors without re-instrumenting, (2) you're polyglot and want one spec across services, (3) you want to ship to multiple backends simultaneously (e.g., Tempo for traces + Prometheus for metrics). Pick a vendor SDK when: (1) you're committed to one platform anyway, (2) the vendor ships a better Laravel-first integration.

What's OTLP?

OpenTelemetry Protocol — the wire format OTel SDKs use to send telemetry. Usually over gRPC (binary, efficient) or HTTP/protobuf. Most modern trace backends (Tempo, Jaeger 1.35+, SigNoz, Honeycomb, Datadog) accept OTLP natively. That interoperability is the whole point.

Is NightOwl built on OpenTelemetry?

No. NightOwl is built on laravel/nightwatch, the official Laravel instrumentation package. Nightwatch is Laravel-specific — it captures framework-aware context (controllers, Eloquent query patterns, queue jobs, cache events) that generic OTel instrumentation doesn't see as cleanly. Different design tradeoff: less portability, more Laravel depth.

Can I run OpenTelemetry alongside Laravel Nightwatch?

Yes. They don't conflict. OTel emits its own spans; Nightwatch emits Laravel-specific records. Most teams doing multi-service architectures run both — OTel for cross-service traces, Nightwatch for deep Laravel-native monitoring within the Laravel app. Pick one to be the primary dashboard.

How do I get started with OpenTelemetry in Laravel?

composer require open-telemetry/sdk open-telemetry/exporter-otlp open-telemetry/sem-conv. Register a tracer in a service provider with your app.name and environment. Start an OTel Collector (Docker Compose) to receive spans and forward to your backend. Instrument critical paths manually at first; adopt auto-instrumentation (via the opentelemetry PECL extension) once you've seen value. See the official OTel PHP docs.

PRICING

Flat pricing. No event caps. No per-seat fees.

14-day free trial, no credit card. Your PostgreSQL, your data.

HOBBY

$5 /month

1 app · 14 days lookback · all Laravel events

TEAM

$15 /month

Up to 3 connected apps · unlimited environments · all Laravel events

AGENCY

$69 /month

Unlimited apps · unlimited agent instances · same flat rate at any traffic