From 171230a9ded7901efdd44b575b6facf67678be2d Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Mon, 21 Jul 2025 16:28:43 +0300 Subject: Added pyroscope support, experimental --- cmd/server/main.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'cmd') diff --git a/cmd/server/main.go b/cmd/server/main.go index d1539fb..147670e 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -29,6 +29,10 @@ import ( "syscall" "time" + "github.com/grafana/pyroscope-go" + _ "github.com/grafana/pyroscope-go/godeltaprof/http/pprof" + _ "net/http/pprof" + "github.com/kyren223/eko/embeds" "github.com/kyren223/eko/internal/server" "github.com/kyren223/eko/internal/server/api" @@ -69,6 +73,8 @@ func main() { handleReload() handleShutdown(cancel) + startPyroscopeProfiling() + if ok := reloadTosAndPrivacy(); !ok { return } @@ -219,3 +225,25 @@ func reloadTosAndPrivacy() bool { return true } + +func startPyroscopeProfiling() { + pyroscope.Start(pyroscope.Config{ + ApplicationName: "eko", + ServerAddress: "http://localhost:4040", + Logger: pyroscope.StandardLogger, // nil to disable + // by default all profilers are enabled, + // but you can select the ones you want to use: + ProfileTypes: []pyroscope.ProfileType{ + pyroscope.ProfileCPU, + pyroscope.ProfileAllocObjects, + pyroscope.ProfileAllocSpace, + pyroscope.ProfileInuseObjects, + pyroscope.ProfileInuseSpace, + pyroscope.ProfileGoroutines, + pyroscope.ProfileMutexCount, + pyroscope.ProfileMutexCount, + pyroscope.ProfileBlockCount, + pyroscope.ProfileBlockDuration, + }, + }) +} -- cgit v1.3.1