|
Mike Cugini |
at Sep 14, 2013 at 12:43 am
|
⇧ |
| |
That's true, I can parse out the goroutine status (e.g. "goroutine 3
[runnable]:") information from runtime.Stack(), though I was hoping to
avoid having to do that (this will be part of an automated monitoring tool
for a production system).
While testing runtime.GoroutineProfile() it seemed like the stacks provided
often contained internal function calls (after running the pointers through
runtime.FuncForPC), for example:
runtime.park
semacquireimpl
runtime.semacquire
gc
runtime.gc
runtime.mallocgc
cnew
runtime.cnewarray
makeslice1
runtime.makeslice
bytes.Map
encoding/base64.(*Encoding).Decode
encoding/base64.(*Encoding).DecodeString
main.doThings
runtime.goexit
the goroutine's stack trace from runtime.Stack() shows the currently
executing function as "encoding/base64.(*Encoding).DecodeString". Is there
a way to programmatically determine how far back in the StackRecord.Stack()
slice to look in order to find the same value?
On Friday, September 13, 2013 6:36:49 PM UTC-4, Rémy Oudompheng wrote:2013/9/13 Mike Cugini <mi...@grooveshark.com <javascript:>>:
Hello everyone,
I'm working on adding monitoring for a Go system, and currently utilizing
the runtime.ReadMemStats function. In addition to these metrics I am also
interested in retrieving a list of goroutines which currently exist, what
state they are in (running, runnable, sleeping, etc), and possibly the
currently executing function.
I've looked through the runtime package and the closest I've been able to
find is the runtime.Stack() function which fills a byte buffer with the
stack traces for all goroutines. I would be interested in adding a new
function to the runtime package that would return a slice of structs, with
each struct containing the information mentioned above for a particular
goroutine.
First off, is this necessary or is there already a way to obtain this
information in a similar way? If not, is this something that would be
worthwhile for me to pursue implementing?
runtime.Stack and runtime.GoroutineProfile will already do this. You
can also use the runtime/pprof package.
Rémy.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.