Skip to content

Observability in practice: logs, metrics and traces with OpenTelemetry, percentiles, sampling and SLOs

The difference between monitoring and observing, how to tie logs, metrics and traces together by trace_id with OpenTelemetry in a Node app, percentiles, cardinality, sampling, SLOs and where to store it all.

Ramon Gomes 12 min read Level: Intermediate

Also available in: Español, Français, Português

It's 3 a.m. and the alert goes off: "error rate above 5%". You open the dashboard and see the red chart. Now what? Which customer, which route, which service, since when, why? If the answers require adding a console.log and deploying, the system is monitored, but it isn't observable.

This article explains the signals, how to wire them up with OpenTelemetry in a Node app, the concepts that confuse people most (percentiles, cardinality, sampling) and the open source and SaaS tools to store it all. Versions checked on November 21, 2026.

Mechanic plugging a diagnostic scanner into the port under a car's dashboard in a repair shop, with the device screen showing charts
The dashboard light warns about what someone predicted. The scanner lets you ask about what nobody predicted.

Monitoring and Observability

Charity Majors, cofounder of Honeycomb, puts it this way: "Monitoring is about known-unknowns and actionable alerts"; "observability is about unknown-unknowns and empowering you to ask arbitrary new questions".

The car analogy helps. The oil light on the dashboard is monitoring: someone predicted the oil could run out and added a light. The scanner the mechanic plugs in under the steering wheel is observability: it lets you investigate a noise nobody predicted.

You need both. The alert wakes you up; observability tells you what to do.

The Signals

Signal What it is Question it answers
Log A timestamped record of an event "What happened to order 42?"
Metric A number measured over time "How many requests per second? How many errors?"
Trace The path of a request, split into spans (each step) "Where did the 3 seconds of this request go?"
Profile Where the code spends CPU and memory, line by line "Which function is eating the CPU?"

Profiling landed in OpenTelemetry as a public alpha in March 2026, and the project itself warns it's not ready for critical production use yet. The first three are what matters today.

Traces: Following a Request

In a system with several services, a request goes through the frontend, the APIContract that defines how one program asks another for data or actions: which endpoints to call, what to send and what comes back. On the web, usually HTTP with JSON., a queue, a worker and the database. The trace puts it all on a single timeline.

An isometric journey with a Front phone, API rack, message queue and cylindrical database, connected by arrows and tagged with traceparent. The waterfall below shows four spans from 0 to 2.4 s; the database has the longest bar, at 1740 ms.
Each service passes the tag along. At the end, the waterfall shows where the time went.

The trick is an HTTP header standardized by the W3C, traceparent, which each service forwards to the next:

text
traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
             │  │                                │                └ sampled (01 = yes)
             │  │                                └ id of the calling span
             │  └ trace id (the same from start to finish)
             └ version

It's like a package tracking number: each carrier logs its own leg, but they all use the same number. With instrumentation libraries, you don't even see this header; it gets passed along on its own.

OpenTelemetry: The Standard That Brought Everyone Together

Before, each vendor (Datadog, New Relic, Honeycomb) had its own agent and format. Switching tools meant reinstrumenting the whole codebase. OpenTelemetry (OTel) solved this with open APIs, SDKs and a protocol (OTLP). You instrument once and send the data wherever you want. The project graduated at the CNCF on May 11, 2026.

Flow from an app with the OTel SDK over OTLP on port 4318 to the Collector, which filters and batches. Arrows route logs to Loki, metrics to Prometheus and traces to Tempo; all three destinations converge on Grafana.
Instrument once, send it anywhere.

Main pieces:

  • SDK inside the app: generates the signals.
  • Automatic instrumentation: creates spans for HTTP, Express, the database, Redis and dozens of libraries without you writing anything.
  • Collector (optional): receives, filters, batches and forwards. The documentation says that to get started, or at small scale, you can send straight from the app to the backend.
  • OTLP: the protocol, on port 4317 (gRPC) or 4318 (HTTP).

Maturity varies by language. In JavaScript and Python, traces and metrics are stable, and logs are still in development. In Java and .NET, all three are stable.

Wiring It Up in Node

sh
npm install @opentelemetry/sdk-node @opentelemetry/api \
  @opentelemetry/auto-instrumentations-node \
  @opentelemetry/exporter-trace-otlp-http
ts
// instrumentation.ts
import { NodeSDK } from '@opentelemetry/sdk-node';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';

