tsingpprof

package module
v0.7.2-0...-1debd40 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: MIT Imports: 2 Imported by: 0

README

tsingpprof

GoDoc Build Status

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

Install

First install tsingpprof to your GOPATH using go get:

go get github.com/DeanThompson/tsingpprof

usage

package main

import (
	"log"
	"net/http"

	"github.com/dxvgef/tsing"
	"github.com/gorpher/tsingpprof"

)

func main()  {
	//获得框架实例
	var app = tsing.New()

    // 添加tsingpprof
    tsingpprof.Wrap(app)

	//注册路由
	app.Router.GET("/", func(ctx *tsing.Context) error {
		ctx.ResponseWriter.WriteHeader(200)
		_, err := ctx.ResponseWriter.Write([]byte("Hello world"))
        		//路由函数的出参为nil,表示路由控制器正常执行完毕
        return err
	})

	if err := http.ListenAndServe(":8080", app); err != nil {
		log.Fatal(err.Error())
	}
}

test

=== RUN   TestWrap/test_routers_
    --- PASS: TestWrap/test_routers_ (5.02s)
        pprof_test.go:36: /debug/pprof/profile ProfileHandler
        pprof_test.go:36: /debug/pprof/trace TraceHandler
        pprof_test.go:36: /debug/pprof/goroutine GoroutineHandler
        pprof_test.go:36: /debug/pprof/heap HeapHandler
        pprof_test.go:36: /debug/pprof/allocs AllocsHandler
        pprof_test.go:36: /debug/pprof/block BlockHandler
        pprof_test.go:36: /debug/pprof/threadcreate ThreadCreateHandler
        pprof_test.go:36: /debug/pprof/cmdline CmdlineHandler
        pprof_test.go:36: /debug/pprof/symbol SymbolHandler
        pprof_test.go:36: /debug/pprof/mutex MutexHandler
        pprof_test.go:36: /debug/pprof/ IndexHandler

Now visit http://localhost:9999/debug/pprof/ and you'll see what you want.

Have Fun.

reference

Thanks for free JetBrains Open Source license

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Wrapper = Wrap

Wrapper make sure we are backward compatible

Functions

func AllocsHandler

func AllocsHandler() tsing.Handler

AllocsHandler will pass the call from /debug/pprof/allocs to pprof

func BlockHandler

func BlockHandler() tsing.Handler

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

func CmdlineHandler

func CmdlineHandler() tsing.Handler

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

func GoroutineHandler

func GoroutineHandler() tsing.Handler

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

func HeapHandler

func HeapHandler() tsing.Handler

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

func IndexHandler

func IndexHandler() tsing.Handler

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

func MutexHandler

func MutexHandler() tsing.Handler

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

func ProfileHandler

func ProfileHandler() tsing.Handler

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

func SymbolHandler

func SymbolHandler() tsing.Handler

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

func ThreadCreateHandler

func ThreadCreateHandler() tsing.Handler

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

func TraceHandler

func TraceHandler() tsing.Handler

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

func Wrap

func Wrap(router *tsing.App)

参考ginpprof : github.com/DeanThompson/ginpprof Wrap adds several routes from package `net/http/pprof` to *gin.Engine object

func WrapGroup

func WrapGroup(router *tsing.RouterGroup)

WrapGroup adds several routes from package `net/http/pprof` to *gin.RouterGroup 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