Skip to content

Commit

Permalink
Added UP/DOWN status metric of the decision engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Redjacket45 authored and mambelli committed Aug 30, 2022
1 parent fc76a1f commit 0c15d3b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/decisionengine/framework/engine/DecisionEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
QUERY_TOOL_HISTOGRAM = Histogram("de_client_query_duration_seconds", "Time to run de-client --query", ["product"])
METRICS_HISTOGRAM = Histogram("de_client_metrics_duration_seconds", "Time to run de-client --status")
WORKERS_COUNT = Gauge("de_workers_total", "Number of workers started by the Decision Engine")

DE_STATUS = Gauge("de_status", "Status of Decision Engine server")

class StopState(enum.Enum):
NotFound = 1
Expand Down Expand Up @@ -944,6 +944,7 @@ def _start_de_server(server):
start_channels_thread.start()

server.get_logger().debug("running _start_de_server: step serve_forever")
DE_STATUS.set(1)
server.serve_forever(
poll_interval=1
) # Once per second is sufficient, given the amount of work done in the service actions.
Expand All @@ -961,6 +962,7 @@ def _start_de_server(server):
raise __e
finally:
start_channels_thread.join(None)
DE_STATUS.set(0)
server.shutdown_complete.wait()
r = redis.Redis.from_url(server.broker_url)
while _requests_in_flight(r, server.exchange.name):
Expand Down

0 comments on commit 0c15d3b

Please sign in to comment.