const sdk = new NodeSDK({
  serviceName: 'orders-api',
  traceExporter: new OTLPTraceExporter(), // default: http://localhost:4318/v1/traces
  instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
sh
node --import ./instrumentation.mjs dist/app.js

The detail the documentation stresses: the instrumentation has to load before the app, hence the --import. If you import it inside the code, the libraries have already loaded without the "listener".

Structured, Correlated Logs

Free-text logs ("Error processing order 42") are great to read and terrible to search. A structured log is JSON, with fields you can filter on:

ts
import pino from 'pino';
const log = pino();

log.info({ orderId: 42, total: 120.0 }, 'order created');

With OpenTelemetry on, the pino instrumentation injects the trace_id and span_id into every line by itself:

json
{"level":30,"time":1763740800000,"orderId":42,"msg":"order created","trace_id":"d61b4e4af1032e0aae279d12f3ab0159","span_id":"d140da862204f2a2","trace_flags":"01"}
A pino log card with orderId 42, an order-created message, trace_id and span_id. An arrow links the log to the matching trace waterfall, where orders.create is highlighted as the span that produced the log.
From log to trace in one click. That's what ties the signals together.

This is the turning point. Without the trace_id, you have thousands of loose lines and have to guess which ones belong to the same request. With it, the log points to the trace, and the trace shows every log from that request.

Watch out for personal data: structured logging makes it easy to write the whole user object without noticing. Log IDs, not emails, Social Security numbers or tokens.

Metrics: What to Measure

Three well-known recipes, each for one kind of thing:

Method For what What to measure
RED (Tom Wilkie) Services (APIs) Rate, Errors, Duration
USE (Brendan Gregg) Resources (CPU, disk, queue) Utilization, Saturation, Errors
Four golden signals (Google SRE) Both Latency, traffic, errors, saturation

For an API, start with RED per route: how many requests, how many failed and how long they took.

Why Average Latency Misleads

Google's SRE book is blunt: "the idea that most of your requests are near the mean is just hopeful thinking".

Illustrative latency histogram from 0 to 1200 ms, with most requests on the left and a long tail on the right. The mean is marked at 240 ms; pills show p50 at 225 ms, p95 at 525 ms and p99 at 1075 ms.
The average stays put. The p99 shows who really waited.

Picture the line at the bank: 9 people wait 1 minute and 1 person waits 60. The average comes out to almost 7 minutes, a wait nobody actually had. The p50 (median) shows the typical case; the p99 shows the plausible worst case, the customer who walked out annoyed. And in systems with many services, the p99 of a backend service becomes the common experience of the frontend service, because each page calls several of them.

That's why you measure latency with a histogram and look at percentiles.

Cardinality: The Expensive Mistake

Each different combination of a metric's labels becomes a separate time series. The Prometheus documentation explicitly rules out high-cardinality labels, such as user IDs and email addresses.

Two panels compare five series, one per route, with adding user_id: drawn users, a dense set of lines and 12,480 active series. Below, a cylindrical database and a bill flank a bar exceeding the 10,000 limit, with a warning.
One user ID label turns 5 series into thousands.
ts
// Good: few combinations (route x method x status)
counter.add(1, { route: '/orders/:id', method: 'GET', status: 200 });

// Bad: one series per user
counter.add(1, { route: '/orders/:id', user_id: '8f2c...' });

On top of weighing on the metrics database, it hits your wallet: Grafana Cloud's free plan, for example, is measured in 10,000 active series. If you need to know "which user", that information goes in the trace or the log, not the metric. And use the route with the parameter (/orders/:id), not the URL with the ID inside.

Sampling: You Can't Keep Everything

A high-traffic system generates too many traces to keep them all. The way out is sampling:

  • Head sampling: decides at the start, at random (e.g., 10% of traces). Simple and cheap, but it can throw away exactly the trace with the error.
  • Tail sampling: waits for the trace to finish and decides based on the result (keeps every error, every slow trace and a sample of the rest). More useful, but it requires holding the spans in memory in the Collector until it decides.
Two cards compare head and tail sampling. Head decides at the start, with a 10% label, and loses an error. Tail waits in the Collector and keeps the error, a slow trace and some normal traces. Arrows separate kept and dropped traces, identified by icons.
Picking at random at the start can throw away the error. Deciding at the end keeps what matters.
yaml
# Collector: keep every slow trace and 10% of the rest
processors:
  tail_sampling:
    decision_wait: 10s
    policies:
      - name: slow
        type: latency
        latency: { threshold_ms: 5000 }
      - name: sample
        type: probabilistic
        probabilistic: { sampling_percentage: 10 }

If you're just starting out with little traffic, keeping everything usually fits in a free plan. Sampling becomes a topic when the bill starts to grow.

SLO: When to Alert

Alerting on "CPU above 80%" wakes people up over things the user never even noticed. Google's SRE book suggests alerting on what the user feels:

  • SLI: the measure ("percentage of requests answered in under 300 ms").
  • SLO: the target ("99% over 30 days").
  • SLA: the contract with the customer, with consequences if it's not met.

The gap between 100% and the SLO is the error budget. While there's budget left, the team can take risks with deploys; when it's running out, stability becomes the priority. And the alert fires when the budget is being burned too fast, not on every isolated spike.

Where to Store It: Tools

Open source (to host yourself):

Tool Role Version
Prometheus Metrics 3.16
Loki Logs 3.7
Tempo or Jaeger Traces 3.1 / 2.23
Grafana Dashboards and alerts 13.3
SigNoz, Uptrace All in one, OpenTelemetry native 0.151 / 2.1

A heads-up if you're following an old tutorial: Jaeger 1 reached end of life on December 31, 2025. Jaeger 2 is a distribution of the OpenTelemetry Collector itself, and the old jaeger-agent no longer exists.

SaaS with a free plan (checked on the pricing pages):

Service Free plan
Grafana Cloud 10k metric series, 50 GB of logs, 50 GB of traces per month, 14-day retention
New Relic 100 GB of ingest per month, 1 full user
Honeycomb 20 million events per month
Sentry 5k errors and 5 million spans per month, 1 user

With OpenTelemetry, switching from one to another means changing the exporter's endpoint.

Cartoon of a person searching for a needle in a giant haystack made of printed sheets of log lines, while another person next to them uses a magnet labeled with a code and pulls the needle straight out
A log without a trace_id is a haystack. With a trace_id, it's a magnet.

Quick check

1. What sets observability apart from monitoring?
Show answer

Answer: Observability lets you ask new questions without changing the code

Monitoring covers what you predicted. Observability helps with what you didn't.

2. Why not use a user ID as a metric label?
Show answer

Answer: Because each different value creates a new series, and the number of series explodes

That information goes in the trace or the log.

3. What's the advantage of tail sampling over head sampling?
Show answer

Answer: It decides after seeing the whole trace, so it can keep all the errors and slow ones

The price is holding the spans in memory until the decision.

Frequently Asked Questions

Do I need the Collector?

Not to get started. It's worth it when you want to switch destinations without touching the apps, filter sensitive data, sample at the end or send to several places.

Is Sentry observability?

It started with error tracking and today it also does traces and performance. For many small projects, Sentry plus a metrics dashboard already covers a lot.

Is observability expensive?

It can be, mostly with too many logs and high-cardinality metrics. Logs at the right level, metrics with few labels and sampling keep the bill under control.

What about background jobs?

The same applies to them, plus one detail: a job that didn't run produces no error at all. The scheduled jobs article shows the dead man's switch for that.

Does a monolith need tracing?

It helps less than with microservices, but it still shows how long each database query and each external call took inside a request. The article on modular monolith vs. microservices discusses when to split.

References

Checked on November 21, 2026:

Source: https://ramongomessilva.com.br/blog/observability-in-practice · Accessed on December 02, 2026

Share Share on LinkedIn Share on X
Cite this article

Ready-made reference, with today as the access date.

ABNT

Brazilian standard (NBR 6023). Use it in theses and academic papers submitted in Brazil.

GOMES, Ramon. Observability in practice: logs, metrics and traces with OpenTelemetry, percentiles, sampling and SLOs. Ramon Gomes, 1 dez. 2026. Disponível em: https://ramongomessilva.com.br/blog/observability-in-practice. Acesso em: 2 dez. 2026.

APA

American Psychological Association style. Common in scientific papers and journals, especially in the social, behavioral and health sciences.

Gomes, R. (2026, December 1). Observability in practice: logs, metrics and traces with OpenTelemetry, percentiles, sampling and SLOs. Ramon Gomes. https://ramongomessilva.com.br/blog/observability-in-practice

BibTeX

Format for LaTeX users (Overleaf, for example). Paste it into your .bib file or import it into Zotero or Mendeley.

@online{gomes2026observabilityinpractice,
  author = {Gomes, Ramon},
  title = {{Observability in practice: logs, metrics and traces with OpenTelemetry, percentiles, sampling and SLOs}},
  organization = {Ramon Gomes},
  year = {2026},
  month = dec,
  date = {2026-12-01},
  url = {https://ramongomessilva.com.br/blog/observability-in-practice},
  urldate = {2026-12-02}
}
Found a mistake?

Wrong fact, broken link, outdated information: tell me and I will fix it.

10 to 2,000 characters. If you can, point to the right source.

Only so I can reply. It never shows on any page of the site.

Written by

Ramon Gomes

Software Engineer

Full stack software engineer. I like taking a messy problem, listening to the people who live with it and shipping something that holds up day to day. These days I split my time between my own products, applied AI and client work.

Available for projects

Need Something Like This Built?

I build websites, systems, apps and AI automations, from design to deploy. Tell me what you need or see what I offer.

Related Articles