-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: interruptible CPU collector #91
Conversation
I got
Maybe we should not register automatically the new endpoint in I am thinking that there may be cases when users import |
Yeah, this is expected, experimented with this while developing. I'm still testing/fixing it, and I will likely finish today – want to add some unit tests.
Agreed, I don't think there is a nice way to register it automatically. I'm not sure about a custom path: use of this handler together with the standard one has little to no value, IMO. Although, that would make sense if we wanted to embed our own UI |
191d026
to
b6f3ca9
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, nice job.
Took me a while to understand, but now that I understand, everything makes sense to me.
As we discussed: another approach could be forking parts of cpu profiler, linking to runtime_pprof_readProfile
and we could share cpu data, for example here https://github.com/golang/go/blob/master/src/runtime/pprof/pprof.go?name=release#L851 we could write to multiple pprof builders. We can also never stop cpu profiler in theory. This way it could not interruptible but sharing.
Pyroscope CPU Profiler HTTP Handler
This package facilitates the collection of CPU profiles via HTTP without disrupting the background operation of the Pyroscope profiler. It enables you to seamlessly gather CPU profiles through HTTP while continuously sending them to Pyroscope.
The standard Go pprof HTTP endpoint
/debug/pprof/profile
returns an error if profiling is already started:The Pyroscope CPU Profiler HTTP handler handles this gracefully by communicating with the Pyroscope profiler, which collects profiles in the background.
Usage
The package does not register the handler automatically. It is highly recommended to avoid using the standard path
/debug/pprof/profile
and the default mux because attempting to register the handler on the same path will cause a panic. In many cases, thenet/http/pprof
package is imported by dependencies, and therefore there is no reliable way to avoid the conflict.