proxy: feat: add option to expose the stats by using metrics
This is an alternative implementation of the MR#103
Enable the exposing metrics using Prometheus on the endpoint /internal/metrics
. The used mechanism is based on the SnowflakeEventDispatcher, only its data is available to the collector and nothing else is leaked.
I added the following CLI flags:
- disableStatsLogger: disable the stats logger using the log
- metrics: enable the stats logger using the Prometheus metrics
- metrics-port: set the port on which the Prometheus metrics server listens
Hint: The new CLI flags shouldn't change the behaviour of the original proxy. So, the new feature doesn't disable the original stats mechanism.
Example:
snowflake-proxy --metrics --metrics-port 8081 --disable-stats-logger
On the new endpoint: http://localhost:8081/internal/metrics
The core part of this is from Issue#40121