• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang metric.Registry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cockroachdb/cockroach/util/metric.Registry的典型用法代码示例。如果您正苦于以下问题:Golang Registry类的具体用法?Golang Registry怎么用?Golang Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Registry类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: 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(MetricLatencyName),
		txnBeginCount:    registry.Counter(MetricTxnBeginName),
		txnCommitCount:   registry.Counter(MetricTxnCommitName),
		txnAbortCount:    registry.Counter(MetricTxnAbortName),
		txnRollbackCount: registry.Counter(MetricTxnRollbackName),
		selectCount:      registry.Counter(MetricSelectName),
		updateCount:      registry.Counter(MetricUpdateName),
		insertCount:      registry.Counter(MetricInsertName),
		deleteCount:      registry.Counter(MetricDeleteName),
		ddlCount:         registry.Counter(MetricDdlName),
		miscCount:        registry.Counter(MetricMiscName),
		queryCount:       registry.Counter(MetricQueryName),
	}
	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:yangxuanjia,项目名称:cockroach,代码行数:38,代码来源:executor.go


示例17: MakeRuntimeStatSampler

// MakeRuntimeStatSampler constructs a new RuntimeStatSampler object.
func MakeRuntimeStatSampler(clock *hlc.Clock, reg *metric.Registry) RuntimeStatSampler {
	return RuntimeStatSampler{
		registry:       reg,
		clock:          clock,
		cgoCalls:       reg.Gauge(nameCgoCalls),
		goroutines:     reg.Gauge(nameGoroutines),
		goAllocBytes:   reg.Gauge(nameGoAllocBytes),
		goTotalBytes:   reg.Gauge(nameGoTotalBytes),
		cgoAllocBytes:  reg.Gauge(nameCgoAllocBytes),
		cgoTotalBytes:  reg.Gauge(nameCgoTotalBytes),
		gcCount:        reg.Gauge(nameGCCount),
		gcPauseNS:      reg.Gauge(nameGCPauseNS),
		gcPausePercent: reg.GaugeFloat64(nameGCPausePercent),
		cpuUserNS:      reg.Gauge(nameCPUUserNS),
		cpuUserPercent: reg.GaugeFloat64(nameCPUUserPercent),
		cpuSysNS:       reg.Gauge(nameCPUSysNS),
		cpuSysPercent:  reg.GaugeFloat64(nameCPUSysPercent),
		rss:            reg.Gauge(nameRSS),
	}
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:21,代码来源:runtime.go


示例18: RegisterMetrics

// RegisterMetrics adds the local metrics to a registry.
// TODO(marc): this pattern deviates from other users of the registry
// that take it as an argument at metric construction time.
func (r *RemoteClockMonitor) RegisterMetrics(reg *metric.Registry) {
	reg.MustAdd(clusterOffsetLowerBoundName, r.metrics.clusterOffsetLowerBound)
	reg.MustAdd(clusterOffsetUpperBoundName, r.metrics.clusterOffsetUpperBound)
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:7,代码来源:clock_offset.go



注:本文中的github.com/cockroachdb/cockroach/util/metric.Registry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang protoutil.Clone函数代码示例发布时间:2022-05-23
下一篇:
Golang metric.NewRegistry函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap