Skip to content

Commit

Permalink
Merge pull request #10 from toshi0607/feature/update-readme
Browse files Browse the repository at this point in the history
Update readme
  • Loading branch information
toshi0607 authored Aug 12, 2022
2 parents 0ccf18d + 2dcf1dd commit 6f0684a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ chi-prometheus is uses as a middleware. It also supports both a default registry
```go
r := chi.NewRouter()
m := chiprometheus.New("test")
# use DefaultRegisterer
m.MustRegisterDefault()
r.Use(m.Handler)
r.Handle("/metrics", promhttp.Handler())
r.Get(`/healthz`, [YOUR HandlerFunc])
r.Get("/healthz", [YOUR HandlerFunc])
```

### Custom registry

```go
r := chi.NewRouter()
# use your registry that works well with promauto
# see also https://github.com/prometheus/client_golang/issues/716#issuecomment-590282553
reg := prometheus.NewRegistry()
if err := reg.Register(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})); err != nil {
t.Error(err)
Expand All @@ -61,7 +64,7 @@ chi-prometheus is uses as a middleware. It also supports both a default registry
)
r.Use(m.Handler)
r.Handle("/metrics", promh)
r.Get(`/healthz`, [YOUR HandlerFunc])
r.Get("/healthz", [YOUR HandlerFunc])
```

## Install
Expand Down
6 changes: 3 additions & 3 deletions middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func TestMiddleware_Handler(t *testing.T) {
})
r.Use(m.Handler)
r.Handle("/metrics", promhttp.Handler())
r.Get(`/healthz`, testHandler)
r.Get(`/users/{firstName}`, testHandler)
r.Get("/healthz", testHandler)
r.Get("/users/{firstName}", testHandler)

paths := [][]string{
{"healthz"},
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestMiddleware_HandlerWithCustomRegistry(t *testing.T) {

r.Use(m.Handler)
r.Handle("/metrics", promh)
r.Get(`/healthz`, testHandler)
r.Get("/healthz", testHandler)

paths := [][]string{
{"healthz"},
Expand Down

0 comments on commit 6f0684a

Please sign in to comment.