Skip to content

Commit fcd14d4

Browse files
PMM-4274 Enable pprof (#488)
* PMM-4274 Enable pprof This patch will enable pprof for the MongoDB exporter. * Added gci to make format * Updated Makefile to use cgi * Ran format
1 parent e72dcf9 commit fcd14d4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
8484
format: ## Format source code.
8585
go mod tidy
8686
bin/gofumpt -l -w $(FILES)
87-
bin/goimports -local github.com/percona/mongodb_exporter -l -w $(FILES)
87+
bin/gci write --Section Standard --Section Default --Section "Prefix(github.com/percona/mongodb_exporter)" .
8888

8989
check: ## Run checks/linters
9090
bin/golangci-lint run

exporter/exporter.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"context"
2222
"fmt"
2323
"net/http"
24+
_ "net/http/pprof"
2425
"os"
2526
"strconv"
2627
"sync"
@@ -322,9 +323,12 @@ func (e *Exporter) Handler() http.Handler {
322323

323324
// Run starts the exporter.
324325
func (e *Exporter) Run() {
326+
mux := http.DefaultServeMux
327+
mux.Handle("/metrics", e.Handler())
328+
325329
server := &http.Server{
326330
Addr: e.webListenAddress,
327-
Handler: e.Handler(),
331+
Handler: mux,
328332
}
329333

330334
if err := web.ListenAndServe(server, e.opts.TLSConfigPath, promlog.New(&promlog.Config{})); err != nil {

tools/tools.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
package tools
2121

2222
import (
23+
_ "github.com/daixiang0/gci"
2324
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
2425
_ "github.com/reviewdog/reviewdog/cmd/reviewdog"
25-
_ "golang.org/x/tools/cmd/goimports"
2626
_ "mvdan.cc/gofumpt"
2727
)
2828

2929
// tools
30+
//go:generate go build -o ../bin/gci github.com/daixiang0/gci
3031
//go:generate go build -o ../bin/gofumpt mvdan.cc/gofumpt
3132
//go:generate go build -o ../bin/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
3233
//go:generate go build -o ../bin/reviewdog github.com/reviewdog/reviewdog/cmd/reviewdog
33-
//go:generate go build -o ../bin/goimports golang.org/x/tools/cmd/goimports

0 commit comments

Comments
 (0)