This repository has been archived by the owner on Sep 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pprof Debug routes for Sherpa server profiling.
- Loading branch information
Showing
5 changed files
with
106 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package server | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
const configKeyDebugEnable = "debug-enabled" | ||
|
||
// GetDebugEnabled is used to identify whether the operator has enabled the server debug API | ||
// endpoints. | ||
func GetDebugEnabled() bool { return viper.GetBool(configKeyDebugEnable) } | ||
|
||
// RegisterDebugConfig registers the CLI flags used to alter the server debug API endpoints. | ||
func RegisterDebugConfig(cmd *cobra.Command) { | ||
flags := cmd.PersistentFlags() | ||
|
||
{ | ||
const ( | ||
key = configKeyDebugEnable | ||
longOpt = "debug-enabled" | ||
defaultValue = false | ||
description = "Specifies if the debugging HTTP endpoints should be enabled" | ||
) | ||
|
||
flags.Bool(longOpt, defaultValue, description) | ||
_ = viper.BindPFlag(key, flags.Lookup(longOpt)) | ||
viper.SetDefault(key, defaultValue) | ||
} | ||
} |
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,15 @@ | ||
package server | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_DebugConfig(t *testing.T) { | ||
fakeCMD := &cobra.Command{} | ||
RegisterDebugConfig(fakeCMD) | ||
cfg := GetClusterConfig() | ||
assert.False(t, GetDebugEnabled(), cfg.Addr) | ||
} |
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