本文整理汇总了Golang中github.com/cockroachdb/cockroach/util/metric.Registry.AddMetric方法的典型用法代码示例。如果您正苦于以下问题:Golang Registry.AddMetric方法的具体用法?Golang Registry.AddMetric怎么用?Golang Registry.AddMetric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/util/metric.Registry
的用法示例。
在下文中一共展示了Registry.AddMetric方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: New
// New creates an instance of a gossip node.
func New(
ctx context.Context,
rpcContext *rpc.Context,
grpcServer *grpc.Server,
resolvers []resolver.Resolver,
stopper *stop.Stopper,
registry *metric.Registry,
) *Gossip {
ctx = log.WithEventLog(ctx, "gossip", "gossip")
g := &Gossip{
ctx: ctx,
Connected: make(chan struct{}),
rpcContext: rpcContext,
server: newServer(ctx, stopper, registry),
outgoing: makeNodeSet(minPeers, metric.NewGauge(MetaConnectionsOutgoingGauge)),
bootstrapping: map[string]struct{}{},
disconnected: make(chan *client, 10),
stalledCh: make(chan struct{}, 1),
stallInterval: defaultStallInterval,
bootstrapInterval: defaultBootstrapInterval,
cullInterval: defaultCullInterval,
nodeDescs: map[roachpb.NodeID]*roachpb.NodeDescriptor{},
resolverAddrs: map[util.UnresolvedAddr]resolver.Resolver{},
bootstrapAddrs: map[util.UnresolvedAddr]struct{}{},
}
stopper.AddCloser(stop.CloserFn(func() {
log.FinishEventLog(ctx)
}))
registry.AddMetric(g.outgoing.gauge)
g.clientsMu.breakers = map[string]*circuit.Breaker{}
log.Infof(g.ctx, "initial resolvers: %s", resolvers)
g.SetResolvers(resolvers)
g.mu.Lock()
// Add ourselves as a SystemConfig watcher.
g.mu.is.registerCallback(KeySystemConfig, g.updateSystemConfig)
// Add ourselves as a node descriptor watcher.
g.mu.is.registerCallback(MakePrefixPattern(KeyNodeIDPrefix), g.updateNodeAddress)
g.mu.Unlock()
RegisterGossipServer(grpcServer, g.server)
return g
}
示例2: newServer
// newServer creates and returns a server struct.
func newServer(ctx context.Context, stopper *stop.Stopper, registry *metric.Registry) *server {
s := &server{
ctx: ctx,
stopper: stopper,
tighten: make(chan roachpb.NodeID, 1),
nodeMetrics: makeMetrics(),
serverMetrics: makeMetrics(),
}
s.mu.is = newInfoStore(ctx, 0, 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
}