prometheus-chi-metric-middleware
所属分类:中间件编程
开发工具:GO
文件大小:0KB
下载次数:0
上传日期:2023-08-23 11:27:08
上 传 者:
sh-1993
说明: 为chi路由器提供简单的prometheus服务器指标,
(Provide easy prometheus server metrics for the chi router,)
文件列表:
chiprometheus.go (3349, 2023-08-23)
example/ (0, 2023-08-23)
example/main.go (1377, 2023-08-23)
go.mod (625, 2023-08-23)
go.sum (2960, 2023-08-23)
# prometheus-chi-metric-middleware
Easy prometheus http server metrics for the chi router.
Based on [chi-prometheus](https://github.com/766b/chi-prometheus)
## Install
```bash
go get github.com/TomL-dev/prometheus-chi-metric-middleware
```
## Usage
```go
import (
chiprometheus "github.com/TomL-dev/prometheus-chi-metric-middleware"
)
r := chi.NewRouter()
metricMiddleware := chiprometheus.NewMiddleware(chiprometheus.Options{
Namespace: "mock",
})
r.Use(metricMiddleware.Handler)
```
For other info, see the [example dir](./example/main.go)
## Result
On the `metric` endpoint of prometheus you'll see the timeseries created by the middleware. The following timeseries will be defined:
- [Counter] http_request_total{code, path}
- [Histogram] http_request_duration_nanoseconds{path}
- [Histogram] http_response_size_bytes{path}
## TODO
- custom bucket sizes
- now by default, it's matched on vars, instead of the actual values. (like /user/{id}). maybe make optional?
- exclusion patterns?
近期下载者:
相关文件:
收藏者: