echopprof

package module
v5.0.0-...-83293a2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 4 Imported by: 0

README

echo-pprof

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

Forked from sevenNt/echo-pprof. Support for Echo v4 and v4.

Install

go get -u github.com/SkYNewZ/echo-pprof/v5

Usage

package main

import (
	"github.com/SkYNewZ/echo-pprof/v5"
	"github.com/labstack/echo/v5"
)

func main() {
	e := echo.New()

	e.GET("/ping", func(c echo.Context) error {
		return c.String(200, "pong")
	})

	// automatically add routers for net/http/pprof
	// e.g. /debug/pprof, /debug/pprof/heap, etc.
	echopprof.Wrap(e)

	// echopprof also plays well with *echo.Group
	// prefix := "/debug/pprof"
	// group := e.Group(prefix)
	// echopprof.WrapGroup(prefix, group)

	e.Start(":8080")
}

Start this server, and then visit http://127.0.0.1:8080/debug/pprof/, and you'll see the pprof index page.

Have fun.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllocHandler

func AllocHandler() echo.HandlerFunc

AllocHandler will pass the call from /debug/pprof/allocs to pprof.

func BlockHandler

func BlockHandler() echo.HandlerFunc

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

func CmdlineHandler

func CmdlineHandler() echo.HandlerFunc

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

func GoroutineHandler

func GoroutineHandler() echo.HandlerFunc

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

func HeapHandler

func HeapHandler() echo.HandlerFunc

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

func IndexHandler

func IndexHandler() echo.HandlerFunc

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

func MutexHandler

func MutexHandler() echo.HandlerFunc

MutexHandler will pass the call from /debug/pprof/mutex to pprof.

func ProfileHandler

func ProfileHandler() echo.HandlerFunc

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

func SymbolHandler

func SymbolHandler() echo.HandlerFunc

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

func ThreadCreateHandler

func ThreadCreateHandler() echo.HandlerFunc

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

func TraceHandler

func TraceHandler() echo.HandlerFunc

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

func Wrap

func Wrap(e *echo.Echo)

Wrap adds several routes from package `net/http/pprof` to *echo.Echo object.

Example
e := echo.New()

e.GET("/ping", func(c echo.Context) error {
	return c.String(200, "pong")
})

// automatically add routers for net/http/pprof
// e.g. /debug/pprof, /debug/pprof/heap, etc.
echopprof.Wrap(e)

e.Start(":8080")
Output:

func WrapGroup

func WrapGroup(prefix string, g *echo.Group)

WrapGroup adds several routes from package `net/http/pprof` to *echo.Group object. Supported profiles from https://pkg.go.dev/runtime/pprof#Profile

Example
e := echo.New()

e.GET("/ping", func(c echo.Context) error {
	return c.String(200, "pong")
})

// echopprof also plays well with *echo.Group
prefix := "/debug/pprof"
group := e.Group(prefix)
echopprof.WrapGroup(prefix, group)

e.Start(":8080")
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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