Closed zephyrpathsofglory closed 3 years ago
Hello!
Yup, collectDefaultMetrics
is called by apollo-prometheus-exporter
but you can avoid errors by:
createPrometheusExporterPlugin({
app,
defaultMetrics: false
});
createPrometheusExporterPlugin({
app,
defaultMetricsOptions: {
prefix: 'example-prefix',
}
});
using another registry:
import { Registry } from 'prom-client';
// ...
createPrometheusExporterPlugin({
app,
register: new Registry()
});
I think I should let this fail like it does currently but provide guidance about it in the readme.
Hello!
Yup,
collectDefaultMetrics
is called byapollo-prometheus-exporter
but you can avoid errors by:* disabling the default metrics: ```ts createPrometheusExporterPlugin({ app, defaultMetrics: false }); ``` * providing a prefix for the default metrics: ```ts createPrometheusExporterPlugin({ app, defaultMetricsOptions: { prefix: 'example-prefix', } }); ``` * using another registry: ```ts import { Registry } from 'prom-client'; // ... createPrometheusExporterPlugin({ app, register: new Registry() }); ```
I think I should let this fail like it does currently but provide guidance about it in the readme.
the solutions work.
Yes, more guidance is good. I will close the issue.
I have an express server with
express-prom-bundle
andapollo-prometheus-exporter
installed and set up, And when I start my server, it crashed.I guess the reason is that
express-prom-bundle
has registered theprocess_cpu_user_seconds_total
metric, andapollo-prometheus-exporter
also try to register this metric, so it crashed. (FYI, I foundexpress-prom-bundle
andapollo-prometheus-exporter
calledcollectDefaultMetrics
which is implement in prom-client)Is it suitable to rescue and ignore the error when we re-register a metric? Or is there anything we can do?