← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

PHP Observability

Observability PHP 8.0+ Intermediate
debt(d9/e5/b5/t7)
d9 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'silent in production until users hit it' (d9), detection_hints.automated is no — missing observability is invisible until incidents occur; no linter flags absence of OpenTelemetry/Datadog instrumentation.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5), quick_fix suggests OpenTelemetry auto-instrumentation which is relatively easy, but adding correlation IDs, structured logging, and metric labels across the app is a multi-file effort.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5), applies to web/cli/queue-worker contexts — observability tooling becomes load-bearing across the codebase, but it's additive infrastructure rather than defining system shape.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap' (t7), misconception that error logs are sufficient contradicts the three-pillars model (metrics/traces/logs) — devs from log-only backgrounds reliably guess wrong about what's needed for production visibility.

About DEBT scoring →

Also Known As

Monolog OpenTelemetry PHP PHP metrics PHP tracing

TL;DR

The three pillars of observability in PHP applications — structured logs, application metrics, and distributed traces — and the tools that provide them (Monolog, Prometheus, OpenTelemetry).

Explanation

PHP observability toolkit: Logs (Monolog with structured JSON handlers — Loki, Elasticsearch, Datadog), Metrics (prometheus/client_php — expose /metrics for Prometheus scraping; StatsD for push-based metrics), Traces (opentelemetry-php or Datadog ddtrace auto-instrumentation — distributed tracing across services). PHP-specific considerations: PHP-FPM process-per-request model means metrics must persist across requests (shared memory via APCu or push to StatsD). Correlation IDs: generate a UUID per request, pass it in all log entries and outgoing HTTP headers — enables correlating logs, metrics, and traces for a single request.

Common Misconception

Error logs are sufficient for production observability — error logs show what broke but not why or when degradation started; metrics show trends, traces show the critical path, and logs add context — all three are needed.

Why It Matters

A PHP application with only error logs cannot answer: is response time increasing? Which endpoint is slowest? When did performance degrade? Metrics and traces answer these questions that logs cannot.

Common Mistakes

  • No correlation IDs — cannot connect related events across log lines and services.
  • Logging without structure — plain text logs cannot be queried for specific fields.
  • Metrics without labels — unlabelled counters cannot distinguish between endpoints.
  • No request duration histogram — cannot calculate p95/p99 latency without it.

Code Examples

✗ Vulnerable
// Plain text logs — unsearchable:
error_log('Error processing order ' . $id . ' for user ' . $userId);
// Cannot query: all errors for user 42
// Cannot correlate with database traces
// Cannot alert when error rate exceeds threshold
✓ Fixed
// Structured observability:
// 1. Structured logging:
$logger->error('order.processing.failed', [
    'order_id'    => $id,
    'user_id'     => $userId,
    'trace_id'    => $this->traceId,
    'duration_ms' => $elapsed,
]);

// 2. Metrics:
$counter->labels(['endpoint' => 'checkout', 'status' => '500'])->inc();
$histogram->labels(['endpoint' => 'checkout'])->observe($duration);

// 3. Trace propagation:
$span = $tracer->spanBuilder('order.process')->startSpan();
$span->setAttribute('order.id', $id);
finally { $span->end(); }

Added 16 Mar 2026
Edited 22 Mar 2026
Views 81
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 1 ping W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 1 ping F 0 pings S 5 pings S 5 pings M 0 pings T 1 ping W 0 pings T 2 pings F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Amazonbot 10 Scrapy 9 Google 5 ChatGPT 4 Perplexity 3 Ahrefs 3 SEMrush 3 Unknown AI 2 Claude 2 Bing 1 Meta AI 1 PetalBot 1
crawler 40 crawler_json 4
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Instrument PHP with the OpenTelemetry auto-instrumentation package — it adds traces for HTTP, PDO, Redis, and queue calls with zero code changes
📦 Applies To
PHP 8.0+ web cli queue-worker laravel symfony
🔗 Prerequisites
🔍 Detection Hints
No APM tracing on PHP app; only infrastructure metrics no request-level visibility; slow requests hard to diagnose without traces
Auto-detectable: ✗ No opentelemetry datadog newrelic tideways
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: Medium Context: File


✓ schema.org compliant