1 Star 0 Fork 0

Clannad/webkit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
otelmetric_metric_callback.go 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
yokaqa 提交于 2024-10-18 10:22 +08:00 . 111
// 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"
)
// localMetricObserver implements interface gmetric.CallbackObserver.
type localMetricObserver struct {
gmetric.MeterOption
gmetric.MetricOption
metric.Float64Observer
}
func (l *localMeterPerformer) newMetricObserver(
metricOption gmetric.MetricOption,
float64Observer metric.Float64Observer,
) gmetric.MetricObserver {
return &localMetricObserver{
MeterOption: l.MeterOption,
MetricOption: metricOption,
Float64Observer: float64Observer,
}
}
// 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 *localMetricObserver) Observe(value float64, option ...gmetric.Option) {
var (
constOption = genConstOptionForMetric(l.MeterOption, l.MetricOption)
dynamicOption = getDynamicOptionByMetricOption(option...)
globalAttributesOption = getGlobalAttributesOption(gmetric.GetGlobalAttributesOption{
Instrument: l.Instrument,
InstrumentVersion: l.InstrumentVersion,
})
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.Float64Observer.Observe(value, observeOptions...)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/clannad_sk/webkit.git
git@gitee.com:clannad_sk/webkit.git
clannad_sk
webkit
webkit
997199055094

搜索帮助