Open akalittle opened 1 year ago
Regarding the customization of Prometheus buckets in go-zero, adding a buckets
option in prometheus.Config
seems like a feasible feature. For an immediate workaround, consider these steps:
Disable go-zero's Built-In Prometheus Handler: This prevents conflicts with the default metrics collection.
Implement a Custom Handler: Implement your handler on the built-in one but with your desired bucket sizes for the Prometheus histogram.
This is a personal suggestion and may need testing in your environment. For a long-term solution, you might want to raise a feature request on the go-zero repository.
This issue is stale because it has been open for 30 days with no activity.
In the
rest/handler/prometheushandler.go
fileThe biggest of bucket is 1000, however, in the service we use, we need to request third-party service, which may last more than 1s. So the metrics are always a straightness line....
But if I write a customized middleware like:
It works. But if a request URL is
/resource/:id
, there will be too many metrics likeresource/1 resource/2
. Not stored asresource/:id