1 Star 0 Fork 0

妥協/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
observer.go 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
Matthew Sykes 提交于 2019-01-04 14:25 . [FAB-13237] metrics for log records
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package metrics
import (
"github.com/hyperledger/fabric/common/metrics"
"go.uber.org/zap/zapcore"
)
var (
CheckedCountOpts = metrics.CounterOpts{
Namespace: "logging",
Name: "entries_checked",
Help: "Number of log entries checked against the active logging level",
LabelNames: []string{"level"},
StatsdFormat: "%{#fqname}.%{level}",
}
WriteCountOpts = metrics.CounterOpts{
Namespace: "logging",
Name: "entries_written",
Help: "Number of log entries that are written",
LabelNames: []string{"level"},
StatsdFormat: "%{#fqname}.%{level}",
}
)
type Observer struct {
CheckedCounter metrics.Counter
WrittenCounter metrics.Counter
}
func NewObserver(provider metrics.Provider) *Observer {
return &Observer{
CheckedCounter: provider.NewCounter(CheckedCountOpts),
WrittenCounter: provider.NewCounter(WriteCountOpts),
}
}
func (m *Observer) Check(e zapcore.Entry, ce *zapcore.CheckedEntry) {
m.CheckedCounter.With("level", e.Level.String()).Add(1)
}
func (m *Observer) WriteEntry(e zapcore.Entry, fields []zapcore.Field) {
m.WrittenCounter.With("level", e.Level.String()).Add(1)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liurenhao/fabric.git
git@gitee.com:liurenhao/fabric.git
liurenhao
fabric
fabric
v1.4.3

搜索帮助