-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable pprof HTTP endpoints with CLI flag.
- Loading branch information
1 parent
6992208
commit 2d96435
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
"net/http/pprof" | ||
|
||
"github.com/coinbase/rosetta-sdk-go/server" | ||
) | ||
|
||
type pprofController struct { | ||
routes []server.Route | ||
} | ||
|
||
// See: | ||
// - https://stackoverflow.com/a/71032595/1475331 | ||
// - https://pkg.go.dev/net/http/pprof | ||
func newPprofController() *pprofController { | ||
routes := []server.Route{ | ||
{ | ||
Method: "GET", | ||
Pattern: "/debug/pprof/", | ||
HandlerFunc: http.HandlerFunc(pprof.Index), | ||
}, | ||
{ | ||
Method: "GET", | ||
Pattern: "/debug/pprof/cmdline", | ||
HandlerFunc: http.HandlerFunc(pprof.Cmdline), | ||
}, | ||
{ | ||
Method: "GET", | ||
Pattern: "/debug/pprof/profile", | ||
HandlerFunc: http.HandlerFunc(pprof.Profile), | ||
}, | ||
{ | ||
Method: "GET", | ||
Pattern: "/debug/pprof/symbol", | ||
HandlerFunc: http.HandlerFunc(pprof.Symbol), | ||
}, | ||
{ | ||
Method: "GET", | ||
Pattern: "/debug/pprof/trace", | ||
HandlerFunc: http.HandlerFunc(pprof.Trace), | ||
}, | ||
{ | ||
Method: "GET", | ||
Pattern: "/debug/pprof/{cmd}", | ||
HandlerFunc: http.HandlerFunc(pprof.Index), | ||
}, | ||
} | ||
|
||
return &pprofController{ | ||
routes: routes, | ||
} | ||
} | ||
|
||
func (r *pprofController) Routes() server.Routes { | ||
return r.routes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters