From 1fa0d77b102c32a2a3065968db9b38661e46fe63 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Mon, 28 Aug 2023 11:23:41 +0200 Subject: [PATCH] chore: Add trace profiling option --- internal/app/app.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/app/app.go b/internal/app/app.go index 22912393..3c1d3d65 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -52,6 +52,9 @@ const ( flagCPUProfile = "cpu-prof" flagCPUProfileShort = "p" + flagTraceProfile = "trace-prof" + flagTraceProfileShort = "t" + flagMemProfile = "mem-prof" flagMemProfileShort = "m" @@ -96,6 +99,11 @@ func New() *cli.App { Aliases: []string{flagCPUProfileShort}, Usage: "Generate CPU profile", }, + &cli.BoolFlag{ + Name: flagTraceProfile, + Aliases: []string{flagTraceProfileShort}, + Usage: "Generate Trace profile", + }, &cli.BoolFlag{ Name: flagMemProfile, Aliases: []string{flagMemProfileShort}, @@ -379,6 +387,11 @@ func withProfiler(c *cli.Context, fn func() error) error { defer profile.Start(profile.CPUProfile, profile.ProfilePath(".")).Stop() } + if c.Bool(flagTraceProfile) { + logrus.Debug("Running with Trace profiling") + defer profile.Start(profile.TraceProfile, profile.ProfilePath(".")).Stop() + } + if c.Bool(flagMemProfile) { logrus.Debug("Running with memory profiling") defer profile.Start(profile.MemProfile, profile.MemProfileAllocs, profile.ProfilePath(".")).Stop()