3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-13 07:29:30 +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
}
// 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.
type Config struct {
Network struct {
@ -215,6 +222,10 @@ type Config struct {
Logging []LoggingConfig
Debug struct {
StackImpact StackImpactConfig
}
Limits struct {
AwayLen uint `yaml:"awaylen"`
ChanListModes uint `yaml:"chan-list-modes"`

View File

@ -16,6 +16,7 @@ import (
"github.com/DanielOaks/oragono/irc/logger"
"github.com/DanielOaks/oragono/mkcerts"
"github.com/docopt/docopt-go"
stackimpact "github.com/stackimpact/stackimpact-go"
"golang.org/x/crypto/ssh/terminal"
)
@ -107,6 +108,21 @@ Options:
if !arguments["--quiet"].(bool) {
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)
if err != nil {
logger.Error("startup", fmt.Sprintf("Could not load server: %s", err.Error()))

View File

@ -26,7 +26,7 @@ server:
":6697":
key: tls.key
cert: tls.crt
# strict transport security, to get clients to automagically use TLS
sts:
# whether to advertise STS
@ -74,7 +74,7 @@ server:
# whether to throttle limits or not
enabled: true
# how wide the cidr should be for IPv4
# how wide the cidr should be for IPv4
cidr-len-ipv4: 24
# how wide the cidr should be for IPv6
@ -94,7 +94,7 @@ server:
# whether to throttle connections or not
enabled: true
# how wide the cidr should be for IPv4
# how wide the cidr should be for IPv4
cidr-len-ipv4: 32
# how wide the cidr should be for IPv6
@ -236,6 +236,19 @@ logging:
type: localconnect localconnect-ip
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:
# path to the datastore