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)
| 155 | // You can then call pprof.SetGoroutineLabels(ctx) to annotate the current go-routine and have that show up in |
| 156 | // pprof analysis. |
| 157 | func 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 | |
| 162 | func addFieldIfNotNil(ctx context.Context, m map[string]interface{}, fieldKey Key) { |
| 163 | val := ctx.Value(fieldKey) |