APM
Application Performance Monitoring
Application performance monitoring. Tracks response time, error rate, and transactions. Datadog, New Relic.
Application Performance Monitoring
Application performance monitoring. Tracks response time, error rate, and transactions. Datadog, New Relic.
APM (Application Performance Monitoring) is a tool that tracks and analyzes application performance in real time. Going beyond simple server monitoring, it traces where and how much time each individual request spends, from DB queries to external API calls. When an incident occurs, it lets you pinpoint exactly "what is slow," greatly reducing MTTR (Mean Time To Recovery).
The core features are three: distributed tracing, metric collection, and error tracking. Distributed tracing visualizes the flow of a single request passing through multiple services in a microservices environment. With a Trace ID, you can tell that "this request passed through service A -> service B -> service C, took 2.3 seconds in total, and spent 1.8 seconds in B."
Representative APM tools include the commercial services Datadog APM, New Relic, and Dynatrace, and the open-source options Jaeger, Zipkin, and Elastic APM. In cloud environments, native services such as AWS X-Ray and GCP Cloud Trace are also widely used. The selection criteria are agent overhead, sampling policy, cost, and whether it integrates with the existing monitoring stack.
When you adopt APM in practice, instead of a vague complaint that "it's slow," data-driven discussion becomes possible, such as "P99 response time exceeded 2 seconds, and the cause was Redis connection pool exhaustion." If you also set up SLO (Service Level Objective) targets and alert integration, you can respond proactively before users feel any inconvenience.
# OpenTelemetry๋ก APM ํธ๋ ์ด์ฑ ๊ตฌํ (Python/FastAPI)
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from opentelemetry.instrumentation.requests import RequestsInstrumentor
from fastapi import FastAPI
import requests
# ํธ๋ ์ด์ ์ค์
provider = TracerProvider()
processor = BatchSpanProcessor(OTLPSpanExporter(endpoint="http://otel-collector:4317"))
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
tracer = trace.get_tracer(__name__)
app = FastAPI()
# FastAPI ์๋ ๊ณ์ธก
FastAPIInstrumentor.instrument_app(app)
RequestsInstrumentor().instrument()
@app.get("/api/orders/{order_id}")
async def get_order(order_id: str):
# ์ปค์คํ
์คํฌ์ผ๋ก ์ธ๋ถ ๊ตฌ๊ฐ ์ธก์
with tracer.start_as_current_span("fetch_order_details") as span:
span.set_attribute("order.id", order_id)
# DB ์กฐํ (์๋ ๊ณ์ธก๋จ)
order = await fetch_from_db(order_id)
# ์ธ๋ถ API ํธ์ถ ์ถ์
with tracer.start_as_current_span("call_payment_service"):
payment = requests.get(f"http://payment-svc/orders/{order_id}")
span.set_attribute("order.total", order["total"])
return {"order": order, "payment": payment.json()}
Senior: "There was a P99 latency spike last night. Did you check the APM traces?"
Junior: "Yes, I checked, and DB connection timeouts occurred intensively in the payment service."
Senior: "Then raise the sampling rate, pull more traces for that time window, and compare them with the slow query log."
Interviewer: "How do you debug performance issues in a microservices environment?"
Candidate: "I use APM's distributed tracing feature. I follow the entire request flow with the Trace ID and check with a waterfall chart which segment of which service the delay occurs in. It was especially effective for tail latency analysis such as P99."
Take a mock interview on this topic โ WIA SOOM AI Interview ยท Start for free
Reviewer: "Please add a custom span to this external API call. To track the performance of this segment later, it needs to be shown separately in APM."
Author: "Yes, I'll add the span and also attach attributes like vendor and endpoint so it can be filtered."