Skip to content

Commit

Permalink
Need to support no-op Gauge after all
Browse files Browse the repository at this point in the history
  • Loading branch information
tjquinno committed Nov 19, 2021
1 parent c74a984 commit 0bcaedc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ static class NoOpGaugeImpl<T /* extends Number */> extends NoOpMetricImpl implem
return new NoOpGaugeImpl<>(registryType, metadata, metric);
}

static <S /* extends Number */> NoOpGaugeImpl<S> create(String registryType, Metadata metadata) {
// TODO uncomment above once MP metrics enforces the Number restriction
return new NoOpGaugeImpl<>(registryType, metadata, () -> null);
}

private NoOpGaugeImpl(String registryType, Metadata metadata, Gauge<T> metric) {
super(registryType, metadata);
value = metric::getValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
class NoOpMetricRegistry extends AbstractRegistry<NoOpMetric> {

private static final Map<MetricType, BiFunction<String, Metadata, NoOpMetric>> NO_OP_METRIC_FACTORIES =
// Omit gauge because creating a gauge requires an existing delegate instance.
// These factory methods do not use delegates.
Map.of(MetricType.COUNTER, NoOpMetricImpl.NoOpCounterImpl::create,
MetricType.GAUGE, NoOpMetricImpl.NoOpGaugeImpl::create,
MetricType.HISTOGRAM, NoOpMetricImpl.NoOpHistogramImpl::create,
MetricType.METERED, NoOpMetricImpl.NoOpMeterImpl::create,
MetricType.TIMER, NoOpMetricImpl.NoOpTimerImpl::create,
Expand Down

0 comments on commit 0bcaedc

Please sign in to comment.