6 Star 44 Fork 25

Hyperledger / fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
metrics.go 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package fsblkstorage
import (
"time"
"github.com/hyperledger/fabric/common/metrics"
)
type stats struct {
blockchainHeight metrics.Gauge
blockstorageCommitTime metrics.Histogram
}
func newStats(metricsProvider metrics.Provider) *stats {
stats := &stats{}
stats.blockchainHeight = metricsProvider.NewGauge(blockchainHeightOpts)
stats.blockstorageCommitTime = metricsProvider.NewHistogram(blockstorageCommitTimeOpts)
return stats
}
// ledgerStats defines block metrics that are common for both orderer and peer
type ledgerStats struct {
stats *stats
ledgerid string
}
func (s *stats) ledgerStats(ledgerid string) *ledgerStats {
return &ledgerStats{
s, ledgerid,
}
}
func (s *ledgerStats) updateBlockchainHeight(height uint64) {
// casting uint64 to float64 guarantees precision for the numbers upto 9,007,199,254,740,992 (1<<53)
// since, we are not expecting the blockchains of this scale anytime soon, we go ahead with this for now.
s.stats.blockchainHeight.With("channel", s.ledgerid).Set(float64(height))
}
func (s *ledgerStats) updateBlockstorageCommitTime(timeTaken time.Duration) {
s.stats.blockstorageCommitTime.With("channel", s.ledgerid).Observe(timeTaken.Seconds())
}
var (
blockchainHeightOpts = metrics.GaugeOpts{
Namespace: "ledger",
Subsystem: "",
Name: "blockchain_height",
Help: "Height of the chain in blocks.",
LabelNames: []string{"channel"},
StatsdFormat: "%{#fqname}.%{channel}",
}
blockstorageCommitTimeOpts = metrics.HistogramOpts{
Namespace: "ledger",
Subsystem: "",
Name: "blockstorage_commit_time",
Help: "Time taken in seconds for committing the block to storage.",
LabelNames: []string{"channel"},
StatsdFormat: "%{#fqname}.%{channel}",
Buckets: []float64{0.005, 0.01, 0.015, 0.05, 0.1, 1, 10},
}
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hyperledger/fabric.git
git@gitee.com:hyperledger/fabric.git
hyperledger
fabric
fabric
v1.4.4

搜索帮助

344bd9b3 5694891 D2dac590 5694891