Documentation
¶
Overview ¶
Package pprofutil contains utilities for pprof HTTP handlers.
Example ¶
package main
import (
"context"
"fmt"
"net/http"
"time"
"github.com/AdguardTeam/golibs/pprofutil"
)
func main() {
mux := http.NewServeMux()
pprofutil.RoutePprof(mux)
srv := &http.Server{
Addr: "127.0.0.1:0",
Handler: mux,
}
errCh := make(chan error, 1)
go func() {
errCh <- srv.ListenAndServe()
}()
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err := srv.Shutdown(ctx)
fmt.Printf("shutdown error: %v\n", err)
fmt.Printf("server error: %v\n", <-errCh)
}
Output: shutdown error: <nil> server error: http: Server closed
Index ¶
Examples ¶
Constants ¶
View Source
const BasePath = "/debug/pprof/"
BasePath is the default base path used by RoutePprof.
TODO(a.garipov): Consider adding the ability to configure the base path.
Variables ¶
This section is empty.
Functions ¶
func RoutePprof ¶
func RoutePprof(r Router)
RoutePprof adds all pprof handlers to r under the paths within BasePath.
Types ¶
type Router ¶
Router is the interface for HTTP routers, such as *http.ServeMux.
Click to show internal directories.
Click to hide internal directories.