New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add profilez
server endpoint
#3774
Conversation
We also have configuration option in the server to enable it at runtime and when embedded. This kind of thing I think should be an opt-in as it can have runtime performance impact on the servers |
So far the only thing that There's no runtime overhead on things like |
There's certainly some cost associated with gathering a profile though - if its same as when you hit the normal pprof end points the go team aims to keep the impact aroun 5%, its still an impact though and a potential vector for abuse that someone might want to turn off. |
I should have probably noted in the original PR that it isn't actually possible to collect a CPU profile via I can make it opt-in, although it doesn't look as though the monitoring port actually has a configuration section of its own, so I guess I could do one of the following:
|
2nd options sounds good - the current |
server/monitor.go
Outdated
Error: "Profiling is not enabled", | ||
} | ||
} | ||
if opts.Name == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use EMPTY, old pattern but want to stay consistent.
server/monitor_test.go
Outdated
{Name: "mutex", Debug: 0}, | ||
{Name: "threadcreate", Debug: 0}, | ||
} { | ||
if ps := s.profilez(try); ps.Error != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EMPTY
2e885e5
to
5f23af8
Compare
Please do a rebase onto dev vs merge. |
5f23af8
to
e95d9fa
Compare
e95d9fa
to
6895367
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR adds a
profilez
endpoint to the system account, which accepts two parameters:profile
for the name of the profile (i.e.allocs
,block
,goroutine
,heap
,mutex
,threadcreate
) anddebug
for the return format (defaults to0
, which is usually gzipped forgo tool pprof
).It will only be possible to query this endpoint if
PROF_PORT
is already enabled, otherwise it will return aProfiling is not enabled
error.Signed-off-by: Neil Twigg neil@nats.io
/cc @nats-io/core