What Is an UpDownCounter in OpenTelemetry?

What Is an UpDownCounter in OpenTelemetry?

An UpDownCounter is the OpenTelemetry metric instrument for numbers that can both rise and fall, such as items waiting in a queue or requests being handled right now. This guide explains it from zero, with analogies, diagrams and real-world patterns.

Think about a public library. Every time someone borrows a book, the number of books currently out on loan goes up by one. Every time someone returns a book, that number goes down by one. The librarian does not need to recount the whole library each time. She just keeps one running number on a sheet of paper: add one when a book leaves, subtract one when it comes back. At any moment, that number tells her how many books are out right now. This is very different from a counter that only ever grows, like the total number of loans in the library’s history. The sheet that goes both up and down is what OpenTelemetry calls an UpDownCounter.

1Why Some Numbers Must Go Down

Not everything in a running system only ever grows.

Applications are full of quantities that rise and fall naturally. A web server handles many requests at once, and the number of requests being processed right now changes every millisecond. A job queue grows when work arrives and shrinks when workers finish. A database connection pool lends out connections and gets them back. A shopping cart gains and loses items. A game server gains and loses players.

Engineers need to watch these numbers, because trouble often shows up as a number that stays too high for too long. A queue that never shrinks means workers are stuck. A count of active requests that keeps climbing means the service is slowing down. A pool with every connection lent out means new users must wait.

A simple counter that only grows cannot describe these situations. Imagine trying to describe the water level in a bathtub using only a tally of how much water ever flowed in from the tap, ignoring what drained out. The tally would be technically correct and practically useless. We need an instrument that can move in both directions.

Simple Analogy

Think of the people inside a shop right now. Each person who enters adds one, and each person who leaves subtracts one. The number on the doorman’s clicker pair tells you how crowded the shop is at this moment, not how many customers visited over the year.

Up
something arrives or starts
Down
something leaves or finishes
Now
the running balance at this moment

2A Quick Map of OpenTelemetry Metrics

A short refresher on the surrounding vocabulary makes everything easier.

OpenTelemetry, often called OTel, is an open-source project that defines how software describes its own behavior. It is vendor neutral, which means no single monitoring company owns it. It handles three kinds of data, called signals: traces, metrics and logs. This guide lives in the world of metrics, which are numbers measured over time.

Piece 1

Meter Provider

The manager of all metrics in an application, normally set up once when the program starts.

Piece 2

Meter

A named group of instruments, often one for each library or component, like a labeled drawer of tools.

Piece 3

Instrument

The actual tool that records numbers. The UpDownCounter is one kind of instrument.

Piece 4

Reader and Exporter

The parts that collect current values on a schedule and send them to the place where people view charts.

The family of instruments

OpenTelemetry offers several instruments, each shaped for a different kind of question. The ones you will meet most often are the Counter, the UpDownCounter, the Gauge and the Histogram. Each of them also has a version where the library reads the value for you through a callback, called an asynchronous or observable instrument. We will compare them carefully in a later chapter.

i
Beginner Tip

Hold onto this chain: a meter provider hands out meters, a meter hands out instruments, and an instrument records numbers. The UpDownCounter is simply the instrument you pick when the number can move in both directions.

3So, What Exactly Is an UpDownCounter?

An UpDownCounter is an instrument that records additions and subtractions to a running total.

Let us define it carefully. An UpDownCounter in OpenTelemetry is a metric instrument used to record changes to a value that can both increase and decrease over time. You use it by calling an add operation whenever something changes, passing a positive number when the value grows and a negative number when the value shrinks. The library keeps the running total, which represents the current level of whatever you are tracking.

The name tells the story: it is a counter that can go up and also go down. Compared with the regular Counter, which accepts only non-negative additions and therefore never decreases, the UpDownCounter accepts negative additions too. In the language of the specification, the regular Counter is monotonic, meaning it never decreases, while the UpDownCounter is non-monotonic.

1

Something arrives

A request starts, a job joins the queue, or a connection is lent out.

2

The code adds one

The application tells the UpDownCounter to add a positive amount, usually one.

3

Something leaves

