Skip to content

Commit f93388c

Browse files
author
Mark Bastiaans
committed
Split into multi-module setup
1 parent cda1880 commit f93388c

38 files changed

+2620
-1508
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor/
2-
.test_coverage.txt
2+
.test_coverage.txt
3+
go.work.sum

Readme.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
go-http-metrics knows how to measure http metrics in different metric formats and Go HTTP framework/libs. The metrics measured are based on [RED] and/or [Four golden signals], follow standards and try to be measured in a efficient way.
44

55
## Table of contents
6-
76
- [Metrics](#metrics)
87
- [Metrics recorder implementations](#metrics-recorder-implementations)
98
- [Framework compatibility middlewares](#framework-compatibility-middlewares)
@@ -28,29 +27,35 @@ The metrics obtained with this middleware are the [most important ones][red] for
2827

2928
go-http-metrics is easy to extend to different metric backends by implementing `metrics.Recorder` interface.
3029

30+
The following metrics backends are provided:
31+
3132
- [Prometheus][prometheus-recorder]
3233
- [OpenCensus][opencensus-recorder]
3334

35+
Each provided backend is its own module. To use an individual backend module, `go get` it. Example: `go get github.com/slok/go-http-metrics/metrics/prometheus`.
36+
3437
## Framework compatibility middlewares
3538

3639
The middleware is mainly focused to be compatible with Go std library using http.Handler, but it comes with helpers to get middlewares for other frameworks or libraries.
3740

38-
**When `go-http-metrics` is imported as a dependency, it will only import the libraries being used, this is safe because each lib/framework is in its own package. More information [here][import-information-1] and [here][import-information-2]**
41+
It supports any framework that supports http.Handler provider type middleware `func(http.Handler) http.Handler` (e.g Chi, Alice, Gorilla...). Use [`std.HandlerProvider`][handler-provider-docs]
42+
43+
The following middleware modules are provided:
3944

4045
- [Alice][alice-example]
4146
- [Chi][chi-example]
4247
- [Echo][echo-example]
4348
- [Fasthttp][fasthttp-example]
4449
- [Gin][gin-example]
45-
- [Go http.Handler][default-example]
50+
- [Go http.Handler][default-example] (imported by default)
4651
- [Go-restful][gorestful-example]
4752
- [Goji][goji-example]
4853
- [Gorilla][gorilla-example]
4954
- [Httprouter][httprouter-example]
5055
- [Iris][iris-example]
5156
- [Negroni][negroni-example]
5257

53-
It supports any framework that supports http.Handler provider type middleware `func(http.Handler) http.Handler` (e.g Chi, Alice, Gorilla...). Use [`std.HandlerProvider`][handler-provider-docs]
58+
Each middleware is its own module. To use an individual middleware module, `go get` it. Example: `go get github.com/slok/go-http-metrics/middleware/gin`.
5459

5560
## Getting Started
5661

examples/go.mod

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
module github.com/slok/go-http-metrics/examples
2+
3+
go 1.19
4+
5+
replace (
6+
github.com/slok/go-http-metrics => ../
7+
github.com/slok/go-http-metrics/metrics/opencensus => ../metrics/opencensus
8+
github.com/slok/go-http-metrics/metrics/prometheus => ../metrics/prometheus
9+
github.com/slok/go-http-metrics/middleware/echo => ../middleware/echo
10+
github.com/slok/go-http-metrics/middleware/fasthttp => ../middleware/fasthttp
11+
github.com/slok/go-http-metrics/middleware/gin => ../middleware/gin
12+
github.com/slok/go-http-metrics/middleware/goji => ../middleware/goji
13+
github.com/slok/go-http-metrics/middleware/gorestful => ../middleware/gorestful
14+
github.com/slok/go-http-metrics/middleware/httprouter => ../middleware/httprouter
15+
github.com/slok/go-http-metrics/middleware/iris => ../middleware/iris
16+
github.com/slok/go-http-metrics/middleware/negroni => ../middleware/negroni
17+
)
18+
19+
require (
20+
contrib.go.opencensus.io/exporter/prometheus v0.4.2
21+
github.com/emicklei/go-restful/v3 v3.10.2
22+
github.com/fasthttp/router v1.4.19
23+
github.com/gin-gonic/gin v1.9.0
24+
github.com/go-chi/chi v4.1.2+incompatible
25+
github.com/gorilla/mux v1.8.0
26+
github.com/julienschmidt/httprouter v1.3.0
27+
github.com/justinas/alice v1.2.0
28+
github.com/kataras/iris/v12 v12.2.0
29+
github.com/labstack/echo/v4 v4.10.2
30+
github.com/prometheus/client_golang v1.15.1
31+
github.com/slok/go-http-metrics v0.0.0-00010101000000-000000000000
32+
github.com/slok/go-http-metrics/metrics/opencensus v0.0.0-00010101000000-000000000000
33+
github.com/slok/go-http-metrics/metrics/prometheus v0.0.0-00010101000000-000000000000
34+
github.com/slok/go-http-metrics/middleware/echo v0.0.0-00010101000000-000000000000
35+
github.com/slok/go-http-metrics/middleware/fasthttp v0.0.0-00010101000000-000000000000
36+
github.com/slok/go-http-metrics/middleware/gin v0.0.0-00010101000000-000000000000
37+
github.com/slok/go-http-metrics/middleware/goji v0.0.0-00010101000000-000000000000
38+
github.com/slok/go-http-metrics/middleware/gorestful v0.0.0-00010101000000-000000000000
39+
github.com/slok/go-http-metrics/middleware/httprouter v0.0.0-00010101000000-000000000000
40+
github.com/slok/go-http-metrics/middleware/iris v0.0.0-00010101000000-000000000000
41+
github.com/slok/go-http-metrics/middleware/negroni v0.0.0-00010101000000-000000000000
42+
github.com/urfave/negroni v1.0.0
43+
github.com/valyala/fasthttp v1.47.0
44+
go.opencensus.io v0.24.0
45+
goji.io v2.0.2+incompatible
46+
)
47+
48+
require (
49+
github.com/BurntSushi/toml v1.2.1 // indirect
50+
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
51+
github.com/CloudyKit/jet/v6 v6.2.0 // indirect
52+
github.com/Joker/jade v1.1.3 // indirect
53+
github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06 // indirect
54+
github.com/andybalholm/brotli v1.0.5 // indirect
55+
github.com/aymerick/douceur v0.2.0 // indirect
56+
github.com/beorn7/perks v1.0.1 // indirect
57+
github.com/bytedance/sonic v1.9.0 // indirect
58+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
59+
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
60+
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 // indirect
61+
github.com/fatih/structs v1.1.0 // indirect
62+
github.com/flosch/pongo2/v4 v4.0.2 // indirect
63+
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
64+
github.com/gin-contrib/sse v0.1.0 // indirect
65+
github.com/go-kit/log v0.2.1 // indirect
66+
github.com/go-logfmt/logfmt v0.6.0 // indirect
67+
github.com/go-playground/locales v0.14.1 // indirect
68+
github.com/go-playground/universal-translator v0.18.1 // indirect
69+
github.com/go-playground/validator/v10 v10.14.0 // indirect
70+
github.com/goccy/go-json v0.10.2 // indirect
71+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
72+
github.com/golang/protobuf v1.5.3 // indirect
73+
github.com/golang/snappy v0.0.4 // indirect
74+
github.com/google/uuid v1.3.0 // indirect
75+
github.com/gorilla/css v1.0.0 // indirect
76+
github.com/iris-contrib/schema v0.0.6 // indirect
77+
github.com/josharian/intern v1.0.0 // indirect
78+
github.com/json-iterator/go v1.1.12 // indirect
79+
github.com/kataras/blocks v0.0.7 // indirect
80+
github.com/kataras/golog v0.1.8 // indirect
81+
github.com/kataras/pio v0.0.11 // indirect
82+
github.com/kataras/sitemap v0.0.6 // indirect
83+
github.com/kataras/tunnel v0.0.4 // indirect
84+
github.com/klauspost/compress v1.16.5 // indirect
85+
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
86+
github.com/labstack/gommon v0.4.0 // indirect
87+
github.com/leodido/go-urn v1.2.4 // indirect
88+
github.com/mailgun/raymond/v2 v2.0.48 // indirect
89+
github.com/mailru/easyjson v0.7.7 // indirect
90+
github.com/mattn/go-colorable v0.1.13 // indirect
91+
github.com/mattn/go-isatty v0.0.19 // indirect
92+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
93+
github.com/microcosm-cc/bluemonday v1.0.24 // indirect
94+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
95+
github.com/modern-go/reflect2 v1.0.2 // indirect
96+
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
97+
github.com/prometheus/client_model v0.4.0 // indirect
98+
github.com/prometheus/common v0.44.0 // indirect
99+
github.com/prometheus/procfs v0.10.0 // indirect
100+
github.com/prometheus/statsd_exporter v0.23.1 // indirect
101+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
102+
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
103+
github.com/schollz/closestmatch v2.1.0+incompatible // indirect
104+
github.com/sirupsen/logrus v1.9.2 // indirect
105+
github.com/tdewolff/minify/v2 v2.12.5 // indirect
106+
github.com/tdewolff/parse/v2 v2.6.6 // indirect
107+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
108+
github.com/ugorji/go/codec v1.2.11 // indirect
109+
github.com/valyala/bytebufferpool v1.0.0 // indirect
110+
github.com/valyala/fasttemplate v1.2.2 // indirect
111+
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
112+
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
113+
github.com/yosssi/ace v0.0.5 // indirect
114+
golang.org/x/arch v0.3.0 // indirect
115+
golang.org/x/crypto v0.9.0 // indirect
116+
golang.org/x/net v0.10.0 // indirect
117+
golang.org/x/sys v0.8.0 // indirect
118+
golang.org/x/text v0.9.0 // indirect
119+
golang.org/x/time v0.3.0 // indirect
120+
google.golang.org/protobuf v1.30.0 // indirect
121+
gopkg.in/ini.v1 v1.67.0 // indirect
122+
gopkg.in/yaml.v2 v2.4.0 // indirect
123+
gopkg.in/yaml.v3 v3.0.1 // indirect
124+
)

0 commit comments

Comments
 (0)