From 419b4e4f7d9835c8b56c4b1c42d4922be8d49a18 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sat, 4 Nov 2023 13:57:56 +0100 Subject: [PATCH] Allow inc with negative, and dec with positive, values for Gauge. --- src/Prometheus.jl | 6 ------ test/runtests.jl | 2 -- 2 files changed, 8 deletions(-) diff --git a/src/Prometheus.jl b/src/Prometheus.jl index 21fff38..2efeef1 100644 --- a/src/Prometheus.jl +++ b/src/Prometheus.jl @@ -236,9 +236,6 @@ Increment the value of the gauge `g` with `v`. `v` defaults to `v = 1`. """ function inc(m::Gauge, v = 1.0) - if v < 0 - error("incrementing with negative value, use dec(...)?") - end @atomic m.value += v return nothing end @@ -250,9 +247,6 @@ Decrement the value of the gauge `g` with `v`. `v` defaults to `v = 1`. """ function dec(m::Gauge, v = 1.0) - if v < 0 - error("decrementing with negative value, use inc(...)?") - end @atomic m.value -= v return nothing end diff --git a/test/runtests.jl b/test/runtests.jl index bd5cbe8..c14f7d4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -76,13 +76,11 @@ end @test c.value == 1 Prometheus.inc(c, 2) @test c.value == 3 - @test_throws ErrorException Prometheus.inc(c, -1) # Prometheus.dec(...) Prometheus.dec(c) @test c.value == 2 Prometheus.dec(c, 1) @test c.value == 1 - @test_throws ErrorException Prometheus.dec(c, -1) # Prometheus.set_to_current_time(...) t0 = time() sleep(0.1)