This module contains middleware to instrument HTTP services written with github.com/julienschmidt/httprouter.
Installation
To add the module to your go.mod
file run the following command in your project directory:
$ go get github.com/instana/go-sensor/instrumentation/instahttprouter
Usage
// Create a sensor
sensor := instana.NewSensor("my-web-server")
// Create router and wrap it with Instana
r := instahttprouter.Wrap(httprouter.New(), sensor)
// Define handlers
r.GET("/foo", func(writer http.ResponseWriter, request *http.Request, params httprouter.Params) {})
r.Handle(http.MethodPost, "/foo/:id", func(writer http.ResponseWriter, request *http.Request, params httprouter.Params) {})
// There is no need to additionally instrument your handlers with instana.TracingHandlerFunc(), since
// the instrumented router takes care of this during the registration process.
r.HandlerFunc(http.MethodDelete, "/foo/:id", func(writer http.ResponseWriter, request *http.Request) {})
// ...