github.com/gramework/gramework@v1.8.1-0.20231027140105-82555c9057f5/pprof/pprof.go (about)

     1  package pprof
     2  
     3  import (
     4  	"net/http/pprof"
     5  
     6  	"github.com/gramework/gramework"
     7  )
     8  
     9  var (
    10  	cmdline = gramework.NewGrameHandlerFunc(pprof.Cmdline)
    11  	profile = gramework.NewGrameHandlerFunc(pprof.Profile)
    12  	symbol  = gramework.NewGrameHandlerFunc(pprof.Symbol)
    13  	trace   = gramework.NewGrameHandlerFunc(pprof.Trace)
    14  	index   = gramework.NewGrameHandlerFunc(pprof.Index)
    15  )
    16  
    17  // Handler serves server runtime profiling data in the format expected by the pprof visualization tool.
    18  //
    19  // See https://golang.org/pkg/net/http/pprof/ for details.
    20  func Handler(ctx *gramework.Context) {
    21  	ctx.HTML()
    22  	switch ctx.RouteArg("type") {
    23  	case "cmdline":
    24  		cmdline(ctx)
    25  	case "symbol":
    26  		symbol(ctx)
    27  	case "profile":
    28  		profile(ctx)
    29  	case "trace":
    30  		trace(ctx)
    31  	default:
    32  		index(ctx)
    33  	}
    34  }