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

APM — Application Performance Monitoring

observability PHP 7.0+ Intermediate

TL;DR

APM tools (Datadog, New Relic, Blackfire) automatically instrument applications to profile code-level performance — identifying slow DB queries, N+1 problems, and method-level bottlenecks.

Explanation

APM = auto-instrumentation + profiling + transaction tracing in one product. Unlike OpenTelemetry (code instrumentation), APM agents install at the PHP extension level and instrument automatically. Capabilities: distributed traces, code-level profiling (which PHP function is slow?), DB query analysis (N+1 detection), external service latency, error tracking. PHP APM: Datadog APM (ddtrace extension), New Relic (newrelic extension), Blackfire (profiler, not APM), Elastic APM (PHP agent). SaaS vs self-hosted: Datadog/New Relic are SaaS (expensive), Elastic/Jaeger are self-hosted. APM complements OpenTelemetry — many APMs now export OTLP.

Common Misconception

APM replaces logging and metrics — APM adds profiling and transaction tracing. You still need logs (for content) and metrics (for aggregate trends).

Why It Matters

APM cuts debugging time from hours to minutes for performance issues — seeing exactly which SQL query took 2s is faster than manually adding timing logs.

Common Mistakes

  • No APM in production — only monitoring in dev.
  • High APM overhead without sampling — some APMs add 5-10% overhead.
  • Not configuring APM sampling — 100% trace rate is expensive.

Code Examples

✗ Vulnerable
// Manually timing every operation:
$start = microtime(true);
$result = $pdo->query($sql);
$duration = microtime(true) - $start;
Log::info('Query time', ['ms' => $duration * 1000]);
✓ Fixed
// Datadog APM — auto-instruments PDO:
// Install: composer require datadog/dd-trace-php
// PHP ext: dd-trace.so
// All PDO queries automatically traced with query, duration, error
// Dashboard shows slow queries, N+1 patterns, error traces
// Zero code changes required

Added 23 Mar 2026
Edited 5 Apr 2026
Views 26
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 1 ping S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 2 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T
No pings yet today
No pings yesterday
Perplexity 8 Amazonbot 6 Google 3 Unknown AI 2 Ahrefs 2 ChatGPT 1
crawler 20 crawler_json 1 pre-tracking 1
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Install APM agent (Datadog/New Relic extension for PHP). Configure sampling rate. Set up dashboards for slow queries and error traces. Review weekly for N+1 patterns.
📦 Applies To
PHP 7.0+ web cli Laravel Symfony
🔗 Prerequisites
🔍 Detection Hints
Auto-detectable: ✗ No datadog newrelic blackfire
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Medium Context: File

✓ schema.org compliant