add pprof vendor
This commit is contained in:
parent
bd8971d9a6
commit
daaef4a5f2
25
vendor/github.com/gin-contrib/pprof/.gitignore
generated
vendored
Normal file
25
vendor/github.com/gin-contrib/pprof/.gitignore
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
coverage*
|
22
vendor/github.com/gin-contrib/pprof/.travis.yml
generated
vendored
Normal file
22
vendor/github.com/gin-contrib/pprof/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
language: go
|
||||
sudo: false
|
||||
|
||||
go:
|
||||
- 1.6.x
|
||||
- 1.7.x
|
||||
- 1.8.x
|
||||
- tip
|
||||
|
||||
script:
|
||||
- go test -v -covermode=atomic -coverprofile=coverage.out
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
notifications:
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/acc2c57482e94b44f557
|
||||
on_success: change
|
||||
on_failure: always
|
||||
on_start: false
|
21
vendor/github.com/gin-contrib/pprof/LICENSE
generated
vendored
Normal file
21
vendor/github.com/gin-contrib/pprof/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016 Gin-Gonic
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
83
vendor/github.com/gin-contrib/pprof/README.md
generated
vendored
Normal file
83
vendor/github.com/gin-contrib/pprof/README.md
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
# pprof
|
||||
|
||||
[![Build Status](https://travis-ci.org/gin-contrib/pprof.svg)](https://travis-ci.org/gin-contrib/pprof)
|
||||
[![codecov](https://codecov.io/gh/gin-contrib/pprof/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-contrib/pprof)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/gin-contrib/pprof)](https://goreportcard.com/report/github.com/gin-contrib/pprof)
|
||||
[![GoDoc](https://godoc.org/github.com/gin-contrib/pprof?status.svg)](https://godoc.org/github.com/gin-contrib/pprof)
|
||||
[![Join the chat at https://gitter.im/gin-gonic/gin](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gin-gonic/gin)
|
||||
|
||||
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:
|
||||
|
||||
```bash
|
||||
$ go get gopkg.in/gin-contrib/pprof.v1
|
||||
```
|
||||
|
||||
Import it in your code:
|
||||
|
||||
```go
|
||||
import "gopkg.in/gin-contrib/pprof.v1"
|
||||
```
|
||||
|
||||
### Example:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gin-contrib/pprof"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
router := gin.Default()
|
||||
pprof.Register(router, nil)
|
||||
router.Run(":8080")
|
||||
}
|
||||
```
|
||||
|
||||
### change default path prefix:
|
||||
|
||||
```go
|
||||
func main() {
|
||||
router := gin.Default()
|
||||
pprof.Register(router, &pprof.Options{
|
||||
// default is "debug/pprof"
|
||||
RoutePrefix: "debug/pprof",
|
||||
})
|
||||
router.Run(":8080")
|
||||
}
|
||||
```
|
||||
|
||||
### Use the pprof tool
|
||||
|
||||
Then use the pprof tool to look at the heap profile:
|
||||
|
||||
```bash
|
||||
go tool pprof http://localhost:8080/debug/pprof/heap
|
||||
```
|
||||
|
||||
Or to look at a 30-second CPU profile:
|
||||
|
||||
```bash
|
||||
go tool pprof http://localhost:8080/debug/pprof/profile
|
||||
```
|
||||
|
||||
Or to look at the goroutine blocking profile, after calling runtime.SetBlockProfileRate in your program:
|
||||
|
||||
```bash
|
||||
go tool pprof http://localhost:8080/debug/pprof/block
|
||||
```
|
||||
|
||||
Or to collect a 5-second execution trace:
|
||||
|
||||
```bash
|
||||
wget http://localhost:8080/debug/pprof/trace?seconds=5
|
||||
```
|
42
vendor/github.com/gin-contrib/pprof/pprof.go
generated
vendored
Normal file
42
vendor/github.com/gin-contrib/pprof/pprof.go
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
package pprof
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Options provides potential route registration configuration options
|
||||
type Options struct {
|
||||
// RoutePrefix is an optional path prefix. If left unspecified, `/debug/pprof`
|
||||
// is used as the default path prefix.
|
||||
RoutePrefix string
|
||||
}
|
||||
|
||||
// Register the standard HandlerFuncs from the net/http/pprof package with
|
||||
// the provided gin.Engine. opts is a optional. If a `nil` value is passed,
|
||||
// the default path prefix is used.
|
||||
func Register(r *gin.Engine, opts *Options) {
|
||||
prefix := routePrefix(opts)
|
||||
r.GET(prefix+"/block", pprofHandler(pprof.Index))
|
||||
r.GET(prefix+"/heap", pprofHandler(pprof.Index))
|
||||
r.GET(prefix+"/profile", pprofHandler(pprof.Profile))
|
||||
r.POST(prefix+"/symbol", pprofHandler(pprof.Symbol))
|
||||
r.GET(prefix+"/symbol", pprofHandler(pprof.Symbol))
|
||||
r.GET(prefix+"/trace", pprofHandler(pprof.Trace))
|
||||
}
|
||||
|
||||
func pprofHandler(h http.HandlerFunc) gin.HandlerFunc {
|
||||
handler := http.HandlerFunc(h)
|
||||
return func(c *gin.Context) {
|
||||
handler.ServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
}
|
||||
|
||||
func routePrefix(opts *Options) string {
|
||||
if opts == nil {
|
||||
return "/debug/pprof"
|
||||
}
|
||||
return opts.RoutePrefix
|
||||
}
|
Loading…
Reference in New Issue
Block a user