pprof

package
v5.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 3 Imported by: 0

README

Usage

package main

import (
	"log/slog"

	"github.com/labstack/echo-contrib/v5/pprof"
	"github.com/labstack/echo/v5"
)

func main() {
	e := echo.New()
	pprof.Register(e)
	//......
	if err := e.Start(":1323"); err != nil {
		slog.Error("failed to start server", "error", err)
	}
}
  • Then use the pprof tool to look at the heap profile:

    go tool pprof http://localhost:1323/debug/pprof/heap

  • Or to look at a 30-second CPU profile:

    go tool pprof http://localhost:1323/debug/pprof/profile?seconds=30

  • Or to look at the goroutine blocking profile, after calling runtime.SetBlockProfileRate in your program:

    go tool pprof http://localhost:1323/debug/pprof/block

  • Or to look at the holders of contended mutexes, after calling runtime.SetMutexProfileFraction in your program:

    go tool pprof http://localhost:1323/debug/pprof/mutex

Documentation

Index

Constants

View Source
const (
	// DefaultPrefix url prefix of pprof
	DefaultPrefix = "/debug/pprof"
)

Variables

This section is empty.

Functions

func Register

func Register(e *echo.Echo, prefixOptions ...string)

Register middleware for net/http/pprof

Types

This section is empty.

Jump to

Keyboard shortcuts

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