Skip to content

Commit

Permalink
Merge pull request #922 from gbregman/devel
Browse files Browse the repository at this point in the history
Move the Prometheus startup to the end of the server initialization
  • Loading branch information
gbregman authored Oct 28, 2024
2 parents c5c20f0 + b9f2113 commit 8672db1
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 8672db1

Please sign in to comment.