1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 // runtime_FrameStartLine is defined in runtime/symtab.go.
16 func runtime_FrameStartLine(f *runtime.Frame) int
18 // runtime_FrameSymbolName is defined in runtime/symtab.go.
21 func runtime_FrameSymbolName(f *runtime.Frame) string
23 // runtime_expandFinalInlineFrame is defined in runtime/symtab.go.
24 func runtime_expandFinalInlineFrame(stk []uintptr) []uintptr
26 // runtime_setProfLabel is defined in runtime/proflabel.go.
27 func runtime_setProfLabel(labels unsafe.Pointer)
29 // runtime_getProfLabel is defined in runtime/proflabel.go.
30 func runtime_getProfLabel() unsafe.Pointer
32 // SetGoroutineLabels sets the current goroutine's labels to match ctx.
33 // A new goroutine inherits the labels of the goroutine that created it.
34 // This is a lower-level API than [Do], which should be used instead when possible.
35 func SetGoroutineLabels(ctx context.Context) {
36 ctxLabels, _ := ctx.Value(labelContextKey{}).(*labelMap)
37 runtime_setProfLabel(unsafe.Pointer(ctxLabels))
40 // Do calls f with a copy of the parent context with the
41 // given labels added to the parent's label map.
42 // Goroutines spawned while executing f will inherit the augmented label-set.
43 // Each key/value pair in labels is inserted into the label map in the
44 // order provided, overriding any previous value for the same key.
45 // The augmented label map will be set for the duration of the call to f
46 // and restored once f returns.
47 func Do(ctx context.Context, labels LabelSet, f func(context.Context)) {
48 defer SetGoroutineLabels(ctx)
49 ctx = WithLabels(ctx, labels)
50 SetGoroutineLabels(ctx)