Skip to content

feat: impact metric gauge#337

Merged
sjaanus merged 5 commits intomainfrom
impact-gauge
Dec 16, 2025
Merged

feat: impact metric gauge#337
sjaanus merged 5 commits intomainfrom
impact-gauge

Conversation

@sjaanus
Copy link
Copy Markdown
Contributor

@sjaanus sjaanus commented Dec 15, 2025

Gauge implementation. Next is histogram.

Comment on lines +27 to +34
counters.values().stream()
.map(CounterImpl::collect)
.filter(m -> !m.getSamples().isEmpty())
.forEach(collected::add);
gauges.values().stream()
.map(GaugeImpl::collect)
.filter(m -> !m.getSamples().isEmpty())
.forEach(collected::add);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found out that filtering out empty samples was missing.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Dec 15, 2025

Pull Request Test Coverage Report for Build 20264911164

Details

  • 36 of 50 (72.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.4%) to 78.356%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/main/java/io/getunleash/impactmetrics/InMemoryMetricRegistry.java 12 16 75.0%
src/main/java/io/getunleash/impactmetrics/GaugeImpl.java 20 30 66.67%
Totals Coverage Status
Change from base Build 20233151881: -0.4%
Covered Lines: 2704
Relevant Lines: 3338

💛 - Coveralls

Comment on lines +40 to +46
new CollectedMetric(
"labeled_counter",
"with labels",
MetricType.COUNTER,
List.of(sample(Map.of("foo", "bar"), 5L)));

assertThat(metrics).containsExactly(expected);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems just formatting

Comment on lines +82 to +85
assertThat(result.getName()).isEqualTo("multi_label");
assertThat(result.getSamples())
.containsExactlyInAnyOrder(
sample(Map.of("a", "x"), 1L), sample(Map.of("b", "y"), 2L), sample(3L));
.containsExactlyInAnyOrder(
sample(Map.of("a", "x"), 1L), sample(Map.of("b", "y"), 2L), sample(3L));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just formatting

public void should_return_zero_value_when_empty() {
InMemoryMetricRegistry registry = new InMemoryMetricRegistry();
registry.counter(new MetricOptions("noop_counter", "noop"));
registry.gauge(new MetricOptions("noop_gauge", "noop"));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests that gauge does not have zero default value.

private final String help;
private final ConcurrentHashMap<String, Long> values = new ConcurrentHashMap<>();

GaugeImpl(String name, String help) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in Node we accept MetricOptions that has 3 fields. why do we have 2 params here instead of the object param and how can we pass labelNames in the constructor as Node allows?

@github-project-automation github-project-automation Bot moved this from New to Approved PRs in Issues and PRs Dec 15, 2025
@sjaanus sjaanus merged commit 9178fa1 into main Dec 16, 2025
9 checks passed
@sjaanus sjaanus deleted the impact-gauge branch December 16, 2025 10:44
@github-project-automation github-project-automation Bot moved this from Approved PRs to Done in Issues and PRs Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants