feat(pprof): add pprof HTTP server (#807)
- `PPROF_ENABLED=no` - `PPROF_BLOCK_PROFILE_RATE=0` - `PPROF_MUTEX_PROFILE_RATE=0` - `PPROF_HTTP_SERVER_ADDRESS=":6060"`
This commit is contained in:
43
internal/httpserver/helpers_test.go
Normal file
43
internal/httpserver/helpers_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package httpserver
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
func stringPtr(s string) *string { return &s }
|
||||
func durationPtr(d time.Duration) *time.Duration { return &d }
|
||||
|
||||
var _ Logger = (*testLogger)(nil)
|
||||
|
||||
type testLogger struct{}
|
||||
|
||||
func (t *testLogger) Info(msg string) {}
|
||||
func (t *testLogger) Warn(msg string) {}
|
||||
func (t *testLogger) Error(msg string) {}
|
||||
|
||||
var _ gomock.Matcher = (*regexMatcher)(nil)
|
||||
|
||||
type regexMatcher struct {
|
||||
regexp *regexp.Regexp
|
||||
}
|
||||
|
||||
func (r *regexMatcher) Matches(x interface{}) bool {
|
||||
s, ok := x.(string)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return r.regexp.MatchString(s)
|
||||
}
|
||||
|
||||
func (r *regexMatcher) String() string {
|
||||
return "regular expression " + r.regexp.String()
|
||||
}
|
||||
|
||||
func newRegexMatcher(regex string) *regexMatcher {
|
||||
return ®exMatcher{
|
||||
regexp: regexp.MustCompile(regex),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user