Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 1 of 6 · Concept · 15 min · revision 2

Three signals and the questions each one answers

See what metrics, traces and logs each tell you about a running service and what each costs, learn the three metric types and the label trap, and see how shared trace IDs let you move from a symptom on a graph to the request and the reason behind it.

Contentsand lesson path

What you will learn

  • Instrument a service with OpenTelemetry so it emits structured logs, request metrics and distributed traces that share correlation IDs.
  • Use logs, metrics and traces together to localize a latency or error regression to a specific component.

01. Why it matters

Your service answers questions by calling a search index and a hosted model. One morning users report that answers have become slow, but only sometimes. The process is up, CPU looks normal and nothing has crashed. Checks for known failure conditions, which is what monitoring in the narrow sense means, all say that everything is fine.

What you need is to ask new questions of the running system: which requests are slow, since when, in which step, and why. A system is observable when its telemetry lets you answer such questions without shipping new code first. Three kinds of telemetry carry most of the load, metrics, traces and logs, and each is good at one kind of question. The example service calls a language model, but nothing here is specific to AI.

02. Three signals, three questions

  • Metrics answer how much, how often, and is it getting worse? A metric is a number aggregated over time, such as requests per second, the share that failed or how long they took, stored as one time series per combination of labels. Aggregation makes metrics cheap to keep for months and fast to query, so they drive dashboards and alerts. The price is detail: a metric says that 3% of /ask requests failed, not which ones or why.
  • Traces answer where did the time go in this request? A trace follows one request through every service it touches. Each timed step is a span with a name, a start time, a duration, attributes and a parent, so the spans form a tree. Traces localise a problem to a component; busy systems often keep only a sample of them.
  • Logs answer what exactly happened, and why? A log record is one event with whatever context the code chose to write: an error, a retry, a cache miss. Logs carry the reason, but cost the most per event and are hard to query unless they are structured, written as fields rather than free text.

Here is one slow request to the example service, seen through each signal.

Metric · one series of the request-duration histogram
http.server.request.duration   histogram, seconds   (service: ask-api)
labels  http.route=/ask  http.request.method=POST  http.response.status_code=200

last 5 minutes   count 2,940   sum 970.4 s
buckets (cumulative)   <=0.1 s: 312   <=0.25 s: 2,281   <=0.5 s: 2,355
                       <=1 s: 2,905   <=+Inf: 2,940
Trace · the same kind of request as a tree of spans
trace 5d7698e2...                                     duration
ask-api       POST /ask                               1,121.7 ms
ask-api         GET  (client call to search-stub)       961.3 ms
search-stub       GET /search                           824.8 ms
ask-api         chat claude-sonnet-5                    152.4 ms
ask-api           POST (client call to model-stub)      144.4 ms
model-stub          POST /v1/messages                   121.8 ms
Log · one structured record written during that trace
{
  "ts": "2026-10-19T07:26:06.995+00:00",
  "level": "WARNING",
  "service": "search-stub",
  "msg": "index segment not cached, reading from disk",
  "segment": 2,
  "trace_id": "5d7698e27bf49ae6c37070c0e53885c9",
  "span_id": "c3a54e0b19d27f86"
}

Read together, they tell the whole story. The metric shows that about one request in five now takes close to a second (only 2,355 of 2,940 finished within 0.5 s). The trace shows that the time is spent inside the search service. The log line carries the same trace ID and says why: the index read a segment from disk. You will run this investigation yourself in lesson 5.

03. Metric types, labels and cost

Most metrics come in three types:

  • A counter only goes up: requests served, tokens billed. Its raw value depends on when the process started, so you query its rate of increase; functions such as Prometheus's rate() also correct for restarts.
  • A gauge is a value that rises and falls and is read as it is: requests in flight, queue length, memory in use, free disk space.
  • A histogram sorts observations into buckets by size (durations up to 0.1 s, up to 0.25 s and so on) and keeps a count and a sum. The buckets give percentiles across many instances, and the count doubles as a request counter.

Every distinct combination of label values is its own time series. A request histogram labelled by route (10 values), method (3) and status code (8), with 15 buckets plus the count and the sum, can produce up to 10 × 3 × 8 × 17 = 4,080 series per instance. Add a user_id label for 50,000 users and the same metric can grow past 200 million series. This is cardinality, the most common way a metrics bill gets out of hand. Keep labels to small, bounded sets, such as route templates (/users/{id}, never /users/8812), and put user, prompt or response IDs on spans and logs, where they cost per event instead of per series.

Two checklists tell you which metrics to have. For each request-driven service, RED: request Rate, Errors and Duration per endpoint, which describe what users experience. For each resource, such as a CPU, a connection pool or a GPU, USE: Utilisation, Saturation (work waiting) and Errors, which help explain why a service struggles.

04. One ID across all three signals

The signals become far more useful when you can jump between them:

  1. Trace context. When a request enters a service, instrumentation starts a trace with a random 128-bit trace ID, or continues the one the caller sent. When the service calls another over HTTP, it passes the context on in a W3C traceparent header, so the downstream spans join the same trace.
  2. Trace IDs in logs. If every log record carries the active trace_id and span_id, you can pull up all log lines of one slow request across services.
  3. Exemplars. A histogram can keep, per bucket, the trace ID of a recent request that landed in it. A latency graph then shows dots that link straight to real slow traces.

OpenTelemetry (OTel) is the vendor-neutral standard that provides all three: an API your code calls, SDKs that export the data, instrumentation libraries for frameworks such as FastAPI and httpx, a wire protocol (OTLP), and the Collector, which forwards telemetry to backends such as Prometheus, Jaeger, Tempo or Loki. Its semantic conventions fix the names, such as http.route or gen_ai.usage.input_tokens, so one query works for every service.

Together the signals give you a repeatable way to localise a regression:

  1. Metrics say that something changed, when and by how much.
  2. Traces from that window, picked through exemplars, say where.
  3. Logs of those traces say why.
  4. Back to metrics to confirm that the cause explains the whole change, not one unlucky request.

05. Check your understanding

Practice check · 3 questions

Pick the right signal

Three decisions you will make when you instrument a service.

Q1. Your product manager wants to see how the share of failed /ask requests changed week by week over the last quarter. Which signal answers this most cheaply?
Q2. The request histogram from this lesson (10 routes, 3 methods, 8 status codes, 15 buckets plus the count and the sum) can produce up to 4,080 series per instance. A teammate adds a `plan` label for the customer's plan, which has 4 values: free, pro, team and enterprise. Up to how many series per instance can the metric produce now?
Q3. Which instrument fits 'number of model calls in progress right now'?
Practice only: not graded, not saved, not evidence.

06. Apply it

Choose the service you will instrument in this skill: your own, or the ask-api example built in the next lab. Write a one-page telemetry plan for it:

  • the RED metrics you need, the labels you will allow on them, and a rough count of series per instance;
  • the spans one request should produce, including every outbound call (database, search, model API), and the attributes each span carries;
  • the fields every log line will carry, including trace_id, span_id and service, and two events worth logging that no metric can show;
  • one value you will deliberately keep off metrics because of cardinality, and where it goes instead.

07. Review prompt

Without looking back, name the question each of the three signals answers best and the main cost of each. Explain the difference between a counter and a gauge, and why a histogram can stand in for a request counter. Then describe in four steps how you would get from 'p95 latency is up' to the cause, saying which signal you use at each step and what links one step to the next.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check