fiberprometheus icon indicating copy to clipboard operation
fiberprometheus copied to clipboard

Not collect custom metrics

Open bigotto opened this issue 1 year ago • 1 comments

After upgrade version to 2.7.0 stopped work custom metrics. Endpoint /metrics don't cause any error, have only defaults metrics ( http_requests_total, http_request_duration_seconds, http_requests_in_progress_total, http_cache_results)

Using fiber at v2.52.5

PS.: After downgrade to 2.6, works correctly

bigotto avatar Sep 08 '24 23:09 bigotto

I'm having same issue.

The problem are : https://github.com/ansrivas/fiberprometheus/blob/7755f92e96f9515a7511f63ed16668043fd18b4b/middleware.go#L156 https://github.com/ansrivas/fiberprometheus/blob/7755f92e96f9515a7511f63ed16668043fd18b4b/middleware.go#L167 https://github.com/ansrivas/fiberprometheus/blob/7755f92e96f9515a7511f63ed16668043fd18b4b/middleware.go#L179

in these 3 cases, before was

func New(serviceName string) *FiberPrometheus {
	return create(prometheus.DefaultRegisterer, serviceName, "http", "", nil)
}

and now is

func New(serviceName string) *FiberPrometheus {
	return create(nil, serviceName, "http", "", nil)
}

since this change, are not publishing custom metrics properly

pineda89 avatar Sep 17 '24 15:09 pineda89

Run into the same problem. I suppose we should switch to fiberprometheus.NewWithRegistry(prometheus.DefaultRegisterer, ... instead?

alanhe avatar Sep 27 '24 10:09 alanhe

@alanhe Yes, the reason for the change was that the DefaultRegisterer is shared across modules, so multiple things were updating the same thing. This was exposed when the unit-tests were changed to run in Parallel.

gaby avatar Oct 06 '24 22:10 gaby

I can add a function called NewWithDefault or something, that uses default registerer.

gaby avatar Oct 06 '24 23:10 gaby