當前位置: 首頁>>代碼示例>>Golang>>正文


Golang metric.Registry類代碼示例

本文整理匯總了Golang中github.com/cockroachdb/cockroach/util/metric.Registry的典型用法代碼示例。如果您正苦於以下問題:Golang Registry類的具體用法?Golang Registry怎麽用?Golang Registry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Registry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewStoreStatusMonitor

// NewStoreStatusMonitor constructs a StoreStatusMonitor with the given ID.
func NewStoreStatusMonitor(id roachpb.StoreID, metaRegistry *metric.Registry) *StoreStatusMonitor {
	registry := metric.NewRegistry()
	// Format as `cr.store.<metric>.<id>` in output, in analogy to the time
	// series data written.
	metaRegistry.MustAdd(storeTimeSeriesPrefix+"%s."+id.String(), registry)
	return &StoreStatusMonitor{
		ID:                   id,
		registry:             registry,
		rangeCount:           registry.Counter("ranges"),
		leaderRangeCount:     registry.Gauge("ranges.leader"),
		replicatedRangeCount: registry.Gauge("ranges.replicated"),
		availableRangeCount:  registry.Gauge("ranges.available"),
		liveBytes:            registry.Gauge("livebytes"),
		keyBytes:             registry.Gauge("keybytes"),
		valBytes:             registry.Gauge("valbytes"),
		intentBytes:          registry.Gauge("intentbytes"),
		liveCount:            registry.Gauge("livecount"),
		keyCount:             registry.Gauge("keycount"),
		valCount:             registry.Gauge("valcount"),
		intentCount:          registry.Gauge("intentcount"),
		intentAge:            registry.Gauge("intentage"),
		gcBytesAge:           registry.Gauge("gcbytesage"),
		lastUpdateNanos:      registry.Gauge("lastupdatenanos"),
		capacity:             registry.Gauge("capacity"),
		available:            registry.Gauge("capacity.available"),
	}
}
開發者ID:kaustubhkurve,項目名稱:cockroach,代碼行數:28,代碼來源:monitor.go

示例2: New

// New creates an instance of a gossip node.
func New(rpcContext *rpc.Context, grpcServer *grpc.Server, resolvers []resolver.Resolver, stopper *stop.Stopper, registry *metric.Registry) *Gossip {
	g := &Gossip{
		Connected:         make(chan struct{}),
		rpcContext:        rpcContext,
		server:            newServer(stopper, registry),
		outgoing:          makeNodeSet(minPeers, registry.Gauge(ConnectionsOutgoingGaugeName)),
		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{}{},
	}
	g.SetResolvers(resolvers)

	// Add ourselves as a SystemConfig watcher.
	g.is.registerCallback(KeySystemConfig, g.updateSystemConfig)
	// Add ourselves as a node descriptor watcher.
	g.is.registerCallback(MakePrefixPattern(KeyNodeIDPrefix), g.updateNodeAddress)

	RegisterGossipServer(grpcServer, g.server)

	return g
}
開發者ID:yangxuanjia,項目名稱:cockroach,代碼行數:28,代碼來源:gossip.go

示例3: NewExecutor

// NewExecutor creates an Executor and registers a callback on the
// system config.
func NewExecutor(db client.DB, gossip *gossip.Gossip, leaseMgr *LeaseManager, metaRegistry *metric.Registry, stopper *stop.Stopper) *Executor {
	exec := &Executor{
		db:       db,
		reCache:  parser.NewRegexpCache(512),
		leaseMgr: leaseMgr,

		latency: metaRegistry.Latency("sql.latency"),
	}
	exec.systemConfigCond = sync.NewCond(&exec.systemConfigMu)

	gossipUpdateC := gossip.RegisterSystemConfigChannel()
	stopper.RunWorker(func() {
		for {
			select {
			case <-gossipUpdateC:
				cfg := gossip.GetSystemConfig()
				exec.updateSystemConfig(cfg)
			case <-stopper.ShouldStop():
				return
			}
		}
	})

	return exec
}
開發者ID:harryge00,項目名稱:cockroach,代碼行數:27,代碼來源:executor.go

示例4: makeNodeMetrics

func makeNodeMetrics(reg *metric.Registry) nodeMetrics {
	nm := nodeMetrics{
		Latency: metric.NewLatency(metaExecLatency),
		Success: metric.NewRates(metaExecSuccess),
		Err:     metric.NewRates(metaExecError),
	}
	reg.AddMetricStruct(nm)
	return nm
}
開發者ID:yaojingguo,項目名稱:cockroach,代碼行數:9,代碼來源:node.go

示例5: NewTxnMetrics

// NewTxnMetrics returns a new instance of txnMetrics that contains metrics which have
// been registered with the provided Registry.
func NewTxnMetrics(txnRegistry *metric.Registry) *TxnMetrics {
	return &TxnMetrics{
		Aborts:    txnRegistry.Rates(abortsPrefix),
		Commits:   txnRegistry.Rates(commitsPrefix),
		Abandons:  txnRegistry.Rates(abandonsPrefix),
		Durations: txnRegistry.Latency(durationsPrefix),
		Restarts:  txnRegistry.Histogram(restartsKey, 60*time.Second, 100, 3),
	}
}
開發者ID:cuongdo,項目名稱:cockroach,代碼行數:11,代碼來源:txn_coord_sender.go

示例6: newServer

