Skip to content

Commit

Permalink
Add fgfprof to Loki and Promtail. (#3424)
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
  • Loading branch information
cyriltovena authored Mar 4, 2021
1 parent 18cb7a0 commit 7e9ac16
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/drone/envsubst v1.0.2
github.com/dustin/go-humanize v1.0.0
github.com/fatih/color v1.9.0
github.com/felixge/fgprof v0.9.1
github.com/fluent/fluent-bit-go v0.0.0-20190925192703-ea13c021720c
github.com/go-kit/kit v0.10.0
github.com/go-logfmt/logfmt v0.5.0
Expand Down
3 changes: 3 additions & 0 deletions pkg/loki/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

frontend "github.com/cortexproject/cortex/pkg/frontend/v1"
"github.com/cortexproject/cortex/pkg/querier/worker"
"github.com/felixge/fgprof"

"github.com/grafana/loki/pkg/storage/stores/shipper/compactor"

Expand Down Expand Up @@ -239,6 +240,8 @@ func (t *Loki) Run() error {
// This adds a way to see the config and the changes compared to the defaults
t.Server.HTTP.Path("/config").HandlerFunc(configHandler(t.cfg, newDefaultConfig()))

t.Server.HTTP.Path("/debug/fgprof").Handler(fgprof.Handler())

// Let's listen for events from this manager, and log them.
healthy := func() { level.Info(util_log.Logger).Log("msg", "Loki started") }
stopped := func() { level.Info(util_log.Logger).Log("msg", "Loki stopped") }
Expand Down
4 changes: 3 additions & 1 deletion pkg/promtail/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"syscall"
"text/template"

"github.com/felixge/fgprof"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
Expand Down Expand Up @@ -99,8 +100,8 @@ func New(cfg Config, log log.Logger, tms *targets.TargetManagers) (Server, error
serv.HTTP.PathPrefix("/static/").Handler(http.FileServer(ui.Assets))
serv.HTTP.Path("/service-discovery").Handler(http.HandlerFunc(serv.serviceDiscovery))
serv.HTTP.Path("/targets").Handler(http.HandlerFunc(serv.targets))
serv.HTTP.Path("/debug/fgprof").Handler(fgprof.Handler())
return serv, nil

}

// serviceDiscovery serves the service discovery page.
Expand Down Expand Up @@ -261,6 +262,7 @@ func (s *noopServer) Run() error {
level.Info(s.log).Log("msg", "received shutdown signal", "sig", sig)
return nil
}

func (s *noopServer) Shutdown() {
s.sigs <- syscall.SIGTERM
}
1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ github.com/facette/natsort
## explicit
github.com/fatih/color
# github.com/felixge/fgprof v0.9.1
## explicit
github.com/felixge/fgprof
# github.com/felixge/httpsnoop v1.0.1
github.com/felixge/httpsnoop
Expand Down

0 comments on commit 7e9ac16

Please sign in to comment.