Skip to content

Commit

Permalink
Allow inc with negative, and dec with positive, values for Gauge.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Nov 4, 2023
1 parent f8b969f commit 419b4e4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
6 changes: 0 additions & 6 deletions src/Prometheus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 419b4e4

Please sign in to comment.