Browse Source

Integrate StackImpact profiling

tags/v0.8.0
Daniel Oaks 7 years ago
parent
commit
5c518531be
3 changed files with 43 additions and 3 deletions
  1. 11
    0
      irc/config.go
  2. 16
    0
      oragono.go
  3. 16
    3
      oragono.yaml

+ 11
- 0
irc/config.go View File

173
 	return val
173
 	return val
174
 }
174
 }
175
 
175
 
176
+// StackImpactConfig is the config used for StackImpact's profiling.
177
+type StackImpactConfig struct {
178
+	Enabled  bool
179
+	AgentKey string `yaml:"agent-key"`
180
+	AppName  string `yaml:"app-name"`
181
+}
182
+
176
 // Config defines the overall configuration.
183
 // Config defines the overall configuration.
177
 type Config struct {
184
 type Config struct {
178
 	Network struct {
185
 	Network struct {
215
 
222
 
216
 	Logging []LoggingConfig
223
 	Logging []LoggingConfig
217
 
224
 
225
+	Debug struct {
226
+		StackImpact StackImpactConfig
227
+	}
228
+
218
 	Limits struct {
229
 	Limits struct {
219
 		AwayLen        uint          `yaml:"awaylen"`
230
 		AwayLen        uint          `yaml:"awaylen"`
220
 		ChanListModes  uint          `yaml:"chan-list-modes"`
231
 		ChanListModes  uint          `yaml:"chan-list-modes"`

+ 16
- 0
oragono.go View File

16
 	"github.com/DanielOaks/oragono/irc/logger"
16
 	"github.com/DanielOaks/oragono/irc/logger"
17
 	"github.com/DanielOaks/oragono/mkcerts"
17
 	"github.com/DanielOaks/oragono/mkcerts"
18
 	"github.com/docopt/docopt-go"
18
 	"github.com/docopt/docopt-go"
19
+	stackimpact "github.com/stackimpact/stackimpact-go"
19
 	"golang.org/x/crypto/ssh/terminal"
20
 	"golang.org/x/crypto/ssh/terminal"
20
 )
21
 )
21
 
22
 
107
 		if !arguments["--quiet"].(bool) {
108
 		if !arguments["--quiet"].(bool) {
108
 			logger.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
109
 			logger.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
109
 		}
110
 		}
111
+
112
+		// profiling
113
+		if config.Debug.StackImpact.Enabled {
114
+			if config.Debug.StackImpact.AgentKey == "" || config.Debug.StackImpact.AppName == "" {
115
+				logger.Error("startup", "Could not start StackImpact - agent-key or app-name are undefined")
116
+				return
117
+			}
118
+
119
+			agent := stackimpact.NewAgent()
120
+			agent.Start(stackimpact.Options{AgentKey: config.Debug.StackImpact.AgentKey, AppName: config.Debug.StackImpact.AppName})
121
+			defer agent.RecordPanic()
122
+
123
+			logger.Info("startup", fmt.Sprintf("StackImpact profiling started as %s", config.Debug.StackImpact.AppName))
124
+		}
125
+
110
 		server, err := irc.NewServer(configfile, config, logger)
126
 		server, err := irc.NewServer(configfile, config, logger)
111
 		if err != nil {
127
 		if err != nil {
112
 			logger.Error("startup", fmt.Sprintf("Could not load server: %s", err.Error()))
128
 			logger.Error("startup", fmt.Sprintf("Could not load server: %s", err.Error()))

+ 16
- 3
oragono.yaml View File

26
         ":6697":
26
         ":6697":
27
             key: tls.key
27
             key: tls.key
28
             cert: tls.crt
28
             cert: tls.crt
29
-    
29
+
30
     # strict transport security, to get clients to automagically use TLS
30
     # strict transport security, to get clients to automagically use TLS
31
     sts:
31
     sts:
32
         # whether to advertise STS
32
         # whether to advertise STS
74
         # whether to throttle limits or not
74
         # whether to throttle limits or not
75
         enabled: true
75
         enabled: true
76
 
76
 
77
-        # how wide the cidr should be for IPv4 
77
+        # how wide the cidr should be for IPv4
78
         cidr-len-ipv4: 24
78
         cidr-len-ipv4: 24
79
 
79
 
80
         # how wide the cidr should be for IPv6
80
         # how wide the cidr should be for IPv6
94
         # whether to throttle connections or not
94
         # whether to throttle connections or not
95
         enabled: true
95
         enabled: true
96
 
96
 
97
-        # how wide the cidr should be for IPv4 
97
+        # how wide the cidr should be for IPv4
98
         cidr-len-ipv4: 32
98
         cidr-len-ipv4: 32
99
 
99
 
100
         # how wide the cidr should be for IPv6
100
         # how wide the cidr should be for IPv6
236
         type: localconnect localconnect-ip
236
         type: localconnect localconnect-ip
237
         level: debug
237
         level: debug
238
 
238
 
239
+# debug options
240
+debug:
241
+    # enabling StackImpact profiling
242
+    stackimpact:
243
+        # whether to use StackImpact
244
+        enabled: false
245
+
246
+        # the AgentKey to use
247
+        agent-key: examplekeyhere
248
+
249
+        # the app name to report
250
+        app-name: Oragono
251
+
239
 # datastore configuration
252
 # datastore configuration
240
 datastore:
253
 datastore:
241
     # path to the datastore
254
     # path to the datastore

Loading…
Cancel
Save