Skip to content

Commit

Permalink
Split into multi-module setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Bastiaans committed Jun 1, 2023
1 parent cda1880 commit b9f89c4
Show file tree
Hide file tree
Showing 38 changed files with 2,620 additions and 1,507 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
.test_coverage.txt
.test_coverage.txt
go.work.sum
12 changes: 9 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,35 @@ The metrics obtained with this middleware are the [most important ones][red] for

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

The following metrics backends are provided:

- [Prometheus][prometheus-recorder]
- [OpenCensus][opencensus-recorder]

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`.

## Framework compatibility middlewares

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.

**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]**
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]

The following middleware modules are provided:

- [Alice][alice-example]
- [Chi][chi-example]
- [Echo][echo-example]
- [Fasthttp][fasthttp-example]
- [Gin][gin-example]
- [Go http.Handler][default-example]
- [Go http.Handler][default-example] (imported by default)
- [Go-restful][gorestful-example]
- [Goji][goji-example]
- [Gorilla][gorilla-example]
- [Httprouter][httprouter-example]
- [Iris][iris-example]
- [Negroni][negroni-example]

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]
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`.

## Getting Started

Expand Down
124 changes: 124 additions & 0 deletions examples/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
module github.com/slok/go-http-metrics/examples

go 1.19

replace (
github.com/slok/go-http-metrics => ../
github.com/slok/go-http-metrics/metrics/opencensus => ../metrics/opencensus
github.com/slok/go-http-metrics/metrics/prometheus => ../metrics/prometheus
github.com/slok/go-http-metrics/middleware/echo => ../middleware/echo
github.com/slok/go-http-metrics/middleware/fasthttp => ../middleware/fasthttp
github.com/slok/go-http-metrics/middleware/gin => ../middleware/gin
github.com/slok/go-http-metrics/middleware/goji => ../middleware/goji
github.com/slok/go-http-metrics/middleware/gorestful => ../middleware/gorestful
github.com/slok/go-http-metrics/middleware/httprouter => ../middleware/httprouter
github.com/slok/go-http-metrics/middleware/iris => ../middleware/iris
github.com/slok/go-http-metrics/middleware/negroni => ../middleware/negroni
)

require (
contrib.go.opencensus.io/exporter/prometheus v0.4.2
github.com/emicklei/go-restful/v3 v3.10.2
github.com/fasthttp/router v1.4.19
github.com/gin-gonic/gin v1.9.0
github.com/go-chi/chi v4.1.2+incompatible
github.com/gorilla/mux v1.8.0
github.com/julienschmidt/httprouter v1.3.0
github.com/justinas/alice v1.2.0
github.com/kataras/iris/v12 v12.2.0
github.com/labstack/echo/v4 v4.10.2
github.com/prometheus/client_golang v1.15.1
github.com/slok/go-http-metrics v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/metrics/opencensus v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/metrics/prometheus v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/middleware/echo v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/middleware/fasthttp v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/middleware/gin v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/middleware/goji v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/middleware/gorestful v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/middleware/httprouter v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/middleware/iris v0.0.0-00010101000000-000000000000
github.com/slok/go-http-metrics/middleware/negroni v0.0.0-00010101000000-000000000000
github.com/urfave/negroni v1.0.0
github.com/valyala/fasthttp v1.47.0
go.opencensus.io v0.24.0
goji.io v2.0.2+incompatible
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
github.com/CloudyKit/jet/v6 v6.2.0 // indirect
github.com/Joker/jade v1.1.3 // indirect
github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.9.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/flosch/pongo2/v4 v4.0.2 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/iris-contrib/schema v0.0.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kataras/blocks v0.0.7 // indirect
github.com/kataras/golog v0.1.8 // indirect
github.com/kataras/pio v0.0.11 // indirect
github.com/kataras/sitemap v0.0.6 // indirect
github.com/kataras/tunnel v0.0.4 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailgun/raymond/v2 v2.0.48 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/microcosm-cc/bluemonday v1.0.24 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.10.0 // indirect
github.com/prometheus/statsd_exporter v0.23.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
github.com/schollz/closestmatch v2.1.0+incompatible // indirect
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/tdewolff/minify/v2 v2.12.5 // indirect
github.com/tdewolff/parse/v2 v2.6.6 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yosssi/ace v0.0.5 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit b9f89c4

Please sign in to comment.