feat(diagnostics): add pprof profiling (#1627)

* feat(tracing): enable tracing

* of course the squash didn't work.

* gah. always nice when there's 40 csets.

* might as well.

* refactor: tracing to diagnostics

* feat: add note about the magic methods from pprof

---------

Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
Kyle Sanderson 2024-08-27 02:00:30 -07:00 committed by GitHub
parent 5ae4ed3604
commit 65d25c56c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 63 additions and 0 deletions

View file

@ -85,6 +85,15 @@ checkForUpdates = true
# Session secret
#
sessionSecret = "{{ .sessionSecret }}"
# Golang pprof profiling and tracing
#
#profiling = false
#
#profilingHost = "127.0.0.1"
#
# Default: 6060
#profilingPort = 6060
`
func (c *AppConfig) writeConfig(configPath string, configFile string) error {
@ -210,6 +219,9 @@ func (c *AppConfig) defaults() {
PostgresPass: "",
PostgresSSLMode: "disable",
PostgresExtraParams: "",
ProfilingEnabled: false,
ProfilingHost: "127.0.0.1",
ProfilingPort: 6060,
}
}
@ -302,6 +314,21 @@ func (c *AppConfig) loadFromEnv() {
if v := os.Getenv(prefix + "POSTGRES_EXTRA_PARAMS"); v != "" {
c.Config.PostgresExtraParams = v
}
if v := os.Getenv(prefix + "PROFILING"); v != "" {
c.Config.ProfilingEnabled = strings.EqualFold(strings.ToLower(v), "true")
}
if v := os.Getenv(prefix + "PROFILING_HOST"); v != "" {
c.Config.ProfilingHost = v
}
if v := os.Getenv(prefix + "PROFILING_PORT"); v != "" {
i, _ := strconv.ParseInt(v, 10, 32)
if i > 0 {
c.Config.ProfilingPort = int(i)
}
}
}
func validDatabaseType(v string) bool {