• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

prometheus / client_ruby / 744 / 2
100%
master: 100%

Build:
Build:
LAST BUILD BRANCH: fix_with_labels
DEFAULT BRANCH: master
Ran 12 Jun 2021 05:58PM UTC
Files 32
Run time 1s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 Jun 2021 05:53PM UTC coverage: 100.0%. First build
2.6.6

push

travis-ci

dmagliola
Use the original metric's store in `with_labels` clone

When calling `with_labels` on a metric object (let's call it "the original"),
we instantiate a new metric (the "clone") that is identical except that
it has some more pre-set labels, that allow the caller to observe it
without having to specify the labels every time.

"currying", if you will.

The problem with the existing code (as exemplified by issue #225, and by
the tests introduced in the previous commit), is that as part of making
this new metric, we end up instantiating a new store for this metric.

With in-memory stores, the new one will be empty. With file stores, it'll
bring over the data from the original metric until the point the clone
gets observed once, at which point they fork, while pointing at the same
file and keeping separate internal state. An almost sure recipe for file
corruption.

And when exporting, only the data in the "original" metric's store will
be exported, the clone's will be ignored, assuming files didn't get
corrupted.

The fix is not particularly elegant, but I don't see any way around it:
we replace the internal store of the "clone" metric with the one from
the "original", through the use of a protected method.

The only real alternative is getting rid of `with_labels`, which is a
nice-to-have for convenience and performance, but not a necessity.

1706 of 1706 relevant lines covered (100.0%)

16.05 hits per line

Source Files on job 744.2 (2.6.6)
  • Tree
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 707
  • Travis Job 744.2
  • 6627a5d8 on github
  • Next Job for 2.6.6 on fix_with_labels (#746.2)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc