github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/runtime/pprof/label.go (about) 1 // Copyright 2016 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. 4 5 package pprof 6 7 import ( 8 "github.com/shogo82148/std/context" 9 ) 10 11 // LabelSetはラベルのセットです。 12 type LabelSet struct { 13 list []label 14 } 15 16 // WithLabelsは指定されたラベルが追加された新しい [context.Context] を返します。 17 // ラベルは同じキーを持つ以前のラベルを上書きします。 18 func WithLabels(ctx context.Context, labels LabelSet) context.Context 19 20 // Labelsは、キーと値のペアを表す文字列の偶数個を受け取り、それらを含む [LabelSet] を作成します。 21 // ラベルは、同じキーを持つ以前のラベルを上書きします。 22 // 現在、CPUプロファイルとゴルーチンプロファイルのみがラベル情報を利用しています。 23 // 詳細は、https://golang.org/issue/23458 を参照してください。 24 func Labels(args ...string) LabelSet 25 26 // Labelは与えられたキーに対応するラベルの値と、そのラベルが存在するかを示すブール値をctxから返します。 27 func Label(ctx context.Context, key string) (string, bool) 28 29 // ForLabelsはコンテキストに設定された各ラベルを持ってfを呼び出します。 30 // 関数fは繰り返しを続けるためにtrueを返すか、繰り返しを早期に停止するためにfalseを返す必要があります。 31 func ForLabels(ctx context.Context, f func(key, value string) bool)