3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 21:39:25 +01:00

Integrate StackImpact profiling

This commit is contained in:
Daniel Oaks 2017-04-30 12:35:07 +10:00
parent 2bd4d03ecc
commit 5c518531be
3 changed files with 43 additions and 3 deletions

View File

@ -173,6 +173,13 @@ func (sts *STSConfig) Value() string {
return val return val
} }
// StackImpactConfig is the config used for StackImpact's profiling.
type StackImpactConfig struct {
Enabled bool
AgentKey string `yaml:"agent-key"`
AppName string `yaml:"app-name"`
}
// Config defines the overall configuration. // Config defines the overall configuration.
type Config struct { type Config struct {
Network struct { Network struct {
@ -215,6 +222,10 @@ type Config struct {
Logging []LoggingConfig Logging []LoggingConfig
Debug struct {
StackImpact StackImpactConfig
}
Limits struct { Limits struct {
AwayLen uint `yaml:"awaylen"` AwayLen uint `yaml:"awaylen"`
ChanListModes uint `yaml:"chan-list-modes"` ChanListModes uint `yaml:"chan-list-modes"`

View File

@ -16,6 +16,7 @@ import (
"github.com/DanielOaks/oragono/irc/logger" "github.com/DanielOaks/oragono/irc/logger"
"github.com/DanielOaks/oragono/mkcerts" "github.com/DanielOaks/oragono/mkcerts"
"github.com/docopt/docopt-go" "github.com/docopt/docopt-go"
stackimpact "github.com/stackimpact/stackimpact-go"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"
) )
@ -107,6 +108,21 @@ Options:
if !arguments["--quiet"].(bool) { if !arguments["--quiet"].(bool) {
logger.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer)) logger.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
} }
// profiling
if config.Debug.StackImpact.Enabled {
if config.Debug.StackImpact.AgentKey == "" || config.Debug.StackImpact.AppName == "" {
logger.Error("startup", "Could not start StackImpact - agent-key or app-name are undefined")
return
}
agent := stackimpact.NewAgent()
agent.Start(stackimpact.Options{AgentKey: config.Debug.StackImpact.AgentKey, AppName: config.Debug.StackImpact.AppName})
defer agent.RecordPanic()
logger.Info("startup", fmt.Sprintf("StackImpact profiling started as %s", config.Debug.StackImpact.AppName))
}
server, err := irc.NewServer(configfile, config, logger) server, err := irc.NewServer(configfile, config, logger)
if err != nil { if err != nil {
logger.Error("startup", fmt.Sprintf("Could not load server: %s", err.Error())) logger.Error("startup", fmt.Sprintf("Could not load server: %s", err.Error()))

View File

@ -236,6 +236,19 @@ logging:
type: localconnect localconnect-ip type: localconnect localconnect-ip
level: debug level: debug
# debug options
debug:
# enabling StackImpact profiling
stackimpact:
# whether to use StackImpact
enabled: false
# the AgentKey to use
agent-key: examplekeyhere
# the app name to report
app-name: Oragono
# datastore configuration # datastore configuration
datastore: datastore:
# path to the datastore # path to the datastore