Skip to main content

WithGoroutineLabel

Gets a new context with Go Routine label key set and a label assigned to the context using pprof.Labels. You can then call pprof.SetGoroutineLabels(ctx) to annotate the current go-routine and have that show up in pprof analysis.

def WithGoroutineLabel(
ctx: context.Context,
routineLabel: string
) - > context.Context

Gets a new context with Go Routine label key set and a label assigned to the context using pprof.Labels. Callers can then use pprof.SetGoroutineLabels(ctx) to annotate the current goroutine for pprof analysis.

Parameters​

NameTypeDescription
ctxcontext.ContextThe parent context to which the goroutine label will be added.
routineLabelstringThe label string to associate with the goroutine for pprof analysis.

Returns​

TypeDescription
context.ContextA new context with the goroutine label applied.