Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

things-go/pprof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pprof

GoDoc Go.Dev reference Build Status codecov Action Status Go Report Card Licence Tag

gin pprof middleware

Package pprof serves via its HTTP server runtime profiling data in the format expected by the pprof visualization tool.

Usage

Start using it

Download and install it:

    go get github.com/things-go/pprof

Import it in your code:

    import "github.com/things-go/pprof"

Example

package main

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

	"github.com/things-go/pprof"
)

func main() {
	router := gin.Default()
	pprof.Router(router)
	router.Run(":8080")
}

Use the pprof tool

Then use the pprof tool to look at the heap profile:

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

Or to look at a 30-second CPU profile:

    go tool pprof http://localhost:8080/debug/pprof/profile

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

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

Or to collect a 5-second execution trace:

    wget http://localhost:8080/debug/pprof/trace?seconds=5

About

pprof middleware for gin, move to https://github.com/things-go/gin-contrib

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages