instahttprouter

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 4 Imported by: 1

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

// ...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(r *httprouter.Router, sensor *instana.Sensor) *wrappedRouter

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

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL