MCPcopy
hub / github.com/flyteorg/flyte / WithGoroutineLabel

Function WithGoroutineLabel

flytestdlib/contextutils/context.go:157–160  ·  view source on GitHub ↗

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.

(ctx context.Context, routineLabel string)

Source from the content-addressed store, hash-verified

155// You can then call pprof.SetGoroutineLabels(ctx) to annotate the current go-routine and have that show up in
156// pprof analysis.
157func WithGoroutineLabel(ctx context.Context, routineLabel string) context.Context {
158 ctx = pprof.WithLabels(ctx, pprof.Labels(RoutineLabelKey.String(), routineLabel))
159 return context.WithValue(ctx, RoutineLabelKey, routineLabel)
160}
161
162func addFieldIfNotNil(ctx context.Context, m map[string]interface{}, fieldKey Key) {
163 val := ctx.Value(fieldKey)

Callers 4

StartMethod · 0.92
StartMethod · 0.92
StartMethod · 0.92
TestWithGoroutineLabelFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by 1

TestWithGoroutineLabelFunction · 0.68