FAQ
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?

--
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.

Search Discussions

  • Rémy Oudompheng at Sep 13, 2013 at 10:36 pm

    2013/9/13 Mike Cugini <mike@grooveshark.com>:
    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.
  • 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.
  • Dave Cheney at Sep 14, 2013 at 12:53 am
    Yup, it must have at least one period in it, and cannot start with runtime.


    On 14/09/2013, at 10:43, Mike Cugini wrote:

    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>:
    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.
    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 13, '13 at 9:54p
activeSep 14, '13 at 12:53a
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase