Skip to content

Commit

Permalink
Expose profiling endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Oct 5, 2023
1 parent 8457c91 commit bac27ee
Show file tree
Hide file tree
Showing 19 changed files with 1,758 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// Package api contains the REST API implementation for k6.
// It also registers the services endpoints like pprof
package api

import (
"context"
"fmt"
"net/http"
_ "net/http/pprof"

Check failure on line 9 in api/server.go

View workflow job for this annotation

GitHub Actions / lint

G108: Profiling endpoint is automatically exposed on /debug/pprof (gosec)
"time"

_ "github.com/grafana/pyroscope-go/godeltaprof/http/pprof"

Check warning on line 12 in api/server.go

View workflow job for this annotation

GitHub Actions / lint

blank-imports: a blank import should be only in a main or test package, or have a comment justifying it (revive)
"github.com/sirupsen/logrus"

v1 "go.k6.io/k6/api/v1"
Expand All @@ -20,6 +24,8 @@ func newHandler(cs *v1.ControlSurface) http.Handler {
mux.Handle("/v1/", v1.NewHandler(cs))
mux.Handle("/ping", handlePing(cs.RunState.Logger))
mux.Handle("/", handlePing(cs.RunState.Logger))
mux.Handle("/debug/pprof/", http.DefaultServeMux)

return mux
}

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ require (
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grafana/pyroscope-go/godeltaprof v0.1.4 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grafana/pyroscope-go/godeltaprof v0.1.4 h1:mDsJ3ngul7UfrHibGQpV66PbZ3q1T8glz/tK3bQKKEk=
github.com/grafana/pyroscope-go/godeltaprof v0.1.4/go.mod h1:1HSPtjU8vLG0jE9JrTdzjgFqdJ/VgN7fvxBNq3luJko=
github.com/grafana/xk6-browser v1.1.0 h1:QHXF0zqm/MgUuJXfIBi9xUbJy5Z0molSWcYgtMkLbk8=
github.com/grafana/xk6-browser v1.1.0/go.mod h1:D0ybXLDFAnIV+fNFvaQY8LIXy7OqobLA3f810BkUVXU=
github.com/grafana/xk6-grpc v0.1.4-0.20230919144024-6ed5daf33509 h1:9ujE4S5cA3WDhRJnwNuUDtfk3w9FeWx6PaZ+lb3o46M=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

203 changes: 203 additions & 0 deletions vendor/github.com/grafana/pyroscope-go/godeltaprof/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions vendor/github.com/grafana/pyroscope-go/godeltaprof/block.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions vendor/github.com/grafana/pyroscope-go/godeltaprof/heap.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bac27ee

Please sign in to comment.