Skip to content

Latest commit

 

History

History
 
 

gorilla

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

ppgorilla

This package instruments the gorilla/mux package.

Installation

$ go get github.com/pinpoint-apm/pinpoint-go-agent/plugin/gorilla
import "github.com/pinpoint-apm/pinpoint-go-agent/plugin/gorilla"

Usage

PkgGoDev

This package instruments inbound requests handled by a gorilla mux.Router. Register the Middleware as the middleware of the router to trace all handlers:

r := mux.NewRouter()
r.Use(ppgorilla.Middleware())

Use WrapHandler or WrapHandlerFunc to select the handlers you want to track:

r.HandleFunc("/outgoing", ppgorilla.WrapHandlerFunc(outGoing))

For each request, a pinpoint.Tracer is stored in the request context. By using the pinpoint.FromContext function, this tracer can be obtained in your handler. Alternatively, the context of the request may be propagated where the context that contains the pinpoint.Tracer is required.

package main

import (
    "github.com/gorilla/mux"
    "github.com/pinpoint-apm/pinpoint-go-agent"
    "github.com/pinpoint-apm/pinpoint-go-agent/plugin/gorilla"
    "github.com/pinpoint-apm/pinpoint-go-agent/plugin/http"
)

func hello(w http.ResponseWriter, r *http.Request) {
    io.WriteString(w, "hello world")
}

func main() {
    ... //setup agent
	
    r := mux.NewRouter()
    r.Use(ppgorilla.Middleware())

    //r.HandleFunc("/", ppgorilla.WrapHandlerFunc(hello)))
    http.ListenAndServe(":8000", r)
}

Full Example Source

This package supports URL Statistics feature. It aggregates response times, successes and failures for each router pattern.

Config Options