ginpprof

package module
v0.0.0-...-30f5f96 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2015 License: MIT Imports: 2 Imported by: 0

README

ginpprof

GoDoc Build Status

A wrapper for golang web framework gin to use net/http/pprof easily.

Install

First install ginpprof to your GOPATH using go get:

go get github.com/DeanThompson/ginpprof

Usage

package main

import (
	"github.com/gin-gonic/gin"

	"github.com/DeanThompson/ginpprof"
)

func main() {
	router := gin.Default()

	router.GET("/ping", func(c *gin.Context) {
		c.String(200, "pong")
	})

	// automatically add routers for net/http/pprof
	// e.g. /debug/pprof, /debug/pprof/heap, etc.
	ginpprof.Wrapper(router)

	router.Run(":8080")
}

Start this server, and you will see such outputs:

[GIN-debug] GET   /ping                     --> main.func·001 (3 handlers)
[GIN-debug] GET   /debug/pprof/             --> github.com/DeanThompson/ginpprof.func·001 (3 handlers)
[GIN-debug] GET   /debug/pprof/heap         --> github.com/DeanThompson/ginpprof.func·002 (3 handlers)
[GIN-debug] GET   /debug/pprof/goroutine    --> github.com/DeanThompson/ginpprof.func·003 (3 handlers)
[GIN-debug] GET   /debug/pprof/block        --> github.com/DeanThompson/ginpprof.func·004 (3 handlers)
[GIN-debug] GET   /debug/pprof/threadcreate --> github.com/DeanThompson/ginpprof.func·005 (3 handlers)
[GIN-debug] GET   /debug/pprof/cmdline      --> github.com/DeanThompson/ginpprof.func·006 (3 handlers)
[GIN-debug] GET   /debug/pprof/profile      --> github.com/DeanThompson/ginpprof.func·007 (3 handlers)
[GIN-debug] GET   /debug/pprof/symbol       --> github.com/DeanThompson/ginpprof.func·008 (3 handlers)
[GIN-debug] Listening and serving HTTP on :8080

Now visit http://127.0.0.1:8080/debug/pprof/ and you'll see what you want.

Have Fun.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Wrapper = Wrap

Wrapper make sure we are backward compatible

Functions

func BlockHandler

func BlockHandler() gin.HandlerFunc

BlockHandler will pass the call from /debug/pprof/block to pprof

func CmdlineHandler

func CmdlineHandler() gin.HandlerFunc

CmdlineHandler will pass the call from /debug/pprof/cmdline to pprof

func GoroutineHandler

func GoroutineHandler() gin.HandlerFunc

GoroutineHandler will pass the call from /debug/pprof/goroutine to pprof

func HeapHandler

func HeapHandler() gin.HandlerFunc

HeapHandler will pass the call from /debug/pprof/heap to pprof

func IndexHandler

func IndexHandler() gin.HandlerFunc

IndexHandler will pass the call from /debug/pprof to pprof

func ProfileHandler

func ProfileHandler() gin.HandlerFunc

ProfileHandler will pass the call from /debug/pprof/profile to pprof

func SymbolHandler

func SymbolHandler() gin.HandlerFunc

SymbolHandler will pass the call from /debug/pprof/symbol to pprof

func ThreadCreateHandler

func ThreadCreateHandler() gin.HandlerFunc

ThreadCreateHandler will pass the call from /debug/pprof/threadcreate to pprof

func TraceHandler

func TraceHandler() gin.HandlerFunc

TraceHandler will pass the call from /debug/pprof/trace to pprof

func Wrap

func Wrap(router *gin.Engine)

Wrap adds several routes from package `net/http/pprof` to *gin.Engine object

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