Please note the original example won't run properly. `pprof.Labels()` takes 
an even number of strings, since it's setting key/value pairs.

func handleFoo(ctx context.Context) {
    labels := pprof.Labels("foo", "foo")
    pprof.Do(ctx, labels, func(ctx context.Context) {
        go interestingFunc()
    })
}

Works better.

On Thursday, 3 January 2019 15:22:06 UTC+1, Francis wrote:
>
>
> I would like to use pprof labels, but it seems like I would need to pass a 
> `context.Context` into all new goroutines and re-call pprof.Do at each of 
> these stages. Am I mistaken here.
>
> specifically if we had
>
> unc handleFoo(ctx context.Context) {
>     pprof.Do(ctx, pprof.Labels("foo"), func(ctx context.Context) {
>         go interestingFunc()
>     })
> }
>
> My understanding is that `interestingFunc` would not be profiled with the 
> ‘foo’ label.
> If this is correct it presents a problem that I can’t group profiles under 
> a label when I don’t control the spawning of goroutines myself.
> i.e. if a library spawns goroutines the work they do will simply appear 
> under the global profile
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to