Categorygithub.com/instana/go-sensor/instrumentation/instahttprouter
modulepackage
1.23.0
Repository: https://github.com/instana/go-sensor.git
Documentation: pkg.go.dev

# README

Instana instrumentation for github.com/julienschmidt/httprouter

This module contains middleware to instrument HTTP services written with github.com/julienschmidt/httprouter.

GoDoc

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 collector
collector := instana.InitCollector(&instana.Options{
  Service: "my-web-app",
})

// Create router and wrap it with Instana
r := instahttprouter.Wrap(httprouter.New(), collector)

// 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) {})

// ...

Full example

# Functions

Wrap returns an instrumented instance of a httprouter.Router that instruments HTTP handlers with Instana upon registration.

# Constants

Version is the instrumentation module semantic version.

# Structs

No description provided by the author