// newServer creates and returns a server struct.
func newServer(stopper *stop.Stopper, registry *metric.Registry) *server {
	return &server{
		stopper:       stopper,
		is:            newInfoStore(0, util.UnresolvedAddr{}, stopper),
		incoming:      makeNodeSet(minPeers, registry.Gauge(ConnectionsIncomingGaugeName)),
		nodeMap:       make(map[util.UnresolvedAddr]serverInfo),
		tighten:       make(chan roachpb.NodeID, 1),
		ready:         make(chan struct{}),
		nodeMetrics:   makeMetrics(registry),
		serverMetrics: makeMetrics(metric.NewRegistry()),
	}
}
開發者ID:yangxuanjia,項目名稱:cockroach,代碼行數:13,代碼來源:server.go

示例7: makeMetrics

// makeMetrics makes a new metrics object with rates set on the provided
// registry.
func makeMetrics(registry *metric.Registry) metrics {
	return metrics{
		bytesReceived: registry.Rates(BytesReceivedRatesName),
		bytesSent:     registry.Rates(BytesSentRatesName),
		infosReceived: registry.Rates(InfosReceivedRatesName),
		infosSent:     registry.Rates(InfosSentRatesName),
	}
}
開發者ID:yangxuanjia,項目名稱:cockroach,代碼行數:10,代碼來源:gossip.go

示例8: eachRecordableValue

// eachRecordableValue visits each metric in the registry, calling the supplied
// function once for each recordable value represented by that metric. This is
// useful to expand certain metric types (such as histograms) into multiple
// recordable values.
func eachRecordableValue(reg *metric.Registry, fn func(string, float64)) {
	reg.Each(func(name string, mtr interface{}) {
		if histogram, ok := mtr.(*metric.Histogram); ok {
			curr := histogram.Current()
			for _, pt := range recordHistogramQuantiles {
				fn(name+pt.suffix, float64(curr.ValueAtQuantile(pt.quantile)))
			}
		} else {
			val, err := extractValue(mtr)
			if err != nil {
				log.Warning(context.TODO(), err)
				return
			}
			fn(name, val)
		}
	})
}
開發者ID:yangxuanjia,項目名稱:cockroach,代碼行數:21,代碼來源:recorder.go

示例9: 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
}
開發者ID:yaojingguo,項目名稱:cockroach,代碼行數:45,代碼來源:gossip.go

示例10: 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
}
開發者ID:yaojingguo,項目名稱:cockroach,代碼行數:20,代碼來源:server.go

示例11: newServerMetrics

func newServerMetrics(reg *metric.Registry) *serverMetrics {
	return &serverMetrics{
		conns:         reg.Counter("conns"),
		bytesInCount:  reg.Counter("bytesin"),
		bytesOutCount: reg.Counter("bytesout"),
	}
}
開發者ID:CubeLite,項目名稱:cockroach,代碼行數:7,代碼來源:server.go

示例12: newServerMetrics

func newServerMetrics(reg *metric.Registry) *serverMetrics {
	return &serverMetrics{
		conns:         reg.Counter(MetricConnsName),
		bytesInCount:  reg.Counter(MetricBytesInName),
		bytesOutCount: reg.Counter(MetricBytesOutName),
	}
}
開發者ID:yangxuanjia,項目名稱:cockroach,代碼行數:7,代碼來源:server.go

示例13: makeNodeMetrics

func makeNodeMetrics(reg *metric.Registry) nodeMetrics {
	return nodeMetrics{
		registry: reg,
		latency:  reg.Latency(execLatencyName),
		success:  reg.Rates(execSuccessName),
		err:      reg.Rates(execErrorName),
	}
}
開發者ID:yangxuanjia,項目名稱:cockroach,代碼行數:8,代碼來源:node.go

示例14: MakeServer

// MakeServer creates a Server, adding network stats to the given Registry.
func MakeServer(context *base.Context, executor *sql.Executor, reg *metric.Registry) *Server {
	return &Server{
		context:  context,
		executor: executor,
		registry: reg,
		metrics: &serverMetrics{
			conns:         reg.Counter("conns"),
			bytesInCount:  reg.Counter("bytesin"),
			bytesOutCount: reg.Counter("bytesout"),
		},
	}
}
開發者ID:GitGoldie,項目名稱:cockroach,代碼行數:13,代碼來源:server.go

示例15: NewExecutor

// NewExecutor creates an Executor and registers a callback on the
// system config.
func NewExecutor(ctx ExecutorContext, stopper *stop.Stopper, registry *metric.Registry) *Executor {
	exec := &Executor{
		ctx:     ctx,
		reCache: parser.NewRegexpCache(512),

		registry:         registry,
		latency:          registry.Latency("latency"),
		txnBeginCount:    registry.Counter("txn.begin.count"),
		txnCommitCount:   registry.Counter("txn.commit.count"),
		txnAbortCount:    registry.Counter("txn.abort.count"),
		txnRollbackCount: registry.Counter("txn.rollback.count"),
		selectCount:      registry.Counter("select.count"),
		updateCount:      registry.Counter("update.count"),
		insertCount:      registry.Counter("insert.count"),
		deleteCount:      registry.Counter("delete.count"),
		ddlCount:         registry.Counter("ddl.count"),
		miscCount:        registry.Counter("misc.count"),
	}
	exec.systemConfigCond = sync.NewCond(exec.systemConfigMu.RLocker())

	gossipUpdateC := ctx.Gossip.RegisterSystemConfigChannel()
	stopper.RunWorker(func() {
		for {
			select {
			case <-gossipUpdateC:
				cfg, _ := ctx.Gossip.GetSystemConfig()
				exec.updateSystemConfig(cfg)
			case <-stopper.ShouldStop():
				return
			}
		}
	})

	return exec
}
開發者ID:cuongdo,項目名稱:cockroach,代碼行數:37,代碼來源:executor.go


注:本文中的github.com/cockroachdb/cockroach/util/metric.Registry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。