From 20e7fc743889ef35f1ac9c751d44574d86a24e51 Mon Sep 17 00:00:00 2001 From: Joe Smith Date: Tue, 16 Apr 2019 10:45:36 -0700 Subject: [PATCH] Review fixups --- Sources/Prometheus/MetricTypes/Counter.swift | 3 ++- Sources/Prometheus/MetricTypes/Gauge.swift | 8 ++------ Sources/Prometheus/MetricTypes/Summary.swift | 2 -- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Sources/Prometheus/MetricTypes/Counter.swift b/Sources/Prometheus/MetricTypes/Counter.swift index 04f833e..97d5468 100644 --- a/Sources/Prometheus/MetricTypes/Counter.swift +++ b/Sources/Prometheus/MetricTypes/Counter.swift @@ -73,10 +73,11 @@ public class Counter: Metric, Prometheus var val = self.metrics[labels] ?? self.initialValue val += amount self.metrics[labels] = val + done(val) } else { self.value += amount + done(self.value) } - done(self.value) } } diff --git a/Sources/Prometheus/MetricTypes/Gauge.swift b/Sources/Prometheus/MetricTypes/Gauge.swift index a96eabf..0757387 100644 --- a/Sources/Prometheus/MetricTypes/Gauge.swift +++ b/Sources/Prometheus/MetricTypes/Gauge.swift @@ -109,9 +109,7 @@ public class Gauge: Metric, PrometheusHa /// - done: Completion handler /// public func inc(_ labels: Labels? = nil, _ done: @escaping (NumType) -> Void = { _ in }) { - self.inc(1, labels) { value in - done(value) - } + self.inc(1, labels, done) } /// Decrements the Gauge @@ -141,9 +139,7 @@ public class Gauge: Metric, PrometheusHa /// - labels: Labels to attach to the value /// public func dec(_ labels: Labels? = nil, _ done: @escaping (NumType) -> Void = { _ in }) { - self.dec(1, labels) { value in - done(value) - } + self.dec(1, labels, done) } /// Gets the value of the Gauge diff --git a/Sources/Prometheus/MetricTypes/Summary.swift b/Sources/Prometheus/MetricTypes/Summary.swift index e8edca9..a02f26e 100644 --- a/Sources/Prometheus/MetricTypes/Summary.swift +++ b/Sources/Prometheus/MetricTypes/Summary.swift @@ -1,5 +1,3 @@ -import Dispatch - /// Default quantiles used by Summaries public var defaultQuantiles = [0.01, 0.05, 0.5, 0.9, 0.95, 0.99, 0.999]