The request finishes, the job is completed, or the connection returns to the pool.

4

The code subtracts one

The application tells the same UpDownCounter to add a negative amount, usually minus one.

5

The balance is exported

On a schedule, the current balance is sent to a backend and charted.

!
Common Misconception

An UpDownCounter does not need to know the current value. You never tell it that the queue length is seven. You only tell it that one item arrived or one item left, and it keeps the balance itself.

4Counter vs UpDownCounter

The two instruments look alike but answer very different questions.

The easiest way to understand the UpDownCounter is to place it next to its famous sibling, the Counter. Both are sums built from additions. The difference lies in what they promise and in what question they answer.

QuestionCounterUpDownCounter
Can the total decrease?NeverYes
Accepts negative additions?No, they are ignoredYes, that is its purpose
Technical nameMonotonic sumNon-monotonic sum
Question it answersHow many times has this happened in total?How much is there right now?
What to chartThe rate of growthThe value itself
Typical exampleRequests servedRequests in progress
Simple Analogy

A Counter is like the odometer in a car, which only climbs and tells you how far you have travelled in total. An UpDownCounter is like the fuel gauge’s logic: fuel goes in at the station and goes out as you drive, and what matters is how much is in the tank now.

Pairing them together

Many real systems use both on the same event. For example, a web service can use a regular Counter to count every request ever received, and an UpDownCounter to track how many requests are in progress at this moment. One tells you how busy the service has been, the other tells you how loaded it is right now.

i
Rule of Thumb

If you can phrase the question as how many are there right now, you probably want an UpDownCounter. If you can phrase it as how many have there been in total, you want a Counter.

5What Should You Track with an UpDownCounter?

Good UpDownCounters measure how much of something exists at a moment.

The classic use of an UpDownCounter is any quantity that is increased by an event and decreased by an opposite event. When you can name the up event and the down event, you have found a candidate.

Requests in progress

Add one when a request starts and subtract one when it ends. A number that stays high means requests are piling up or taking too long.

Queue length

Add one when a message joins the queue and subtract one when a worker takes it. A rising line means workers cannot keep up.

Active connections

Add one when a client connects and subtract one when it disconnects. This shows load on servers, databases and message brokers.

Database pool usage

Add one when a connection is lent out and subtract one when it is returned. A pool at its limit explains many mysterious slowdowns.

Items in a cart or stock levels

Add when stock arrives or an item is added to a cart, subtract when it is sold or removed. The balance shows live inventory or live shopping activity.

Active sessions or players

Add one on sign-in and subtract one on sign-out or timeout. The balance shows how many people are online at this moment.

Memory or resources handed out

Add the size when memory or a resource is allocated and subtract it when it is released, giving a live picture of how much is in use.

i
Standard Example

The OpenTelemetry semantic conventions for web servers describe the number of active requests as an UpDownCounter. Following such shared definitions makes your data line up with other teams and with ready-made dashboards.

6What Should You NOT Track with It?

Knowing the limits prevents the most common beginner mistakes.

The UpDownCounter is flexible, which makes it tempting to use everywhere. But some quantities are better served by other instruments. Picking the wrong one produces confusing charts and sometimes wrong numbers.

ANTI-PATTERN-01 Avoid
Problem

Using an UpDownCounter for values that only ever grow, such as total orders ever placed.

Why It’s Harmful

You lose the clear signal that the value is monotonic. Backends can no longer assume it is safe to compute rates and handle restarts as resets.

Correct Approach

Use a regular Counter for ever-growing totals.

ANTI-PATTERN-02 Avoid
Problem

Using an UpDownCounter to record a reading you simply observe, such as room temperature or CPU percentage, by faking additions and subtractions.

Why It’s Harmful

You must calculate the difference from the last reading yourself, and any missed update leaves the balance permanently wrong.

Correct Approach

Use a Gauge for readings of the current state that are not naturally additive.

ANTI-PATTERN-03 Avoid
Problem

Using an UpDownCounter to track how long things take, such as adding the duration of each request.

Why It’s Harmful

A running balance of durations has no sensible meaning, and it hides the spread between fast and slow requests.

