@@ -98,6 +98,19 @@ export class Registry<
9898 */
9999 static merge ( registers : Registry [ ] ) : Registry ;
100100
101+ /**
102+ * Creates a new Registry instance from an array of metrics that were
103+ * created by `registry.getMetricsAsJSON()`. Metrics are aggregated using
104+ * the method specified by their `aggregator` property, or by summation if
105+ * `aggregator` is undefined.
106+ * @param {Array } metricsArr Array of metrics, each of which created by
107+ * `registry.getMetricsAsJSON()`.
108+ * @returns {Registry } aggregated registry.
109+ */
110+ static aggregate < T extends RegistryContentType > (
111+ metricsArr : Array < object > ,
112+ ) : Registry < T > ; // TODO Promise?
113+
101114 /**
102115 * HTTP Prometheus Content-Type for metrics response headers.
103116 */
@@ -131,7 +144,7 @@ export const prometheusContentType: PrometheusContentType;
131144 */
132145export const openMetricsContentType : OpenMetricsContentType ;
133146
134- export class AggregatorRegistry <
147+ export class ClusterRegistry <
135148 T extends RegistryContentType ,
136149> extends Registry < T > {
137150 /**
@@ -142,17 +155,60 @@ export class AggregatorRegistry<
142155 clusterMetrics ( ) : Promise < string > ;
143156
144157 /**
145- * Creates a new Registry instance from an array of metrics that were
146- * created by `registry.getMetricsAsJSON()`. Metrics are aggregated using
147- * the method specified by their `aggregator` property, or by summation if
148- * `aggregator` is undefined.
149- * @param {Array } metricsArr Array of metrics, each of which created by
150- * `registry.getMetricsAsJSON()`.
151- * @returns {Registry } aggregated registry.
158+ * Sets the registry or registries to be aggregated. Call from workers to
159+ * use a registry/registries other than the default global registry.
160+ * @param {Array<Registry>|Registry } regs Registry or registries to be
161+ * aggregated.
162+ * @returns {void }
152163 */
153- static aggregate < T extends RegistryContentType > (
154- metricsArr : Array < object > ,
155- ) : Registry < T > ; // TODO Promise?
164+ static setRegistries (
165+ regs :
166+ | Array <
167+ Registry < PrometheusContentType > | Registry < OpenMetricsContentType >
168+ >
169+ | Registry < PrometheusContentType >
170+ | Registry < OpenMetricsContentType > ,
171+ ) : void ;
172+ }
173+
174+ export class WorkerRegistry < T extends RegistryContentType > extends Registry < T > {
175+ /**
176+ * Gets aggregated metrics for all workers.
177+ * @returns {Promise<string> } Promise that resolves with the aggregated
178+ * metrics.
179+ */
180+ workerMetrics ( ) : Promise < string > ;
181+
182+ addWorker ( worker : Worker ) : void ;
183+ /**
184+ * Sets the registry or registries to be aggregated. Call from workers to
185+ * use a registry/registries other than the default global registry.
186+ * @param {Array<Registry>|Registry } regs Registry or registries to be
187+ * aggregated.
188+ * @returns {void }
189+ */
190+ static setRegistries (
191+ regs :
192+ | Array <
193+ Registry < PrometheusContentType > | Registry < OpenMetricsContentType >
194+ >
195+ | Registry < PrometheusContentType >
196+ | Registry < OpenMetricsContentType > ,
197+ ) : void ;
198+ }
199+
200+ /**
201+ * @deprecated
202+ */
203+ export class AggregatorRegistry <
204+ T extends RegistryContentType ,
205+ > extends Registry < T > {
206+ /**
207+ * Gets aggregated metrics for all workers.
208+ * @returns {Promise<string> } Promise that resolves with the aggregated
209+ * metrics.
210+ */
211+ clusterMetrics ( ) : Promise < string > ;
156212
157213 /**
158214 * Sets the registry or registries to be aggregated. Call from workers to
0 commit comments