Skip to content

v1.7.10

Compare
Choose a tag to compare
@depado depado released this 18 Apr 13:19
9f1d545
Add new RequestPathFunc feature to customize request path (#41)

* feat: new RequestPathFunc to retrieve request path and corresponding option on *Prometheus

Recording metrics for routes not registered on the instrumented root *gin.Router currently requires defining a side-middleware mimicking the *Prometheus internals, that is, declaring counters, histograms and summaries for the metrics one wants to record, and "manually" handling them inside the middleware.
With RequestPathFunc, one can monitor calls to unregistered routes by setting RequestPathFunc to some function that returns a default value if the request path is undefined.

Even finer-grained monitoring is made possible by this commit, e.g. recording a metric with the (*http.Request).RequestURI rather than the (*gin.Context).Fullpath() return value.

* feat: add test for new feature RequestPathFunc