Correct Approach

Use a Histogram, which records the distribution of values such as latency.

ANTI-PATTERN-04 Avoid
Problem

Wanting to know how many times a request started, but only keeping an UpDownCounter that goes back down when requests finish.

Why It’s Harmful

The balance forgets history. You cannot tell how many requests happened in total, only how many are in flight.

Correct Approach

Record two instruments: a Counter for the total and an UpDownCounter for the live balance.

7UpDownCounter vs Gauge

This is the comparison that confuses beginners most, so let us settle it clearly.

Both an UpDownCounter and a Gauge can describe a number that moves up and down. So when should you use which? The answer depends on how the number is known and whether it makes sense to add values from different sources.

With an UpDownCounter, you report changes: one more arrived, one left. The library builds the balance. The values from different instances of your service can be added together, because they are all balances of the same kind of thing. If three servers each report four requests in progress, the whole system has twelve.

With a Gauge, you report the current reading directly: the temperature is now twenty-two degrees. Readings of this kind often do not make sense to add. If three rooms each report twenty-two degrees, the total of sixty-six degrees is meaningless. Gauges are for such non-additive readings.

QuestionUpDownCounterGauge
What do you report?The change: plus or minus an amountThe current reading itself
Who builds the balance?The library, from your changesYou, from an external reading
Can values from many instances be added?Yes, the total is meaningfulUsually not
Natural exampleRequests in progressRoom temperature
Risk if an update is missedThe balance drifts until fixedThe next reading corrects it
Simple Analogy

An UpDownCounter is like a bank account where you record each deposit and withdrawal, and the balance follows. A Gauge is like checking the balance on the bank’s screen. Both show money, but one is built from transactions and the other is simply read.

i
Decision Hint

Ask yourself: would adding the numbers from two servers give a meaningful total? If yes, think UpDownCounter. If adding them would be nonsense, think Gauge.

8Choosing Among All the Instruments

A single decision path makes the choice almost automatic.

flowchart TD
  Q1{"What kind of number is it?"}
  Q1 -->|"Total of events, only grows"| C["Counter"]
  Q1 -->|"Balance built from ups and downs"| U["UpDownCounter"]
  Q1 -->|"Current reading, not additive"| G["Gauge"]
  Q1 -->|"Spread of many values such as latency"| H["Histogram"]
        
FIG 1 — Choosing the right instrument for the number
InstrumentMoves how?Best questionEveryday picture
CounterOnly upHow many in total?Car odometer
UpDownCounterUp and down by stepsHow many right now?People inside a shop
GaugeFreely, read directlyWhat is the reading?Wall thermometer
HistogramMany values recordedHow are they spread?Log of phone call lengths
!
Common Mistake

Choosing an instrument based on what is easiest to code today rather than what the number really means. The right choice shapes how every backend interprets, sums and charts your data for years.

9Synchronous and Asynchronous UpDownCounters

There are two ways to feed the balance, depending on who notices the change.

The regular UpDownCounter is synchronous. Your code is in charge and calls add at the moment each change happens. Use it when your own program performs the up and down events, such as accepting and finishing requests.

The second style is the asynchronous UpDownCounter, also called the observable UpDownCounter. You register a small function called a callback. Whenever the library is about to collect metrics, it calls your function, and your function reports the current total. Use it when the balance already lives somewhere else and you merely want to read it, for example the number of items in an external queue that the library of that system already tracks.

QuestionSynchronousAsynchronous
Who triggers the update?Your code at every changeThe library at every collection
What do you report?The amount to add or subtractThe current total, already known
Best whenYour code causes the changesAnother system keeps the balance
Typical exampleRequests in progress in your serviceSize of a queue managed by a broker
Simple Analogy

Synchronous is like keeping your own tally sheet of books checked out. Asynchronous is like asking the library desk once an hour how many books are out and writing down their answer.

i
Good to Know

In the asynchronous style, you report the total itself, not a change. The library works out the rest. Mixing these ideas up is a frequent source of wrong numbers.

10The Golden Rule: Every Up Needs a Matching Down

The biggest danger of an UpDownCounter is a balance that quietly drifts away from reality.

