trpc.group/trpc-go/trpc-go@v1.0.3/metrics/options.go (about) 1 // 2 // 3 // Tencent is pleased to support the open source community by making tRPC available. 4 // 5 // Copyright (C) 2023 THL A29 Limited, a Tencent company. 6 // All rights reserved. 7 // 8 // If you have downloaded a copy of the tRPC source code from Tencent, 9 // please note that tRPC source code is licensed under the Apache 2.0 License, 10 // A copy of the Apache 2.0 License is included in this file. 11 // 12 // 13 14 package metrics 15 16 var options = &Options{} 17 18 // Options defines the report options. 19 type Options struct { 20 // Meta is used to adapt some complex scenes. For example, a monitor may map the metric name to 21 // monitor id. 22 Meta map[string]interface{} 23 } 24 25 // GetOptions gets options. 26 func GetOptions() Options { 27 return *options 28 } 29 30 // Option modifies the Options. 31 type Option func(opts *Options) 32 33 // WithMeta returns an Option which sets the metadata, such as a map between metric name and metric 34 // id. 35 func WithMeta(meta map[string]interface{}) Option { 36 return func(opts *Options) { 37 if opts != nil { 38 opts.Meta = meta 39 } 40 } 41 }