Multiple HTTP servers not supported
Closed this issue · 0 comments
Update:
PR #19 fixes this.
OLD:
I've tried to use the prometheus integration into vertx.
The problem ist that my server (running at port 4567) was never showing up in the data at /metrics
, only the internal server of the prometheus library was shown (port 9090).
I've traced this to the register call of the collector in io.prometheus.client.CollectorRegistry
(using the default registry).
If an HTTP server was registered then the 2nd, 3rd etc will be ignored (due to the IAE thrown and caught in io.vertx.ext.prometheus.metrics.PrometheusMetrics#register
without logging.
I've worked around this by calling CollectorRegistry.defaultRegistry.clear()
before starting my own vertx http server, but that's a bad workaround :)
Is this setup supposed to work?
Is the internal server supposed to register itself for the metrics and thus to disable all other servers?
Is there a better fix for this?
Code of the registry's register implementation:
public void register(Collector m) {
List<String> names = collectorNames(m);
synchronized (collectorsToNames) {
for (String name : names) {
if (namesToCollectors.containsKey(name)) {
throw new IllegalArgumentException("Collector already registered that provides name: " + name);
}
}
for (String name : names) {
namesToCollectors.put(name, m);
}
collectorsToNames.put(m, names);
}
}