Because an UpDownCounter is built from changes, its accuracy depends on every up event being matched by exactly one down event. If a request adds one when it starts but an error path forgets to subtract one when it ends, the balance will creep upward forever, even when the system is idle. A chart of requests in progress might show fifty when the true number is zero. This kind of drift is the most common bug with this instrument.

sequenceDiagram
  participant R as Request
  participant U as UpDownCounter
  R->>U: Start: add 1
  Note over U: Balance goes up
  R->>R: Do the work
  alt Work succeeds
    R->>U: End: add minus 1
  else Work fails
    R->>U: End: add minus 1 as well
  end
  Note over U: Balance returns to where it was
        
FIG 2 — Success and failure paths must both subtract
Simple Analogy

Imagine a hotel desk clerk who writes a plus when a guest checks in and a minus when a guest checks out. If one guest leaves through the fire escape without checking out, the clerk’s sheet says the room is occupied forever. Every exit, even the unusual ones, must produce a minus.

How to stay safe

1

Subtract in a guaranteed place

Put the subtraction in the part of your code that always runs, regardless of success, error or timeout.

2

Wrap the pair in one helper

Hide the add and subtract inside a single small component so developers cannot use one without the other.

3

Watch for drift

If the balance never returns to zero during quiet periods, a subtraction is being missed somewhere.

!
Watch Out

Crashes and killed processes cannot subtract. When a program restarts, its in-memory balance begins again from zero, which is usually the correct answer because nothing is in flight in a brand-new process.

11Attributes Must Match on the Way Up and Down

Labels on an UpDownCounter need extra care compared with a regular Counter.

Like other instruments, an UpDownCounter lets you attach attributes, which are small key and value labels such as the route being served or the queue name. The library keeps a separate running balance for every unique combination of attribute values, called a time series.

Here is the trap. If you add one with the attribute route equal to checkout, but later subtract one with a different attribute, say route equal to payment, the two balances will not cancel each other. The checkout series will be stuck one above zero and the payment series one below zero. Neither tells the truth.

flowchart LR
  A["Start: add 1 with route checkout"] --> B["Series checkout is 1"]
  C["End: add minus 1 with route payment"] --> D["Series payment is minus 1"]
  B --> E["Both series are wrong forever"]
  D --> E
        
FIG 3 — Mismatched attributes leave two broken balances
!
Common Mistake

Choosing an attribute whose value changes during the life of the thing being counted, such as a status that is unknown at the start. Only use attributes whose values are known and unchanging from the up event to the down event.

i
Practical Tip

Save the attribute values when you add, and reuse exactly the same values when you subtract. Treat the pair as one transaction with one fixed label set.

Cardinality still matters

As with any metric, avoid attributes with huge numbers of possible values, such as user identifiers or request identifiers. Each unique combination creates a new series, which costs memory and money. For an UpDownCounter there is an extra reason to be careful: a series with a stale non-zero balance can linger for a long time.

12What Happens Inside: From Add to Chart

Let us follow a single change from your code all the way to a dashboard.

Understanding the journey helps you reason about delays and surprises. Here is what happens when a request starts and later ends.

1

Code adds a change

The application adds plus one when a request starts, with its attributes.

2

The SDK updates the balance in memory

The library finds the series matching those attributes and adjusts its running sum. No network call happens yet, so the cost is tiny.

3

Code subtracts when the work ends

The same series is adjusted by minus one, and the balance falls back.

4

A reader collects on a timer

At a regular interval, commonly about once a minute by default, the reader asks the SDK for the current balance of every series.

5

An exporter sends the snapshot

The balances travel to a Collector or backend, where they are stored and charted.

sequenceDiagram
  participant App as Application Code
  participant SDK as SDK Aggregator
  participant R as Metric Reader
  participant E as Exporter
  participant B as Backend
  App->>SDK: Add 1
  App->>SDK: Add 1
  App->>SDK: Add minus 1
  Note over SDK: Balance is now 1
  R->>SDK: Collect on timer
  SDK-->>R: Current balance
  R->>E: Hand over snapshot
  E->>B: Send metrics
        
