Fix prometheus metrics
Use a singleton to prevent attempt to rebind socket on page reload.
This commit is contained in:
parent
fcfec4b6a9
commit
82263557af
3 changed files with 30 additions and 15 deletions
|
|
@ -1,9 +1,10 @@
|
|||
class Counter:
|
||||
def __init__(self, line_orientation):
|
||||
def __init__(self, line_orientation, metrics):
|
||||
self.in_count = 0
|
||||
self.out_count = 0
|
||||
self.track_memory = {}
|
||||
self.line_orientation = line_orientation
|
||||
self.metrics = metrics
|
||||
|
||||
def update(self, tracks, line_position):
|
||||
for track in tracks:
|
||||
|
|
@ -27,5 +28,7 @@ class Counter:
|
|||
|
||||
if prev < line_position <= center:
|
||||
self.in_count += 1
|
||||
self.metrics["people_in"].inc()
|
||||
elif prev > line_position >= center:
|
||||
self.out_count += 1
|
||||
self.metrics["people_out"].inc()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue