Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
Polish micrometer-metricsgh-4608
The test was not testing the changes made (it would have passed before the changes to main code), so I removed it.
Removed the unused constructor in MicrometerCollector because it is a package private class we know all the callsites.
  • Loading branch information
shakuzen committed Jan 31, 2024
1 parent 864f58a commit f2fa7a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,9 @@ class MicrometerCollector extends Collector implements Collector.Describable {

private final String help;

public MicrometerCollector(Meter.Id id, NamingConvention convention, PrometheusConfig config) {
this.id = id;
this.conventionName = id.getConventionName(convention);
this.tagKeys = id.getConventionTags(convention).stream().map(Tag::getKey).collect(toList());
this.help = config.descriptions() ? Optional.ofNullable(id.getDescription()).orElse(" ") : " ";
}

public MicrometerCollector(String name, Meter.Id id, NamingConvention convention, PrometheusConfig config) {
// take name to avoid calling NamingConvention#name after the callsite has already
// done it
MicrometerCollector(String name, Meter.Id id, NamingConvention convention, PrometheusConfig config) {
this.id = id;
this.conventionName = name;
this.tagKeys = id.getConventionTags(convention).stream().map(Tag::getKey).collect(toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@

class MicrometerCollectorTest {

NamingConvention convention = NamingConvention.snakeCase;

@Issue("#769")
@Test
void manyTags() {
Meter.Id id = Metrics.counter("my.counter").getId();
MicrometerCollector collector = new MicrometerCollector(id, NamingConvention.dot, PrometheusConfig.DEFAULT);
MicrometerCollector collector = new MicrometerCollector(id.getConventionName(convention), id, convention,
PrometheusConfig.DEFAULT);

for (Integer i = 0; i < 20_000; i++) {
Collector.MetricFamilySamples.Sample sample = new Collector.MetricFamilySamples.Sample("my_counter",
Expand All @@ -52,7 +55,8 @@ void manyTags() {
@Test
void sameValuesDifferentOrder() {
Meter.Id id = Metrics.counter("my.counter").getId();
MicrometerCollector collector = new MicrometerCollector(id, NamingConvention.dot, PrometheusConfig.DEFAULT);
MicrometerCollector collector = new MicrometerCollector(id.getConventionName(convention), id, convention,
PrometheusConfig.DEFAULT);

Collector.MetricFamilySamples.Sample sample = new Collector.MetricFamilySamples.Sample("my_counter",
asList("k", "k2"), asList("v1", "v2"), 1.0);
Expand Down

This file was deleted.

0 comments on commit f2fa7a3

Please sign in to comment.