本文整理匯總了Golang中github.com/cockroachdb/cockroach/pkg/util/metric.Registry.AddMetricStruct方法的典型用法代碼示例。如果您正苦於以下問題:Golang Registry.AddMetricStruct方法的具體用法?Golang Registry.AddMetricStruct怎麽用?Golang Registry.AddMetricStruct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/pkg/util/metric.Registry
的用法示例。
在下文中一共展示了Registry.AddMetricStruct方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newServer
// newServer creates and returns a server struct.
func newServer(
ambient log.AmbientContext,
nodeID *base.NodeIDContainer,
stopper *stop.Stopper,
registry *metric.Registry,
) *server {
s := &server{
AmbientContext: ambient,
NodeID: nodeID,
stopper: stopper,
tighten: make(chan struct{}, 1),
nodeMetrics: makeMetrics(),
serverMetrics: makeMetrics(),
}
s.mu.is = newInfoStore(s.AmbientContext, nodeID, util.UnresolvedAddr{}, stopper)
s.mu.incoming = makeNodeSet(minPeers, metric.NewGauge(MetaConnectionsIncomingGauge))
s.mu.nodeMap = make(map[util.UnresolvedAddr]serverInfo)
s.mu.ready = make(chan struct{})
registry.AddMetric(s.mu.incoming.gauge)
registry.AddMetricStruct(s.nodeMetrics)
return s
}
示例2: makeNodeMetrics
func makeNodeMetrics(reg *metric.Registry, sampleInterval time.Duration) nodeMetrics {
nm := nodeMetrics{
Latency: metric.NewLatency(metaExecLatency, sampleInterval),
Success: metric.NewCounter(metaExecSuccess),
Err: metric.NewCounter(metaExecError),
}
reg.AddMetricStruct(nm)
return nm
}