From 2d8503cafb9f63ca4cb63f041281987f9a63f16a Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sun, 23 Aug 2026 15:38:08 +0200 Subject: Add on-demand pprof profiling grouped by route Expose pprof at /debug/pprof via -pprof flag, tag each handler with runtime/pprof route label, add handleRoute helper to avoid repeating patterns, and document UI workflow in README. --- cli/cli.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'cli') diff --git a/cli/cli.go b/cli/cli.go index 68a86a6..bd54b35 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -21,10 +21,11 @@ import ( ) var ( - fetchOSM = flag.Bool("fetch-osm", false, "download the France OSM PBF (resumable) into france-latest.osm.pbf") - extractOSM = flag.String("extract-osm", "", "extract mountain passes from an OSM PBF file into the database") - backfill = flag.Bool("backfill", false, "recompute all stored ride values") - backtest = flag.Bool("backtest", false, "run data benchmarks comparing computed values against stored reference values") + fetchOSM = flag.Bool("fetch-osm", false, "download the France OSM PBF (resumable) into france-latest.osm.pbf") + extractOSM = flag.String("extract-osm", "", "extract mountain passes from an OSM PBF file into the database") + backfill = flag.Bool("backfill", false, "recompute all stored ride values") + backtest = flag.Bool("backtest", false, "run data benchmarks comparing computed values against stored reference values") + enablePprof = flag.Bool("pprof", false, "expose pprof endpoints at /debug/pprof") ) const ( @@ -52,7 +53,10 @@ func Run(db *sql.DB, configPath string, appConfig config.Config) { } func runServer(db *sql.DB, configPath string, appConfig config.Config) { - server := web.NewServer(db, configPath) + server := web.NewServer(db, configPath).WithPprof(*enablePprof) + if *enablePprof { + slog.Info("pprof enabled", "endpoint", appConfig.Server.PublicURL+"/debug/pprof/") + } slog.Info("Starting web server", "address", appConfig.Server.PublicURL) kcore.Expect(server.ListenAndServe(appConfig.Server.Address), "web server stopped") } -- cgit v1.3