FIG 4 — Many cheap changes, one periodic export of the balance
i
Key Insight

Only the balance at the moment of collection is exported. A request that started and finished entirely between two collections leaves no trace in the chart, because the balance was back to its earlier value when it was read.

13Aggregation: A Non-Monotonic Sum

The balance is summarized as a sum that is marked as allowed to go down.

OpenTelemetry separates the act of recording from the way recorded values are summarized. For an UpDownCounter, the default summary is a Sum, and it is marked as non-monotonic. That mark is a message to every backend saying: this value can go down, so do not treat a decrease as a reset, and do not compute a rate of growth from it.

This is the reason the UpDownCounter exists as a separate instrument rather than a flag on the regular Counter. The mark changes how the data is understood everywhere downstream. A backend that sees a drop in a monotonic sum assumes a restart and adjusts. A backend that sees a drop in a non-monotonic sum accepts it as real.

Simple Analogy

Imagine reading the water level in a tank. If a warning label says the tank can only be filled, a sudden drop in the reading suggests the gauge was reset. If the label says the tank can also be drained, a drop is simply water leaving. The label, which is monotonic or non-monotonic, decides how readers interpret what they see.

!
Trade-off

Because the summary is a balance, you cannot recover how many ups and downs happened. A balance of five could mean five arrivals and no departures, or a thousand of each with five left over.

14Temporality: Why Cumulative Fits Best

The way a total is reported matters even more for a balance than for a regular Counter.

When a sum is exported, it can be described in one of two styles, called temporality. Cumulative style reports the full running balance since the program started. Delta style reports only the change since the last report.

MinuteChange in the minuteCumulative reportDelta report
1plus 444
2minus 13minus 1
3plus 252
4minus 50minus 5

Look at the cumulative column: each report directly answers how many are there right now. With the delta column, a backend must add up every past delta to reconstruct the balance, and a single lost report would make the balance wrong from then on. For this reason, cumulative reporting is the natural fit for UpDownCounters, and the OpenTelemetry specification suggests cumulative as the default for this instrument. Some backends that prefer delta for other instruments still keep cumulative for balances.

i
Practical Tip

When configuring a metric exporter for a backend that prefers delta, check how it treats UpDownCounters. Many setups intentionally keep these instruments cumulative so the balance stays reliable.

15Charting and Alerting on an UpDownCounter

Unlike a regular Counter, you chart the value itself, not its rate.

For a regular Counter, the raw total is rarely interesting, and people chart its rate of growth. For an UpDownCounter, it is the opposite. The value itself is the answer. A line chart of requests in progress shows exactly how loaded the system is. Taking a rate of an UpDownCounter usually produces confusing numbers that mix up arrivals and departures.

Chart 1

Current Level

Plot the balance over time. A flat low line means calm, and a rising staircase means work is piling up.

Chart 2

Sum Across Instances

Add the balances of all service instances to see the load on the whole system, such as total connections.

Chart 3

Compare with a Limit

Show the balance next to a known capacity, such as the pool size, so that saturation is easy to see.

Chart 4

Maximum Over Time

Because collections sample the balance, look at the highest value in each window to catch brief spikes.

Useful alerts

Good alerts for an UpDownCounter watch for a balance that stays beyond a sensible level for a sustained period. A queue length above a threshold for ten minutes is meaningful. A single moment above the threshold is usually just a burst. Another valuable alert is for a balance that fails to return to a low value during quiet periods, which can reveal the missed-subtraction bug described earlier.

!
Common Mistake

Alerting on a momentary spike. Balances naturally bounce, so use a sustained condition such as above the limit for several minutes, to avoid noisy pages.

16Naming, Units and Descriptions

A good UpDownCounter introduces itself clearly so strangers can understand it.

When you create an UpDownCounter, you give it a name, a unit and a description. These small details matter greatly, because the person reading a chart months later will not remember what you meant.

Field 1

Name

A short, dotted, lowercase name such as http.server.active_requests or queue.length. It should describe what exists, not the act of counting.

Field 2

Unit

What one unit means, often written in curly braces such as {request} or {connection}, or a real unit such as bytes.

