Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ deps:
mocks:
$(MOCKS_CMD)

.PHONY: godoc
godoc:
.PHONY: docs
docs:
godoc -http=":6060"
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# go-http-metrics [![Build Status][github-actions-image]][github-actions-url] [![Go Report Card][goreport-image]][goreport-url] [![GoDoc][godoc-image]][godoc-url]

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

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

## Table of contents

Expand Down
39 changes: 39 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
/*
Package gohttpmetrics knows how to measure http metrics in different metric formats,
it comes with a middleware that can be used for different frameworks and also the
the main Go net/http handler:
package main

import (
"log"
"net/http"

"github.com/prometheus/client_golang/prometheus/promhttp"
httpmetrics "github.com/slok/go-http-metrics/metrics/prometheus"
httpmiddleware "github.com/slok/go-http-metrics/middleware"
)

func main() {
// Create our middleware.
mdlw := httpmiddleware.New(httpmiddleware.Config{
Recorder: httpmetrics.NewRecorder(httpmetrics.Config{}),
})

// Our handler.
myHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("hello world!"))
})
h := mdlw.Handler("", myHandler)

// Serve metrics.
log.Printf("serving metrics at: %s", ":9090")
go http.ListenAndServe(":9090", promhttp.Handler())

// Serve our handler.
log.Printf("listening at: %s", ":8080")
if err := http.ListenAndServe(":8080", h); err != nil {
log.Panicf("error while serving: %s", err)
}
}
*/
package gohttpmetrics

// blank imports help docs.
Expand Down