prometheus / prometheus/client_python

Histogram without label creates histogram_*.db even without data

Open
#1,022 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.4k
Forks
876
Avg merge
8d 4h
Merged PRs (30d)
1

Description

I tried this with versions: 0.19.0 and 0.20.0, both seem to have this bug.

I have a script prom_example.py:

from prometheus_client import Histogram

Example = Histogram("example", "Example", "lol")

When I run it:

prometheus_multiproc_dir=/tmp/metrics python prom_example.py

I see nothing in /tmp/metrics (as expected).

But when I edit the script and remove the label from histogram:

from prometheus_client import Histogram

Example = Histogram("example", "Example")

Database is created is /tmp/metrics, named for example: histogram_37373.db I would expect no database creation, since no data is pushed into the metric.

Edit: it seems the behaviour is the same for Counter and Gauge

Contributor guide

Open the contributing guide

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

Reproduce the issue with the prom_example.py script and prometheus_multiproc_dir using a label-free Histogram, then compare it with the labeled case. Check the initialization paths for Histogram, Counter, and Gauge; done means no .db file is created before any metric data is recorded.

Written by the indexing model from the issue text.

Assessment

Tech stack
prometheus, python
Domain
observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.