From 6ec883a7fd40a14f2882076bd1a377bbbd0438ad Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Thu, 27 Aug 2026 13:06:20 +0200 Subject: Add local Pyroscope server and Go continuous profiling Add a docker-compose service running the Grafana Pyroscope backend on port 4040 with a persistent data volume, and instrument the Go app via github.com/grafana/pyroscope-go. The app pushes CPU, memory, and goroutine profiles every 10s when pyroscope.enabled is set in config.yaml. Config is extended with application_name and server_address (defaults to http://localhost:4040). Document usage in the README. --- config/config.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'config/config.go') diff --git a/config/config.go b/config/config.go index 6fe9048..f95d3f8 100644 --- a/config/config.go +++ b/config/config.go @@ -16,6 +16,7 @@ type Config struct { Storage StorageConfig `yaml:"storage"` Strava StravaConfig `yaml:"strava"` OfficialClimb OfficialClimbConfig `yaml:"official_climb"` + Pyroscope PyroscopeConfig `yaml:"pyroscope"` } type DatabaseConfig struct { @@ -43,6 +44,12 @@ type OfficialClimbConfig struct { MatchRadiusM float64 `yaml:"match_radius_m"` } +type PyroscopeConfig struct { + Enabled bool `yaml:"enabled"` + ApplicationName string `yaml:"application_name"` + ServerAddress string `yaml:"server_address"` +} + func Default() Config { return Config{ Database: DatabaseConfig{Path: "biking_home.db"}, @@ -52,6 +59,10 @@ func Default() Config { }, Storage: StorageConfig{GPXDir: "data/rides"}, OfficialClimb: OfficialClimbConfig{MatchRadiusM: official_climb.DefaultMatchRadiusM}, + Pyroscope: PyroscopeConfig{ + ApplicationName: "biking_home", + ServerAddress: "http://localhost:4040", + }, } } @@ -73,6 +84,12 @@ func Load(filename string) (Config, error) { if config.Storage.GPXDir == "" { return Config{}, fmt.Errorf("config %q: storage.gpx_dir is required", filename) } + if config.Pyroscope.Enabled && config.Pyroscope.ApplicationName == "" { + return Config{}, fmt.Errorf("config %q: pyroscope.application_name is required when pyroscope is enabled", filename) + } + if config.Pyroscope.Enabled && config.Pyroscope.ServerAddress == "" { + return Config{}, fmt.Errorf("config %q: pyroscope.server_address is required when pyroscope is enabled", filename) + } if math.IsNaN(config.OfficialClimb.MatchRadiusM) || math.IsInf(config.OfficialClimb.MatchRadiusM, 0) || config.OfficialClimb.MatchRadiusM <= 0 { return Config{}, fmt.Errorf("config %q: official_climb.match_radius_m must be greater than zero", filename) } -- cgit v1.3