prometheus / prometheus/client_js

Negative observations

Open
#247 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
JavaScript
Stars
3.5k
Forks
429
Avg merge
3d 3h
Merged PRs (30d)
22

Description

Hi,

I was assuming that histogram metric can handle negative observations, but it appears that it fails to do so and I haven't found any mention of this neither in this repository, nor in official description of Prometheus metrics. In fact, the latter explicitly states that negative observations are possible:

In principle, however, you can use summaries and histograms to observe negative values (e.g. temperatures in centigrade).

In my use case, being able to observe negative metrics is critical, so unfortunately I have to resort to the custom implementation of histogram metric.

On the other notice, the limitation seems to be relatively easy to eliminate - values that don't fall into last bucket could be handled separately.

Maybe you could consider extending implementation to support negative observations as well? Or are there any other reasons (e.g. compatibility) that prevent us from doing so? I would be happy to provide a PR myself.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the histogram implementation and its existing tests, then trace how observations outside the last bucket are handled. The issue is complete when negative observations work correctly, relevant histogram tests cover them, and any compatibility or documentation implications are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.