github.com/gogf/gf/v2@v2.7.4/os/gmetric/gmetric_meter.go (about) 1 // Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package gmetric 8 9 // localMeter for Meter implements. 10 type localMeter struct { 11 MeterOption 12 } 13 14 // MeterOption holds the creation option for a Meter. 15 type MeterOption struct { 16 // Instrument is the instrumentation name to bind this Metric to a global MeterProvider. 17 // This is an optional configuration for a metric. 18 Instrument string 19 20 // InstrumentVersion is the instrumentation version to bind this Metric to a global MeterProvider. 21 // This is an optional configuration for a metric. 22 InstrumentVersion string 23 24 // Attributes holds the constant key-value pair description metadata for all metrics of Meter. 25 // This is an optional configuration for a meter. 26 Attributes Attributes 27 } 28 29 // newMeter creates and returns a Meter implementer. 30 func newMeter(option MeterOption) Meter { 31 return &localMeter{ 32 MeterOption: option, 33 } 34 } 35 36 // Performer creates and returns the Performer of the Meter. 37 func (meter *localMeter) Performer() MeterPerformer { 38 if globalProvider == nil { 39 return nil 40 } 41 return globalProvider.MeterPerformer(meter.MeterOption) 42 }