Field 3

Description

One plain sentence explaining the metric, shown in tools. It is the label on the jar.

Name a balance after the thing that is present, such as active requests or queue length, not after the event of adding. Keep names stable, because renaming breaks dashboards and alerts. Follow the semantic conventions whenever one exists, so that your numbers match those of other teams. And create each instrument once at program start and reuse it everywhere, rather than recreating it for every event.

i
Good to Know

Some backends convert an UpDownCounter into their own gauge-like type when storing it. The meaning stays the same, because a balance is a value at a moment, even though the way it was built differs.

17UpDownCounters in Real Systems

Seeing the patterns in familiar systems makes the idea concrete.

The in-flight request pattern

A web service adds one when a request arrives and subtracts one when the response is sent. The balance is the number of requests currently being handled. A steady low number means health. A steadily rising number signals slowness, because new requests arrive faster than old ones finish.

The queue pattern

A producer adds one when it puts a message on a queue, and a consumer subtracts one when it takes the message. The balance is the backlog. A growing backlog tells you the consumers are too few, too slow or stuck.

The pool pattern

A connection pool adds one when a connection is lent out and subtracts one when it comes back. Compared with the pool’s size, the balance shows how close the system is to running out of connections, a classic cause of mysterious waits.

The session pattern

A chat or game service adds one on login and subtracts one on logout or timeout. The balance is the number of people online, which is useful for capacity planning and for noticing unusual drops after a release.

flowchart LR
  P["Producer"] -->|"add 1"| Q["Queue balance"]
  Q -->|"add minus 1"| W["Worker takes a message"]
  Q --> M["Exported as queue length"]
        
FIG 5 — The queue pattern: producers add, workers subtract
“An UpDownCounter does not remember how busy you have been. It tells you how busy you are.”

18Best Practices and Common Mistakes

A short checklist that saves hours of confusion later.

Do

Pair Every Up with a Down

Ensure every path, including errors and timeouts, subtracts what was added.

Do

Keep Attributes Identical

Use exactly the same label values when adding and subtracting so balances cancel properly.

Do

Pair with a Counter

Use a Counter for the all-time total and an UpDownCounter for the live balance of the same thing.

Do

Set a Unit and Description

Future readers will thank you, and units remove doubt about what one step means.

Do

Chart the Value Itself

Show the balance, compare it with limits, and alert on sustained levels.

Don’t

Use It for Ever-Growing Totals

Reach for a regular Counter so backends can compute rates and handle restarts.

Don’t

Use It for Readings

Temperatures and percentages belong in a Gauge, not in a faked balance.

Don’t

Add Unbounded Attributes

User identifiers and request identifiers create endless series and endless cost.

i
Debugging Tip

If a balance never returns to zero when the system is idle, search your code for any start path that lacks a matching end path, especially on errors, timeouts and cancelled work.

19Advantages and Trade-offs

Every design choice has a price, and the UpDownCounter is no exception.

Advantages

  • Naturally models quantities that rise and fall
  • Very cheap to record, even in busy code
  • Balances from many instances can be added meaningfully
  • Reports the live level, not just history
  • Marks the data as non-monotonic so backends interpret it correctly
  • Standard across languages and backends

Disadvantages / Trade-offs

  • Depends on every up being matched by a down, or the balance drifts
  • Attributes must stay identical between add and subtract
  • Forgets how many events happened in total
  • Short spikes between collections can go unseen
  • Not suitable for readings that are not additive

Balancing simplicity and correctness

The UpDownCounter is simple to use but unforgiving to sloppy code. The more places your program can start something, the more places must also end it. Teams that wrap the pair in a single helper, or that use the asynchronous style to read a balance maintained elsewhere, avoid most of the pain. When a trustworthy external reading exists, the observable form or a Gauge may be the safer choice.

20Real-World Examples

Seeing how teams use UpDownCounters makes the ideas concrete.

An online retailer on sale day

The retailer tracks requests in progress per route. During the sale, the checkout route balance climbs steadily while others stay flat, showing exactly which part of the system is struggling.

A messaging platform watching backlog

