Gracefully shuts down the metrics server.
Notifies observers that the metrics server is stopping and then closes the underlying web server.
A promise that resolves when the server has been successfully closed.
Retrieves the address information associated with the server.
The address information if available; otherwise, undefined
.
Starts the metrics server on the specified port.
Initializes a web server using the provided port and sets up a fetch callback to handle incoming requests. Notifies observers about the server startup and stores the server and address instances for later use.
The port number on which the metrics server should listen.
Optional
appName: `${string}-${string}`(Optional) The application name in the format ${string}-${string}
.
A promise that resolves when the server has started.
Provides a metrics server for exposing application and process metrics.
The
MetricsServer
class initializes and manages a web server that exposes metrics endpoints for Prometheus scraping and real-time metrics streaming. It supports graceful startup and shutdown, notifies observers of server events, and provides access to collected metrics such as event loop delay, memory usage, and CPU statistics.Remarks
/
endpoint returns dashboard UI/metrics
endpoint returns Prometheus-formatted metrics./metrics-stream
endpoint provides a real-time event stream of metrics updates.curl -H Accept:text/event-stream http://localhost:9090/metrics-stream