What Is a Metric in OpenTelemetry?
A beginner-friendly guide to the numbers your software measures about itself over time: what a metric is, how instruments record it, how it is summarised and sent, and how to keep it useful, cheap and safe.
Imagine you are driving a car on a long highway. You do not need a movie of every second of the journey to stay safe. You glance at a few simple gauges: the speedometer, the fuel level, the engine temperature. Each gauge turns something complicated into one number you can understand at a glance, and each number changes over time. If the fuel needle drops quickly, you know to stop for petrol well before the engine sputters. A metric in OpenTelemetry is exactly that kind of gauge, but for your software.
This guide starts from zero. You do not need to know what an instrument is, what a histogram is, or why anyone would summarise numbers before sending them. We will build every idea step by step, using everyday comparisons and simple pictures, until you can explain metrics to a colleague with confidence.
1The Problem: How Healthy Is My Software Right Now?
Before we define a metric, let us feel the question it answers.
Software is invisible
You cannot look at a running program and see whether it is happy. There is no smoke, no noise and no warning light. A web service might be handling ten requests a second or ten thousand. It might be using a little memory or almost all of it. It might be answering in twenty milliseconds or in twenty seconds. Unless the program tells you, you simply do not know.
Why detailed records are not always the answer
One way to understand a system is to record every single thing it does. Logs do that: they write a line for each event. Traces do something similar: they follow each request in detail. These are wonderful for investigating one particular problem. But if your shop handles a million requests an hour, reading a million log lines to answer “are we healthy?” is slow, expensive and tiring.
What you often want is a short summary: “how many requests per second?”, “how many failed?”, “what is the typical waiting time?”, “how full is the memory?”. You want a handful of numbers that update over time and can be drawn as a line on a chart. That is the job of metrics.
Think of a hospital. A doctor does not read the full diary of a patient every minute. A monitor beside the bed shows heart rate, blood pressure and oxygen level as simple numbers. If one number moves into a dangerous zone, an alarm rings, and then the doctor looks at the detailed notes. Metrics are the bedside monitor, and logs and traces are the detailed notes.
Many beginners think metrics are just “small logs”. They are not. A log records one event with text. A metric records a number, or a summary of many numbers, measured over a period. Metrics trade detail for speed, size and clarity.
2So, What Is a Metric?
A plain definition first, then the reasons behind each word.
A metric is a measurement of something about your system, captured at regular intervals and summarised so that it can be tracked over time. It is usually a number, such as a count of requests, a measure of memory used, or the time a task took, together with a few labels describing what the number refers to.
That definition has three important ideas inside it.
A measurement
A metric describes a quantity: how many, how much, how long, how full. It answers numeric questions, not “what happened” questions.
Over time
A single number is not very useful. A metric becomes powerful when the same measurement is taken again and again, so you can see trends, spikes and drops.
Summarised
Instead of sending every single measurement, metrics usually combine many measurements into a compact summary, such as a total, an average or a distribution. This keeps the cost low even at very high traffic.
Think of a school that records the temperature in the classroom every hour. One reading of 24 degrees tells you little. A whole day of readings drawn as a line shows when the room heats up, when it cools down, and whether something odd happened at lunchtime. The metric is the temperature, and the line is the story it tells over time.
3Metrics in the OpenTelemetry Family
Metrics are one of three sisters, and each sister answers a different question.
OpenTelemetry is an open-source project that provides a common way to create and send telemetry, which is data that software produces about itself. It handles three main kinds of signals, and they are designed to work together.
Metrics
Numbers over time. They answer: how healthy is the system, and is something changing?
Traces
The journey of one request through many services. They answer: where did this request spend its time?
Logs
Timestamped messages written by programs. They answer: what exactly happened at this moment?
Resource
A description of who produced the data, such as the service name and environment, shared by all three signals.
Where metrics fit in a real investigation
A typical story goes like this. A metric shows that the error rate has doubled. That tells you that something is wrong and when it started. You then open traces from that time window to see where in the system requests are failing. Finally, you read logs from the failing step to learn why. Metrics are usually the first alarm bell.
Imagine a smoke detector, a security camera and a night watchman’s notebook. The smoke detector (metric) tells you there is a problem. The camera (trace) shows where in the building. The notebook (log) explains what the watchman saw. You would not want to give up any of the three.
4The Anatomy of a Metric
Every metric is built from the same few parts.
When OpenTelemetry sends a metric, it packages it in a standard shape. Learning these parts helps you read any metric from any system.
Name
A short label that says what is measured, such as the number of requests handled or the memory in use.
Description
A short sentence in plain words that explains the metric for people reading dashboards later.
Unit
The unit of measure, such as seconds, bytes or a simple count. Without a unit, a number is ambiguous.
Type
The kind of data: a sum, a last known value, or a distribution. The type decides how the data is combined.
Data Points
The actual measurements, each with a timestamp, a value and a set of labels. One metric holds many data points.
Attributes
Key-and-value labels on each data point, such as the route or the result code, used to slice the numbers.
One metric, many series
Imagine a metric that counts requests. If you attach an attribute for the route, you do not get one number. You get one number for each route: one for the home page, one for checkout, one for search. Each unique combination of attribute values forms a separate time series, which is simply one line on a chart. One metric name can therefore produce many lines.
A metric is like a column header in a sports table, such as “points scored”. Each team is one row, and each match day adds a new reading. The attributes, such as team name, decide which row a number belongs to. The metric name is shared, but every team has its own running history.
Always set a unit. A latency number of “250” could mean milliseconds or seconds, and a mistake of that size changes the meaning completely. Good units make shared dashboards safe to read.
5Instruments: The Tools That Record Metrics
In OpenTelemetry, you do not write numbers straight onto a metric. You use an instrument.
An instrument is the object that your code uses to record a measurement. You pick the instrument that matches the kind of thing you want to measure. OpenTelemetry offers a small set, and choosing the right one is the most important metric decision you will make.
Counter
For values that only go up, such as requests served or errors seen. You add to it, but never subtract.
UpDownCounter
For values that can go up and down, such as items in a queue or active connections. You add or subtract as things change.
Histogram
For measurements where the spread matters, such as response times or request sizes. It records how values are distributed.
Gauge
For a value you want to record at the moment it changes, such as a current temperature or a setting. It stores the latest reading.
Synchronous and asynchronous instruments
Each instrument comes in two styles. A synchronous instrument is used inline, at the moment something happens. When a request arrives, your code immediately adds one to a counter. An asynchronous instrument, sometimes called an observable instrument, works differently. You register a small function, and the system calls it later, at each collection time, to read the current value. This suits things that you cannot easily update every time they change, such as the memory currently used by the process, or the temperature of a processor.
| Instrument | Goes Up? | Goes Down? | Typical Example |
|---|---|---|---|
| Counter | Yes | No | Total requests handled |
| UpDownCounter | Yes | Yes | Jobs currently waiting in a queue |
| Histogram | Records many values | Records many values | Time taken to answer a request |
| Gauge | Latest value | Latest value | Current room temperature |
| Observable (async) versions | Read on demand | Read on demand | Memory in use right now |
A counter is like a turnstile at a stadium gate that clicks once for every person entering and never goes backwards. An up-down counter is like the “people currently inside” board, which goes up when someone enters and down when someone leaves. A histogram is like a record of how long each person queued. A gauge is like a thermometer that simply shows the temperature right now.
Using a gauge when you really want a counter, or the other way round. Counting events with a gauge loses information if collection happens between changes. If something only grows, use a counter and let the tool work out the rate.
6Choosing the Right Instrument
A short set of questions will lead you to the correct choice nearly every time.
Are you counting events that only accumulate?
If yes, such as requests, errors, bytes sent or jobs completed, use a Counter. The total only ever grows.
Can the value go down as well as up?
If the quantity rises and falls, such as items waiting or users online, use an UpDownCounter when you know the changes, or an observable gauge when you can only read the current level.
Do you care about the spread of values?
If you want to know typical and worst-case values, such as response times, use a Histogram. An average alone hides slow outliers.
Is the value something you read, not something you count?
If you need a snapshot of the current state, such as a temperature or a configured limit, use a Gauge.
Can your code update it at the moment of change?
If yes, use the synchronous style. If the value is only known when asked, use the asynchronous, observable style with a callback.
When in doubt, ask: “Would I want to know the rate of this, the level of this, or the distribution of this?” Rate suggests a counter, level suggests an up-down counter or gauge, and distribution suggests a histogram.
7Histograms: Why Averages Are Not Enough
Histograms are the most powerful instrument and the one beginners find hardest.
Suppose ten customers each wait for an answer. Nine of them wait one second, and one waits ninety-one seconds. The average wait is ten seconds. That number describes nobody. Nine people were happy and one was furious. An average hid the real story. A histogram keeps the shape of the data.
How a histogram works
A histogram sorts measurements into ranges called buckets. Each bucket counts how many measurements fell inside its range. For response times, one bucket might hold answers under a tenth of a second, the next might hold answers between a tenth and half a second, and so on. A histogram also usually records the total number of measurements and the sum of all of them, so that an average can still be calculated.
Imagine a row of buckets under a conveyor belt, each labelled with a size range. As oranges roll past, each falls into the bucket that matches its size. At the end of the day you do not remember every orange, but you can see at a glance how many were small, medium or huge. That picture is a histogram.
Percentiles in simple words
From a histogram, tools can estimate percentiles. The 50th percentile, often called the median, is the value that half of all measurements are below. The 95th percentile is the value that 95 out of every 100 measurements are below. The 99th percentile focuses on the unlucky slowest one in a hundred. Teams often watch the 95th or 99th percentile because it represents what the unhappiest real users experience.
Explicit bucket histograms
The boundaries between buckets are chosen in advance, either by default or by you. They are simple and widely supported, but if the boundaries do not fit your data, estimates become rough.
Exponential histograms
A more modern form where bucket sizes grow by a fixed ratio and adjust automatically to the data. They need little configuration and give good accuracy across a wide range of values, though not every backend supports them yet.
Reporting only averages for response times. Averages smooth away the pain of your slowest users. Use histograms and watch high percentiles to learn what the worst-case experience really looks like.
8Meters, Providers and the Metrics Pipeline Inside Your App
A short tour of the machinery that turns instrument calls into data on a dashboard.
You do not have to master these parts, but knowing their roles makes everything else click. Inside an application, OpenTelemetry sets up a small pipeline.
Meter Provider
The factory that configures metrics for the whole application and hands out meters.
Meter
The object that creates instruments. Each library or module often has its own named meter.
Instruments
The counters, histograms and gauges your code uses to record measurements.
Views
Optional rules that change how a metric is summarised, renamed, or which attributes it keeps.
Metric Reader
Collects the summarised data on a schedule, or whenever an outside system asks for it.
Exporter
Sends the collected data to a destination such as a Collector or a monitoring tool.
flowchart LR
C["Your code records a measurement"] --> I["Instrument"]
I --> A["Aggregation combines measurements"]
A --> V["Views adjust names and labels"]
V --> R["Metric Reader collects on a schedule"]
R --> E["Exporter sends data"]
E --> CO["OpenTelemetry Collector"]
CO --> B["Metrics Backend and Dashboard"]
Aggregation happens early
Here is a key idea. Your application does not send every individual measurement. As measurements arrive, the SDK combines them right away into running summaries. A counter keeps a running total. A histogram keeps bucket counts. A gauge keeps the latest value. Only these small summaries are sent at each collection. This is why metrics stay cheap even when traffic is huge.
Collection happens on a rhythm
The metric reader typically gathers the current summaries at regular intervals, often about once a minute by default, though the interval can be changed. Between collections, the application simply keeps updating its in-memory summaries. A shorter interval gives fresher charts but more data to send.
If your dashboard looks “steppy” or slow to react, check the collection interval first. A once-a-minute rhythm cannot show events that happen and disappear within a few seconds.
9Temporality: Cumulative Versus Delta
The same counter can be reported in two different ways, and both are valid.
Imagine a shop that counts customers entering. By midday the total is 300, and by evening it is 700. There are two ways to report this to head office. You can say “700 so far today”, a running total that always grows. Or you can say “400 since the last report”, the amount added in the latest period. The first is called cumulative and the second is called delta. The word for this choice is temporality.
Cumulative
- Reports the total since the start
- A missed report is easy to recover from, since the next one still includes everything
- Preferred by many open-source metrics systems
- Needs the application to remember its running totals
Delta
- Reports only what changed since last time
- Can use less memory in the application
- Preferred by some commercial platforms
- A lost report means lost data that cannot be recovered
| Time | Customers Entered | Cumulative Report | Delta Report |
|---|---|---|---|
| Morning | 100 | 100 | 100 |
| Midday | 200 | 300 | 200 |
| Afternoon | 150 | 450 | 150 |
| Evening | 250 | 700 | 250 |
You usually do not need to decide this alone. Choose the temporality your backend prefers. The OpenTelemetry Collector and many SDK settings can also convert between the two styles for you.
Sending delta data to a backend that expects cumulative data, or the reverse. The charts will show strange spikes, drops or flat lines. When numbers look nonsensical, mismatched temporality is a prime suspect.
10Attributes and the Danger of High Cardinality
Labels make metrics useful, and too many labels make them dangerous.
Attributes let you break a metric into slices. A request counter with a route attribute can show which pages are busiest. With a status attribute, it can show how many requests succeeded or failed. These slices are what turn a flat number into real insight.
What is cardinality?
Cardinality is the number of different values something can take. An attribute for HTTP method has very low cardinality, since there are only a handful of methods. An attribute for the customer’s user identifier has very high cardinality, since there might be millions of different users.
Because every unique combination of attribute values creates its own time series, the total number of lines multiplies quickly. Three routes, five status codes and four regions already make sixty series. Add a user identifier with a million values, and you could create sixty million series. Storage fills, queries slow down and bills explode.
Imagine a notebook where you keep one page for every combination of shop, product and customer. With three shops and ten products, you have thirty pages, which is fine. If you add one page for every individual customer, the notebook grows into a library you can no longer carry. Metrics are meant to be summaries, not a page for every person.
Safe attributes
Small, bounded sets of values: HTTP method, status class, region, service version, environment, operation type.
Dangerous attributes
Unbounded or unique values: user identifiers, session tokens, email addresses, full web addresses with real data in them, request identifiers, precise timestamps.
Where details belong instead
Unique details belong in traces and logs, which are designed for individual events. Use metrics for the big picture, and use traces and logs for the single case.
Problem
A developer adds the customer identifier as an attribute on a request counter so that they can see usage per customer.
Why It’s Harmful
Every customer creates a separate time series. Series counts explode, storage costs soar, queries slow down, and the monitoring system may start rejecting data.
Correct Approach
Use a small, bounded attribute such as customer tier, and look up individual customers through traces or logs when you need them.
11Resources and Instrumentation Scope
Two extra pieces of context explain where a metric came from.
Besides its own attributes, every metric carries information about its producer. This comes in two layers.
Resource
Describes the entity producing the data: the service name, its version, the environment, the host or the container. It is the same for all signals from that service.
Instrumentation Scope
Describes which library or module created the metric, along with its version. It helps tell apart metrics from your own code and from a database library.
These layers mean that metric data points do not need to repeat “service name equals checkout” on every line. The information is attached once, at a higher level, and applies to everything underneath. When you query for all metrics from one service, the resource is what makes that possible.
Always set a clear service name and environment in the resource. Without them, metrics from your test system and your production system can end up mixed together on the same chart, which is a recipe for confusion.
12Semantic Conventions: Speaking a Common Language
Agreeing on names is what makes metrics from different teams comparable.
If one team calls its metric “req_count”, another calls it “requests_total”, and a third calls it “http_hits”, then building a shared dashboard is painful. OpenTelemetry solves this with semantic conventions, a published set of agreed names, units and attributes for common situations such as web servers, databases, messaging systems and runtime behaviour.
When your instrumentation follows these conventions, any tool that understands them can recognise, for example, that a metric describes the duration of web requests, and can draw a ready-made chart. Many automatic instrumentation libraries already follow these conventions, so you get consistent metrics without extra work.
Naming
Use clear, lowercase names with dots to group related ideas, and avoid putting the unit inside the name, since the unit is a separate field.
Units
Prefer standard units, such as seconds for time and bytes for size, so numbers from different services line up.
Attributes
Use the standard attribute names for things like HTTP method, status and server address, so that filters and groupings work the same everywhere.
Inventing your own names for things that already have a standard. You lose ready-made dashboards and alerts, and every new teammate has to learn your private vocabulary.
13Getting Metrics Out: Push, Pull and the Collector
There are two classic ways for measurements to reach a monitoring tool.
Push
In the push style, your application sends metrics out on a schedule using the OpenTelemetry Protocol, often shortened to OTLP. It is like a reporter who phones the head office every minute with the latest figures. This is the native OpenTelemetry approach.
Pull
In the pull style, a monitoring tool visits your application on a schedule and reads the current values from a web page the application exposes. It is like an inspector who walks from shop to shop, reading each meter. Many open-source systems work this way, and OpenTelemetry can expose its metrics in that format.
| Question | Push | Pull |
|---|---|---|
| Who starts the transfer? | The application | The monitoring tool |
| Good for short-lived jobs? | Yes, they can report before they end | Harder, the job may be gone before the visit |
| Firewall friendliness | Needs outbound access from the application | Needs inbound access to the application |
| Control over frequency | Set in the application | Set in the monitoring tool |
The Collector in the middle
The OpenTelemetry Collector is a separate program that receives telemetry, processes it, and forwards it. For metrics, it can accept both pushed OTLP data and pulled data from many sources, convert between cumulative and delta styles, add labels, remove unwanted ones, batch data for efficiency, and send it to one or several destinations at once.
flowchart LR
A1["App pushing OTLP metrics"] --> COL["Collector"]
A2["App exposing a metrics page"] --> COL
H["Host and container metrics"] --> COL
COL --> P1["Add labels and remove noisy ones"]
P1 --> P2["Convert temporality and batch"]
P2 --> B1["Open-source metrics store"]
P2 --> B2["Commercial monitoring platform"]
A Collector is a fine place to enforce company-wide rules, such as dropping dangerous high-cardinality labels or adding the team name to every metric, so that individual applications do not each have to remember to do it.
14Metrics, Traces and Logs Working Together
Each signal is strongest when it can point to the others.
OpenTelemetry is designed so that metrics, traces and logs can reference each other. This is called correlation, and it turns three separate piles of data into one connected investigation.
Exemplars
A metric data point, especially in a histogram, can carry a small sample that points to a real trace. From a spike on a chart, you can open an example slow request.
Shared Resource
Metrics, traces and logs from one service share the same resource, so everything lines up under one name.
Metrics from Traces
Counting and timing spans can produce request-rate, error-rate and duration metrics, giving dashboards without extra code.
Logs with Trace Identifiers
Log lines stamped with trace identifiers let you jump from a slow span to the messages written during it.
flowchart LR
M["Metric alert: error rate jumped"] --> X["Open an exemplar trace"]
X --> T["Find the failing span"]
T --> L["Read the linked logs"]
L --> F["Understand and fix the cause"]
Think of a fire alarm panel in a building. The panel (metric) tells you that something is wrong on the third floor. The camera feed (trace) shows you which corridor. The guard’s notes (log) explain what happened. The panel’s real value is that it points you to the right place quickly.
15What Should You Measure? Practical Starting Points
Good metrics answer the questions people really ask at three in the morning.
Beginners often ask, “What should I measure?” There are a few well-known frameworks that turn that vague question into a short checklist.
The RED method for services
Rate
How many requests per second is the service handling? Use a counter and let the tool compute the rate.
Errors
How many of those requests are failing? Use a counter with a status or result attribute.
Duration
How long do requests take? Use a histogram and watch high percentiles.
The USE method for resources
Utilisation
How busy is the resource, such as processor or disk, as a percentage of its capacity?
Saturation
How much extra work is waiting because the resource is full, such as a queue length?
Errors
How many error events has the resource reported, such as disk faults or dropped packets?
Business metrics
Technical health is only part of the picture. Counting orders placed, payments completed or sign-ups finished tells you whether the business is working, not just the machines. A sudden drop in orders with perfectly healthy servers can reveal problems that technical metrics never show.
A restaurant owner watches three things about the dining room: how many customers arrive (rate), how many leave unhappy (errors) and how long they wait for food (duration). The kitchen manager watches how busy each cooker is (utilisation), how many orders are waiting (saturation) and how many dishes are ruined (errors). Both are looking at the same restaurant through different lenses.
16Security and Privacy for Metrics
Metrics look harmless, but they can still reveal more than you expect.
Because metrics are summaries, they feel safer than logs. But attributes can still carry sensitive values, and a metrics endpoint can reveal how your system is built. Treat metrics with the same respect as any other operational data.
Keep personal data out of attributes
Never use names, emails, phone numbers or account numbers as attributes. They are both a privacy risk and a cardinality disaster.
Protect metrics endpoints
A web page that exposes metrics can reveal server names, versions and traffic patterns. Keep it on a private network or require authentication.
Encrypt data in transit
Use secure connections between applications, Collectors and backends so metrics cannot be read or changed on the way.
Limit who can see and change dashboards
Operational data can reveal business activity, such as sales volumes. Give access only to the people who need it.
Use the Collector as a safety net
A central Collector can remove or hash risky attributes before data leaves your network, as a second line of defence behind careful developers.
Exposing a metrics page to the public internet “because it is only numbers”. Those numbers can reveal internal names, software versions and load patterns that help an attacker plan.
17Best Practices and Anti-patterns
Habits that keep metrics useful, affordable and trustworthy.
Good habits
Start with the RED and USE basics
Rate, errors and duration for every service, plus utilisation, saturation and errors for key resources, give strong coverage with little effort.
Pick the right instrument
Counters for totals, up-down counters or gauges for levels, histograms for distributions. The right choice keeps data meaningful.
Always set units and descriptions
Future readers, including yourself in six months, will thank you.
Keep attributes small and bounded
Choose labels with a small, predictable set of values, and review them before releasing a new metric.
Follow semantic conventions
Reuse standard names and attributes so tools and teammates understand your data immediately.
Alert on symptoms, not just causes
Alert on user-facing problems such as high error rate or slow responses, then use traces and logs to find causes.
Send metrics through a Collector
It lets you change backends, convert temporality, and enforce label rules without touching application code.
Mistakes to avoid
Problem
Teams track only averages for response times and show a single “average latency” chart.
Why It’s Harmful
Slow outliers disappear into the average. Users suffer while the dashboard looks calm, and problems are found only when customers complain.
Correct Approach
Record durations in a histogram, and chart the median together with high percentiles such as the 95th and 99th.
Problem
Names and units are inconsistent: one service reports time in milliseconds, another in seconds, and both use different names for the same idea.
Why It’s Harmful
Dashboards combine numbers that cannot be compared, and shared alerts must be rewritten for each service.
Correct Approach
Adopt semantic conventions, agree on standard units, and review new metrics before they reach production.
Problem
Every function in the code gets its own metric, creating hundreds of counters that nobody ever looks at.
Why It’s Harmful
Costs rise, dashboards become cluttered, and the few metrics that matter are lost in the noise.
Correct Approach
Measure what answers real questions: user-visible health, resource pressure and key business outcomes. Add more only when a real need appears.
Problem
Alerts are set on raw causes such as “processor above 70 percent” with no link to user impact.
Why It’s Harmful
People are woken up for harmless spikes and learn to ignore alerts, so real incidents can be missed.
Correct Approach
Alert on symptoms users feel, such as error rate and slow responses, and keep resource metrics for investigation and capacity planning.
18Advantages and Trade-offs of Metrics
Metrics are the cheapest and fastest signal, but they have limits.
Advantages
- Very cheap to store, since data is summarised before it is sent
- Fast to query, so dashboards and alerts respond quickly
- Excellent for spotting trends, spikes and gradual decay
- Predictable cost that does not grow with every single request
- Perfect for alerting on the health of a system
- Open standard that works across languages and vendors
Disadvantages / Trade-offs
- Individual events are hidden inside the summary
- Cannot tell you why something happened, only that it did
- Too many attributes can cause cost and performance explosions
- Collection intervals can hide very short spikes
- Choosing the wrong instrument or temporality gives confusing data
Metrics, traces and logs compared
| Signal | Best Question It Answers | Level of Detail | Typical Cost |
|---|---|---|---|
| Metric | Is something changing, and when? | Summary over time | Low and predictable |
| Trace | Where did this request spend its time? | One request at a time | Medium to high |
| Log | What exactly happened at this moment? | One event at a time | Can be high at scale |
“Metrics replace logs and traces.” They do not. Metrics raise the alarm, traces point to the place, and logs often explain the reason. Each signal covers a gap that the others leave.
19Real-World Scenarios
Picture how different teams put metrics to work every day.
An online shop catches a failing payment provider
A chart of the payment error rate suddenly climbs from almost zero to ten percent at 2 p.m. An alert fires within minutes. The team opens an example trace attached to the metric, sees the external provider timing out, and switches to a backup provider. Few customers notice.
A streaming service plans capacity
By charting active viewers and processor use over several months, the team notices that evening traffic grows steadily by about five percent each month. They add servers ahead of the holiday season instead of reacting to a crash.
A bank watches queue length
A queue of waiting transfers is tracked as an up-down counter. When the queue grows for ten minutes without shrinking, an alert tells the team that workers are too few or stuck. They scale up before customers see delays.
A game company discovers a memory leak
A gauge of memory used by each game server shows a slow, steady climb after every deployment. The pattern points to a leak introduced in the latest release. The team rolls back and fixes the code before servers start crashing.
A platform team cuts monitoring costs
A bill for monitoring doubles in one month. Investigation shows that one service added a request identifier as an attribute. The team removes the label using a rule in the Collector, and the bill returns to normal the next day.
20Getting Started: A Gentle Path
You do not need to learn everything at once.
Pick one service that matters
Choose a visible service, such as checkout or sign-in, so the value of metrics is easy to see.
Turn on automatic instrumentation
Many libraries produce request rate, error and duration metrics for you, following the standard conventions.
Send metrics to a Collector and a viewer
Use a free open-source tool or your existing vendor to draw the first charts.
Build one simple dashboard
Show rate, errors and duration for the service, plus processor and memory use. Resist the urge to add everything.
Add one or two business metrics
Count something the business cares about, such as orders completed, using a counter with a few bounded attributes.
Create a small number of useful alerts
Alert on user-facing symptoms and tune them until they are trusted. Add correlation with traces and logs as the next improvement.
Your first goal is not perfection. It is to see one real chart that moves when your service gets busy. That moment, when the numbers start to mirror reality, is when metrics finally click.
21Frequently Asked Questions
It is a number that describes something about your software, measured again and again over time, and usually summarised so it stays small. Examples include requests per second, memory in use and response time distribution.
A metric is a summary number over time, a trace follows one request across services, and a log is a text record of one event. Metrics tell you that something changed, traces show where, and logs often explain why.
An instrument is the object your code uses to record a measurement. Counters, up-down counters, histograms and gauges are the main kinds, and each comes in a synchronous and an asynchronous style.
Use a counter for totals that only increase, such as requests or errors, and let your tool compute the rate. Use a gauge for a value that you simply read at a moment in time, such as current temperature or a configured limit.
Because averages hide slow outliers. A histogram keeps the shape of the data, so you can see the median and high percentiles, which reflect what your unluckiest users actually experience.
Cumulative reports the running total since the start, while delta reports only the change since the previous report. Different backends prefer different styles, and the Collector can convert between them.
Cardinality is the number of different values an attribute can take. Every unique combination of attribute values makes a new time series, so high-cardinality labels such as user identifiers can create huge numbers of series, raising cost and slowing queries.
Typically on a regular rhythm, often around once a minute by default, though you can change the interval. Shorter intervals give fresher charts but produce more data. In pull setups, the monitoring tool decides how often to visit.
No, applications can send metrics straight to a compatible backend. A Collector is recommended as systems grow, because it centralises label rules, temporality conversion, batching and destination changes.
An exemplar is a small sample attached to a metric data point that points to a specific trace. It lets you jump from a spike on a chart to a real example request that contributed to it.
For each service, start with request rate, error count and request duration. For key resources, add utilisation, saturation and errors. Then add one or two business metrics, such as orders completed.
They can if you put personal or secret values into attributes. Keep attributes small, bounded and free of personal data, protect metrics endpoints, encrypt data in transit, and consider a Collector rule that removes risky labels as a safety net.
22Summary and Key Takeaways
A metric in OpenTelemetry is a summarised measurement of your software, tracked over time and described by a name, a unit, a type and a set of labelled data points. Your code records measurements with instruments: counters for totals, up-down counters and gauges for levels, and histograms for distributions. The SDK combines measurements into compact summaries, a reader collects them on a schedule, and an exporter sends them to a Collector and then to a backend, where they become lines on dashboards and triggers for alerts. Choose the right instrument, set clear units, keep attributes small and bounded, follow semantic conventions, and watch percentiles rather than averages. Used well, metrics are your earliest and cheapest warning system, and they point you towards the traces and logs that explain why.
Key Takeaways
- A metric is a number over time — it summarises many measurements into compact data that is cheap to store and fast to chart and alert on.
- Instruments decide the meaning — use counters for totals that only grow, up-down counters or gauges for levels, and histograms for spreads such as response times.
- Histograms beat averages — they preserve the shape of the data so you can watch the median and high percentiles instead of a misleading single average.
- Aggregation happens early — the SDK combines measurements inside the application, and a reader sends the summaries on a regular rhythm.
- Match temporality to your backend — cumulative reports running totals, delta reports changes, and the Collector can convert between them.
- Guard cardinality — every unique combination of attribute values creates a new time series, so avoid unbounded labels like user identifiers.
- Start simple and connect the signals — begin with rate, errors and duration, follow semantic conventions, and use exemplars and shared resources to jump from metrics to traces and logs.