ppgorilla

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

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

Documentation

Overview

Package ppgorilla instruments the gorilla/mux package (https://github.com/gorilla/mux).

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware() mux.MiddlewareFunc

Middleware returns a mux middleware that creates a pinpoint.Tracer that instruments the http handler function.

func WrapHandler

func WrapHandler(handler http.Handler) http.Handler

WrapHandler wraps the given http handler.

func WrapHandlerFunc

func WrapHandlerFunc(f func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

WrapHandlerFunc wraps the given http handler function.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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