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,6 +173,13 @@ func (sts *STSConfig) Value() string {
173 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 183
 // Config defines the overall configuration.
177 184
 type Config struct {
178 185
 	Network struct {
@@ -215,6 +222,10 @@ type Config struct {
215 222
 
216 223
 	Logging []LoggingConfig
217 224
 
225
+	Debug struct {
226
+		StackImpact StackImpactConfig
227
+	}
228
+
218 229
 	Limits struct {
219 230
 		AwayLen        uint          `yaml:"awaylen"`
220 231
 		ChanListModes  uint          `yaml:"chan-list-modes"`

+ 16
- 0
oragono.go View File

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

+ 16
- 3
oragono.yaml View File

@@ -26,7 +26,7 @@ server:
26 26
         ":6697":
27 27
             key: tls.key
28 28
             cert: tls.crt
29
-    
29
+
30 30
     # strict transport security, to get clients to automagically use TLS
31 31
     sts:
32 32
         # whether to advertise STS
@@ -74,7 +74,7 @@ server:
74 74
         # whether to throttle limits or not
75 75
         enabled: true
76 76
 
77
-        # how wide the cidr should be for IPv4 
77
+        # how wide the cidr should be for IPv4
78 78
         cidr-len-ipv4: 24
79 79
 
80 80
         # how wide the cidr should be for IPv6
@@ -94,7 +94,7 @@ server:
94 94
         # whether to throttle connections or not
95 95
         enabled: true
96 96
 
97
-        # how wide the cidr should be for IPv4 
97
+        # how wide the cidr should be for IPv4
98 98
         cidr-len-ipv4: 32
99 99
 
100 100
         # how wide the cidr should be for IPv6
@@ -236,6 +236,19 @@ logging:
236 236
         type: localconnect localconnect-ip
237 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 252
 # datastore configuration
240 253
 datastore:
241 254
     # path to the datastore

Loading…
Cancel
Save