代码拉取完成,页面将自动刷新
// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package otelmetric
import (
"go.opentelemetry.io/otel/metric"
"gitee.com/clannad_sk/webkit/v2/os/gmetric"
)
// localObserver implements interface gmetric.Observer.
type localObserver struct {
metric.Observer
gmetric.MeterOption
}
// newObserver creates and returns gmetric.Observer.
func newObserver(observer metric.Observer, meterOption gmetric.MeterOption) gmetric.Observer {
return &localObserver{
Observer: observer,
MeterOption: meterOption,
}
}
// Observe observes the value for certain initialized Metric.
// It adds the value to total result if the observed Metrics is type of Counter.
// It sets the value as the result if the observed Metrics is type of Gauge.
func (l *localObserver) Observe(om gmetric.ObservableMetric, value float64, option ...gmetric.Option) {
var (
m = om.(gmetric.Metric)
constOption = getConstOptionByMetric(l.MeterOption, m)
dynamicOption = getDynamicOptionByMetricOption(option...)
globalAttributesOption = getGlobalAttributesOption(gmetric.GetGlobalAttributesOption{
Instrument: m.Info().Instrument().Name(),
InstrumentVersion: m.Info().Instrument().Version(),
})
observeOptions = make([]metric.ObserveOption, 0)
)
if globalAttributesOption != nil {
observeOptions = append(observeOptions, globalAttributesOption)
}
if constOption != nil {
observeOptions = append(observeOptions, constOption)
}
if dynamicOption != nil {
observeOptions = append(observeOptions, dynamicOption)
}
l.Observer.ObserveFloat64(metricToFloat64Observable(m), value, observeOptions...)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。