When i tried to make clusterMetrics() collector i had an issue where this function always get errorTimeout.
Master process code:
private aggregator: Client.AggregatorRegistry<Client.RegistryContentType>
constructor() {
this.aggregator = new Client.AggregatorRegistry()
}
getMetrics = async () => {
const workersMetrics = await this.aggregator.clusterMetrics()
return workersMetrics
}
worker code:
private registry: Client.Registry
constructor() {
this.registry = new Client.Registry()
Client.AggregatorRegistry.setRegistries(this.registry)
//some metrics
}
After searching source code i found that listeners for message GET_METRICS_REQ only apply if Client.AggregatorRegistry class constructor is runned (basically worker need new Client.AggregatorRegistry() too)
Source code in node_modules/prom-client/lib/cluster.js

setRegistries:

Suggestions(variants):
- add listeners when setRegistries run - function for listeners already have check for duplicate run
- add static call for addListeners() function and add it to guide - so it could be run separately and manually
When i tried to make clusterMetrics() collector i had an issue where this function always get errorTimeout.
Master process code:
worker code:
After searching source code i found that listeners for message GET_METRICS_REQ only apply if Client.AggregatorRegistry class constructor is runned (basically worker need new Client.AggregatorRegistry() too)
Source code in node_modules/prom-client/lib/cluster.js


setRegistries:
Suggestions(variants):