You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be a good to have support for examplar metrics
func (ps*FiberPrometheus) RegisterAt(app fiber.Router, urlstring, handlers...fiber.Handler) {
ps.defaultURL=urlh:=append(handlers, adaptor.HTTPHandler(promhttp.HandlerFor(ps.gatherer, promhttp.HandlerOpts{
EnableOpenMetrics: true,
})))
app.Get(ps.defaultURL, h...)
}
func (ps*FiberPrometheus) Middleware(ctx*fiber.Ctx) error {
...// Update the request duration histogramelapsed:=float64(time.Since(start).Nanoseconds()) /1e9// Extract the trace ID from the user context to use it as an exemplar if available.traceID:=trace.SpanContextFromContext(ctx.UserContext()).TraceID()
// Retrieve the histogram metric for request duration, labeled with status code, method, and path.histogram:=ps.requestDuration.WithLabelValues(statusCode, method, path)
// Check if the trace ID is valid to potentially use it as an exemplar.iftraceID.IsValid() {
// If the histogram supports exemplars, record the observed duration with the trace ID as an exemplar.ifhistogramExemplar, ok:=histogram.(prometheus.ExemplarObserver); ok {
histogramExemplar.ObserveWithExemplar(elapsed, prometheus.Labels{"traceID": traceID.String()})
}
}
// Record the observed duration in the histogram.histogram.Observe(elapsed)
returnerr
}
IDK if there will be a performance hit on this. But it's working. Happy to hear better way of handling this
The text was updated successfully, but these errors were encountered:
It should be a good to have support for examplar metrics
IDK if there will be a performance hit on this. But it's working. Happy to hear better way of handling this
The text was updated successfully, but these errors were encountered: