Skip to content

Commit

Permalink
Merge pull request #1681 from weaveworks/block-profiling-1672
Browse files Browse the repository at this point in the history
Add flag for block profiling
  • Loading branch information
jml authored Jul 14, 2016
2 parents 528936a + 0edd2e7 commit cdb651f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions prog/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
_ "net/http/pprof"
"net/url"
"os"
"runtime"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -199,6 +200,7 @@ func pipeRouterFactory(userIDer multitenant.UserIDer, pipeRouterURL, consulInf s
func appMain(flags appFlags) {
setLogLevel(flags.logLevel)
setLogFormatter(flags.logPrefix)
runtime.SetBlockProfileRate(flags.blockProfileRate)

defer log.Info("app exiting")
rand.Seed(time.Now().UnixNano())
Expand Down
4 changes: 4 additions & 0 deletions prog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ type appFlags struct {
memcachedExpiration time.Duration
userIDHeader string

blockProfileRate int

awsCreateTables bool
consulInf string
}
Expand Down Expand Up @@ -197,6 +199,8 @@ func main() {
flag.StringVar(&flags.app.memcachedService, "app.memcached.service", "memcached", "SRV service used to discover memcache servers.")
flag.StringVar(&flags.app.userIDHeader, "app.userid.header", "", "HTTP header to use as userid")

flag.IntVar(&flags.app.blockProfileRate, "app.block.profile.rate", 0, "If more than 0, enable block profiling. The profiler aims to sample an average of one blocking event per rate nanoseconds spent blocked.")

flag.BoolVar(&flags.app.awsCreateTables, "app.aws.create.tables", false, "Create the tables in DynamoDB")
flag.StringVar(&flags.app.consulInf, "app.consul.inf", "", "The interface who's address I should advertise myself under in consul")

Expand Down
6 changes: 6 additions & 0 deletions site/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ To collect the CPU profile of the Scope Probe:

go tool pprof http://localhost:4041/debug/pprof/profile

To collect a blocking profile of the Scope App, make sure you have launched
Scope with `--app.block.profile.rate=N` (where `N` is the number of
nanoseconds between samples) and then:

go tool pprof http://localhost:4040/debug/pprof/block

If you don't have `go` installed, you can use a Docker container instead:

To collect the memory profile of the Scope App:
Expand Down

0 comments on commit cdb651f

Please sign in to comment.