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

prometheus / client_ruby / 746
100%
master: 100%

Build:
Build:
LAST BUILD BRANCH: fix_with_labels
DEFAULT BRANCH: master
Ran 12 Jun 2021 06:01PM UTC
Jobs 5
Files 32
Run time 4min
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

pending completion
746

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.

Signed-off-by: Daniel Magliola <dmagliola@crystalgears.com>

10 of 10 new or added lines in 2 files covered. (100.0%)

1690 of 1690 relevant lines covered (100.0%)

63.84 hits per line

Jobs
ID Job ID Ran Files Coverage
1 746.1 (2.5.8) 12 Jun 2021 06:01PM UTC 0
100.0
Travis Job 746.1
2 746.2 (2.6.6) 12 Jun 2021 06:01PM UTC 0
100.0
Travis Job 746.2
3 746.3 (2.7.2) 12 Jun 2021 06:01PM UTC 0
100.0
Travis Job 746.3
4 746.4 (3.0.0) 12 Jun 2021 06:03PM UTC 0
100.0
Travis Job 746.4
5 746.5 (jruby-9.1.9.0) 12 Jun 2021 06:06PM UTC 0
0.0
Travis Job 746.5
Source Files on build 746
  • Tree
  • List 32
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Travis Build #746
  • 316faf7c on github
  • Prev Build on fix_with_labels (#744)
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