diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..1bf30d848 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ + +## 2.3.0 + +* Change the `observeAndSample` function from the + `System.Metrics.Prometheus.Metric.Histogram` module to return the value of + the sample that was just added, instead of the previous sample. + This change matches similar functions for `Counter`s and `Gauge`s. + [#51](https://github.com/bitnomial/prometheus/pull/51) diff --git a/prometheus.cabal b/prometheus.cabal index fb91b64fb..1feb401c1 100644 --- a/prometheus.cabal +++ b/prometheus.cabal @@ -1,5 +1,5 @@ name: prometheus -version: 2.2.4 +version: 2.3.0 synopsis: Prometheus Haskell Client homepage: http://github.com/bitnomial/prometheus bug-reports: http://github.com/bitnomial/prometheus/issues @@ -7,7 +7,7 @@ license: BSD3 license-file: LICENSE author: Luke Hoersten maintainer: luke@bitnomial.com, opensource@bitnomial.com -copyright: Bitnomial, Inc. (c) 2016-2019 +copyright: Bitnomial, Inc. (c) 2016-2023 category: Metrics, Monitoring, Web, System build-type: Simple cabal-version: >=1.10 diff --git a/src/System/Metrics/Prometheus/Metric/Counter.hs b/src/System/Metrics/Prometheus/Metric/Counter.hs index f76a3edcd..70d8148f4 100644 --- a/src/System/Metrics/Prometheus/Metric/Counter.hs +++ b/src/System/Metrics/Prometheus/Metric/Counter.hs @@ -15,7 +15,7 @@ import Data.Atomics.Counter (AtomicCounter, incrCounter, newCounter, writeCounte newtype Counter = Counter {unCounter :: AtomicCounter} -newtype CounterSample = CounterSample {unCounterSample :: Int} +newtype CounterSample = CounterSample {unCounterSample :: Int} deriving Show new :: IO Counter diff --git a/src/System/Metrics/Prometheus/Metric/Gauge.hs b/src/System/Metrics/Prometheus/Metric/Gauge.hs index 76610e221..3c0852e2c 100644 --- a/src/System/Metrics/Prometheus/Metric/Gauge.hs +++ b/src/System/Metrics/Prometheus/Metric/Gauge.hs @@ -16,7 +16,7 @@ import Data.IORef (IORef, atomicModifyIORef', newIORef) newtype Gauge = Gauge {unGauge :: IORef Double} -newtype GaugeSample = GaugeSample {unGaugeSample :: Double} +newtype GaugeSample = GaugeSample {unGaugeSample :: Double} deriving Show new :: IO Gauge diff --git a/src/System/Metrics/Prometheus/Metric/Histogram.hs b/src/System/Metrics/Prometheus/Metric/Histogram.hs index fbd26528a..39a49c26a 100644 --- a/src/System/Metrics/Prometheus/Metric/Histogram.hs +++ b/src/System/Metrics/Prometheus/Metric/Histogram.hs @@ -36,6 +36,7 @@ data HistogramSample = HistogramSample , histSum :: !Double , histCount :: !Int } + deriving Show new :: [UpperBound] -> IO Histogram @@ -49,7 +50,7 @@ new buckets = Histogram <$> newIORef empty observeAndSample :: Double -> Histogram -> IO HistogramSample observeAndSample x = flip atomicModifyIORef' update . unHistogram where - update histData = (hist' histData, histData) + update histData = (hist' histData, hist' histData) hist' histData = histData { histBuckets = updateBuckets x $ histBuckets histData diff --git a/src/System/Metrics/Prometheus/Metric/Summary.hs b/src/System/Metrics/Prometheus/Metric/Summary.hs index 98f2498ef..feff1b230 100644 --- a/src/System/Metrics/Prometheus/Metric/Summary.hs +++ b/src/System/Metrics/Prometheus/Metric/Summary.hs @@ -8,3 +8,4 @@ data SummarySample = SummarySample , sumSum :: !Int , sumCount :: !Int } + deriving Show