Skip to content

Commit

Permalink
Move the Prometheus startup to the end of the server initialization.
Browse files Browse the repository at this point in the history
Fixes #919

Signed-off-by: Gil Bregman <[email protected]>
  • Loading branch information
gbregman committed Oct 28, 2024
1 parent c5c20f0 commit b9f2113
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions control/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ def _wait_for_group_id(self):
self.logger.info("The MonitorGroup gRPC server stopped...")
self.monitor_server = None

def start_prometheus(self):
###Starts the prometheus endpoint if enabled by the config.###

if self.config.getboolean_with_default("gateway", "enable_prometheus_exporter", True):
self.logger.info("Prometheus endpoint is enabled")
start_exporter(self.spdk_rpc_client, self.config, self.gateway_rpc, self.logger)
else:
self.logger.info(f"Prometheus endpoint is disabled. To enable, set the config option 'enable_prometheus_exporter = True'")

def serve(self):
"""Starts gateway server."""
self.logger.info(f"Starting serve, monitor client version: {self._monitor_client_version()}")
Expand Down Expand Up @@ -238,13 +247,6 @@ def serve(self):
# Start server
self.server.start()

# Start the prometheus endpoint if enabled by the config
if self.config.getboolean_with_default("gateway", "enable_prometheus_exporter", True):
self.logger.info("Prometheus endpoint is enabled")
start_exporter(self.spdk_rpc_client, self.config, self.gateway_rpc, self.logger)
else:
self.logger.info(f"Prometheus endpoint is disabled. To enable, set the config option 'enable_prometheus_exporter = True'")

# Set SPDK log level
log_level_args = {}
log_level = self.config.get_with_default("spdk", "log_level", None)
Expand All @@ -255,6 +257,9 @@ def serve(self):

self._register_service_map()

# This should be at the end of the function, after the server is up
self.start_prometheus()

def _register_service_map(self):
# show gateway in "ceph status" output
conn = self.omap_state.conn
Expand Down

0 comments on commit b9f2113

Please sign in to comment.