Skip to content

[!] refactor Prometheus sink, closes #1267#1289

Merged
pashagolub merged 4 commits intomasterfrom
prom-refactor
Mar 11, 2026
Merged

[!] refactor Prometheus sink, closes #1267#1289
pashagolub merged 4 commits intomasterfrom
prom-refactor

Conversation

@pashagolub
Copy link
Copy Markdown
Collaborator

  • send immediately without returning slice in WritePromMetrics()
  • add de-duplication for produced Prom metrics
  • use NewConstMetric instead of MustNewConstMetric
  • create cache snapshots during Collect() instead of clearing it, which safely enables parallel scrapes
  • sort label keys lexicographically to guarantee deterministic descriptor identities and avoid Prometheus "duplicate metric" errors
  • add unit tests

- send immediately without returning slice in `WritePromMetrics()`
- add de-duplication for produced Prom metrics
- use `NewConstMetric` instead of `MustNewConstMetric`
- create cache snapshots during `Collect()` instead of clearing it,
which safely enables parallel scrapes
- sort label keys lexicographically to guarantee deterministic
descriptor identities and avoid Prometheus "duplicate metric" errors
- add unit tests
@pashagolub pashagolub self-assigned this Mar 10, 2026
@pashagolub pashagolub added the sinks Where and how to store monitored data label Mar 10, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 10, 2026

Pull Request Test Coverage Report for Build 22946701892

Details

  • 82 of 85 (96.47%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.7%) to 83.062%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/sinks/prometheus.go 82 85 96.47%
Files with Coverage Reduction New Missed Lines %
internal/reaper/reaper.go 4 37.04%
Totals Coverage Status
Change from base Build 22900897986: 0.7%
Covered Lines: 4541
Relevant Lines: 5467

💛 - Coveralls

@pashagolub pashagolub marked this pull request as ready for review March 11, 2026 09:57
@pashagolub pashagolub merged commit 9d0d505 into master Mar 11, 2026
4 checks passed
@pashagolub pashagolub deleted the prom-refactor branch March 11, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sinks Where and how to store monitored data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants