Skip to content

Commit be48cb1

Browse files
authored
Add root docs (#27)
Add root docs
2 parents 2e69403 + 66c9490 commit be48cb1

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ deps:
3232
mocks:
3333
$(MOCKS_CMD)
3434

35-
.PHONY: godoc
36-
godoc:
35+
.PHONY: docs
36+
docs:
3737
godoc -http=":6060"

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# go-http-metrics [![Build Status][github-actions-image]][github-actions-url] [![Go Report Card][goreport-image]][goreport-url] [![GoDoc][godoc-image]][godoc-url]
22

3-
go-http-metrics knows how to measure http metrics in different metric formats, it comes with a middleware that will measure metrics of a Go net/http handler. The metrics measured are based on [RED] and/or [Four golden signals], follow standards and try to be measured in a efficient way.
3+
go-http-metrics knows how to measure http metrics in different metric formats. The metrics measured are based on [RED] and/or [Four golden signals], follow standards and try to be measured in a efficient way.
44

5-
If you are using a framework that isn't directly compatible with go's `http.Handler` interface from the std library, do not worry, there are multiple helpers available to get middlewares fo the most used http Go frameworks. If there isn't you can open an issue or a PR.
5+
It measures based on a middleware that is compatible with Go core net/http handler, if you are using a framework that isn't directly compatible with go's `http.Handler` interface, do not worry, there are multiple helpers available to get middlewares for the most used http Go frameworks. If there isn't you can open an issue or a PR.
66

77
## Table of contents
88

doc.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
/*
2+
Package gohttpmetrics knows how to measure http metrics in different metric formats,
3+
it comes with a middleware that can be used for different frameworks and also the
4+
the main Go net/http handler:
5+
package main
6+
7+
import (
8+
"log"
9+
"net/http"
10+
11+
"github.com/prometheus/client_golang/prometheus/promhttp"
12+
httpmetrics "github.com/slok/go-http-metrics/metrics/prometheus"
13+
httpmiddleware "github.com/slok/go-http-metrics/middleware"
14+
)
15+
16+
func main() {
17+
// Create our middleware.
18+
mdlw := httpmiddleware.New(httpmiddleware.Config{
19+
Recorder: httpmetrics.NewRecorder(httpmetrics.Config{}),
20+
})
21+
22+
// Our handler.
23+
myHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
24+
w.WriteHeader(http.StatusOK)
25+
w.Write([]byte("hello world!"))
26+
})
27+
h := mdlw.Handler("", myHandler)
28+
29+
// Serve metrics.
30+
log.Printf("serving metrics at: %s", ":9090")
31+
go http.ListenAndServe(":9090", promhttp.Handler())
32+
33+
// Serve our handler.
34+
log.Printf("listening at: %s", ":8080")
35+
if err := http.ListenAndServe(":8080", h); err != nil {
36+
log.Panicf("error while serving: %s", err)
37+
}
38+
}
39+
*/
140
package gohttpmetrics
241

342
// blank imports help docs.

0 commit comments

Comments
 (0)