Producers add and consumers subtract on a queue balance. When a deployment slows consumers, the backlog line rises within minutes, and an alert on a sustained high level pages the team before users notice delays.

A bank monitoring database connections

The bank tracks connections lent out from each pool. A pool balance pinned at its maximum explains a series of slow transactions, and the team raises the pool size and fixes a leaking code path.

A game company tracking players online

Each game server adds on login and subtracts on logout. Summing the balances across all servers gives the live player count, and a sudden drop after a release points to a broken login flow.

A team that found a drifting balance

Engineers notice that requests in progress never falls to zero at night. They find an error path that skipped the subtraction, fix it with a guaranteed cleanup step, and the balance finally returns to zero when idle.

21Frequently Asked Questions

Q1What is an UpDownCounter in one sentence?

It is a metric instrument that records additions and subtractions to a running balance, so it can describe values that rise and fall, such as requests in progress.

Q2How is it different from a Counter?

A Counter only goes up and tells you how many events have happened in total. An UpDownCounter can also go down and tells you how much exists right now.

Q3What does non-monotonic mean?

It means the value is allowed to decrease as well as increase. Backends use this mark to avoid treating a drop as a reset.

Q4When should I use a Gauge instead?

Use a Gauge when you read a current value directly and adding values from different sources would be meaningless, such as temperature or a percentage.

Q5Do I tell the UpDownCounter the current value?

Not in the synchronous style. You report only changes, such as plus one or minus one, and the library keeps the balance. In the asynchronous style you report the current total through a callback.

Q6Why does my balance never return to zero?

Most likely some code path adds but never subtracts, often an error, timeout or cancellation path. Make sure every start has a guaranteed matching end.

Q7Why do I see a series stuck at a positive number and another at a negative number?

The attributes used when adding differ from those used when subtracting, so the two changes landed in different series. Use identical attributes for both.

Q8What happens to an UpDownCounter when the program restarts?

It starts again from zero, which is usually correct because a new process has nothing in flight.

Q9Should I chart the rate of an UpDownCounter?

Usually no. The value itself is the answer. A rate would mix arrivals and departures and is hard to interpret. Use a Counter if you want a rate.

Q10Which temporality is best for an UpDownCounter?

Cumulative is the natural fit, because each report directly shows the current balance and a lost report does not corrupt later ones.

Q11Can I add values from many service instances?

Yes. Balances of the same kind of thing are additive, so the sum across instances is the load on the whole system.

Q12Does an UpDownCounter slow my application down?

Very little. Each change is a tiny in-memory operation, and the heavy work of exporting happens rarely and off the main path.

22Summary and Key Takeaways

We began at a library desk where a single sheet records how many books are out right now: a plus when one leaves, a minus when one returns. An UpDownCounter in OpenTelemetry is exactly that sheet. It is a cheap, simple instrument for balances such as requests in progress, queue length, active connections and players online. Your code adds and subtracts, the SDK keeps the running balance, and a reader exports it on a schedule as a non-monotonic sum, usually in cumulative style. Choose it when the number rises and falls by steps, pair every up with a matching down, keep attributes identical on both sides, and chart the value itself. Choose a Counter for ever-growing totals, a Gauge for non-additive readings, and a Histogram for spreads of values.

Key Takeaways

  • An UpDownCounter records a balance — you add positive and negative changes, and it keeps the running total that tells you how much exists right now.
  • It is non-monotonic — unlike a Counter, the value may decrease, and backends use that mark to avoid treating drops as resets or computing growth rates.
  • Pick it for rise-and-fall quantities — requests in progress, queue length, active connections, pool usage and players online are classic examples.
  • Choose the right sibling — use a Counter for ever-growing totals, a Gauge for non-additive readings, and a Histogram for distributions such as latency.
  • Every up needs a matching down — guarantee the subtraction on every path, including errors and timeouts, or the balance will drift away from reality.
  • Keep attributes identical — use exactly the same label values when adding and subtracting, and avoid unbounded values that explode series counts.
  • Chart the value, not the rate — cumulative reporting suits balances, and alerts should watch for sustained levels rather than momentary spikes.