pinax-network / substreams-sink

Substreams Sink library
MIT License
4 stars 1 forks source link

A metric with the name `X` has already been registered #11

Closed DenisCarriere closed 1 year ago

DenisCarriere commented 1 year ago

Receiving the following error

{"nativeError":{},"name":"Error","message":"A metric with the name trace_calls has already been registered.","stack":[{"fullFilePath":"/node_modules/prom-client/lib/registry.js:67:10","fileName":"registry.js","fileNameWithLine":"registry.js:67","fileColumn":"10","fileLine":"67","filePath":"node_modules/prom-client/lib/registry.js","filePathWithLine":"node_modules/prom-client/lib/registry.js:67","method":"Registry.registerMetric"},{"fullFilePath":"/node_modules/prom-client/lib/metric.js:48:13","fileName":"metric.js","fileNameWithLine":"metric.js:48","fileColumn":"13","fileLine":"48","filePath":"node_modules/prom-client/lib/metric.js","filePathWithLine":"node_modules/prom-client/lib/metric.js:48","method":"new Metric"},

Perhaps might need to check if the gauge/counter exists before registering a 2nd time.

if ( !prometheus.registry.getSingleMetric(name) ) {
    prometheus.registerGauge(name, "custom help", Object.keys(labels));
}
DenisCarriere commented 1 year ago

Seems to be fixed