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

Golang go-metrics.NewRegistry函数代码示例

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

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



在下文中一共展示了NewRegistry函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: NewGaugeDiff

func NewGaugeDiff(name string, r metrics.Registry) *GaugeDiff {
	return &GaugeDiff{
		Delta:    metrics.NewRegisteredGauge(name, r),
		Absolute: metrics.NewRegisteredGauge(name+"-absolute", metrics.NewRegistry()),
		Previous: metrics.NewRegisteredGauge(name+"-previous", metrics.NewRegistry()),
	}
}
开发者ID:vadv,项目名称:ostent,代码行数:7,代码来源:operating.go


示例2: init

func init() {
	Reg1s = IndexRegistry{
		Registry:                 metrics.NewRegistry(),
		PrivateCPURegistry:       metrics.NewRegistry(),
		PrivateInterfaceRegistry: metrics.NewRegistry(),
		PrivateDFRegistry:        metrics.NewRegistry(),
	}
	Reg1s.PrivateCPUAll = /* *Reg1s.RegisterCPU */ *system.NewMetricCPU(
		/* pcreg := */ metrics.NewRegistry(), "all")
	// pcreg.Register("all", Reg1s.PrivateCPUAll)

	Reg1s.RAM = system.NewMetricRAM(Reg1s.Registry)
	Reg1s.Swap = operating.NewMetricSwap(Reg1s.Registry)
	Reg1s.Load = operating.NewMetricLoad(Reg1s.Registry)
}
开发者ID:vadv,项目名称:ostent,代码行数:15,代码来源:index.go


示例3: newBot

func newBot() (b MMJira) {

	b = MMJira{l: zap.NewJSON(zap.DebugLevel), reg: metrics.NewRegistry()}
	data, err := ioutil.ReadFile("config.yaml")
	if err != nil {
		b.l.Panic("not able to read the file", zap.Error(err))
	}
	var config InstanceConfig
	if err = yaml.Unmarshal(data, &config); err != nil {
		b.l.Panic("not able to marshal the file", zap.Error(err))
	}
	b.c = &config
	if !b.c.Debug {
		b.l.SetLevel(zap.ErrorLevel)
	}
	mmpost, err := mmcontroller.NewController(b.c.MMicon, b.c.MMuser, b.c.Hooks, b.c.Debug, metrics.NewPrefixedChildRegistry(b.reg, "mmc."))
	if err != nil {
		panic(err)
	}

	b.m = mmpost
	b.l.Debug("outputting config", zap.Object("config", b.c))
	b.r = mux.NewRouter()
	b.r.HandleFunc("/", b.homeHandler)
	b.r.HandleFunc("/hooks/", b.getHandler).Methods("GET")
	b.r.HandleFunc("/hooks/{hookid}", b.postHandler).Methods("POST")
	b.r.Handle("/metrics", exp.ExpHandler(b.reg))
	b.r.HandleFunc("/config/", b.configGetHandler).Methods("GET")

	return b

}
开发者ID:tixu,项目名称:mmjira,代码行数:32,代码来源:main.go


示例4: newGCMetricaDataSource

func newGCMetricaDataSource(pollInterval int) goMetricaDataSource {
	r := metrics.NewRegistry()

	metrics.RegisterDebugGCStats(r)
	go metrics.CaptureDebugGCStats(r, time.Duration(pollInterval)*time.Second)
	return goMetricaDataSource{r}
}
开发者ID:ChrisSmith,项目名称:gorelic,代码行数:7,代码来源:gc_metrics.go


示例5: main

func main() {
	if len(os.Args) < 2 {
		fmt.Println("Please provide one or more IP:Port pairs")
		os.Exit(1)
	}

	h := &httpmetrics.Handler{
		Registries: make(map[string]*metrics.Registry),
		Socket:     "/tmp/tcp-monitor.sock",
	}

	for _, addr := range os.Args[1:] {
		r := metrics.NewRegistry()
		a := &Addr{
			Address:  addr,
			Registry: &r,
		}

		addrs = append(addrs, a)
		a.startPing()
		h.Registries[addr] = &r
	}

	if err := h.CreateServer(); err != nil {
		panic(err)
	}
}
开发者ID:mehulsbhatt,项目名称:gollector-monitors,代码行数:27,代码来源:main.go


示例6: InitDefaultMetrics

func InitDefaultMetrics() {
	Gm = util.NewStreamingMetrics(metrics.NewRegistry())
	metricsAddr := "tcp://127.0.0.1:5450"
	logPrefix := "Go-stream"
	go statsSender(&metricsAddr, &logPrefix)

}
开发者ID:sgichohi,项目名称:go-stream,代码行数:7,代码来源:metrics.go


示例7: ExtraNewMetricRAM

func ExtraNewMetricRAM(r metrics.Registry, extra RAMUpdater) *MetricRAM {
	return &MetricRAM{
		Free:  metrics.NewRegisteredGauge("memory.memory-free", r),
		Total: metrics.NewRegisteredGauge("memory.memory-total", metrics.NewRegistry()),
		Extra: extra,
	}
}
开发者ID:vadv,项目名称:ostent,代码行数:7,代码来源:operating.go


示例8: New

// New will mint a new Instrumentation - getting statsd connection details from the config service and then looking out
// for any changes.
func New() *Instrumentation {
	ch := config.SubscribeChanges()
	addr := loadStatsdAddr()
	inst := &Instrumentation{
		namespace:     "default",
		confHash:      addr,
		statsd:        loadStatsd(addr),
		registry:      metrics.NewRegistry(),
		savedTimers:   make(map[string]metrics.Timer),
		savedCounters: make(map[string]metrics.Counter),
		savedGauges:   make(map[string]metrics.Gauge),
		launched:      time.Now(),
		instRuntime:   false,
	}

	inst.StartRuntime()

	// Launch listener for config changes
	go func() {
		for _ = range ch {
			inst.mtx.Lock()
			if addr := loadStatsdAddr(); addr != inst.confHash {
				// @todo close old statsd here -- but no way to do this yet
				inst.statsd = loadStatsd(addr)
			}
			inst.mtx.Unlock()
		}
	}()

	return inst
}
开发者ID:armada-io,项目名称:h2,代码行数:33,代码来源:instrumentation.go


示例9: monitorIssueTracker

// monitorIssueTracker reads the counts for all the types of issues in the skia
// issue tracker (code.google.com/p/skia) and stuffs the counts into Graphite.
func monitorIssueTracker() {
	c := &http.Client{
		Transport: &http.Transport{
			Dial: dialTimeout,
		},
	}

	if *useMetadata {
		*apikey = metadata.Must(metadata.ProjectGet(metadata.APIKEY))
	}

	// Create a new metrics registry for the issue tracker metrics.
	addr, err := net.ResolveTCPAddr("tcp", *graphiteServer)
	if err != nil {
		glog.Fatalln("Failed to resolve the Graphite server: ", err)
	}
	issueRegistry := metrics.NewRegistry()
	go graphite.Graphite(issueRegistry, common.SAMPLE_PERIOD, "issues", addr)

	// IssueStatus has all the info we need to capture and record a single issue status. I.e. capture
	// the count of all issues with a status of "New".
	type IssueStatus struct {
		Name   string
		Metric metrics.Gauge
		URL    string
	}

	allIssueStatusLabels := []string{
		"New", "Accepted", "Unconfirmed", "Started", "Fixed", "Verified", "Invalid", "WontFix", "Done", "Available", "Assigned",
	}

	issueStatus := []*IssueStatus{}
	for _, issueName := range allIssueStatusLabels {
		issueStatus = append(issueStatus, &IssueStatus{
			Name:   issueName,
			Metric: metrics.NewRegisteredGauge(strings.ToLower(issueName), issueRegistry),
			URL:    "https://www.googleapis.com/projecthosting/v2/projects/skia/issues?fields=totalResults&key=" + *apikey + "&status=" + issueName,
		})
	}

	liveness := imetrics.NewLiveness("issue-tracker")
	for _ = range time.Tick(ISSUE_TRACKER_PERIOD) {
		for _, issue := range issueStatus {
			resp, err := c.Get(issue.URL)
			jsonResp := map[string]int64{}
			dec := json.NewDecoder(resp.Body)
			if err := dec.Decode(&jsonResp); err != nil {
				glog.Warningf("Failed to decode JSON response: %s", err)
				util.Close(resp.Body)
				continue
			}
			issue.Metric.Update(jsonResp["totalResults"])
			glog.Infof("Num Issues: %s - %d", issue.Name, jsonResp["totalResults"])
			if err == nil && resp.Body != nil {
				util.Close(resp.Body)
			}
		}
		liveness.Update()
	}
}
开发者ID:Tiger66639,项目名称:skia-buildbot,代码行数:62,代码来源:main.go


示例10: NewConfigLocal

// NewConfigLocal constructs a new ConfigLocal with default components.
func NewConfigLocal() *ConfigLocal {
	config := &ConfigLocal{}
	config.SetClock(wallClock{})
	config.SetReporter(NewReporterSimple(config.Clock(), 10))
	config.SetConflictRenamer(TimeAndWriterConflictRenamer{config})
	config.SetMDCache(NewMDCacheStandard(5000))
	config.SetKeyCache(NewKeyCacheStandard(5000))
	// Limit the block cache to 10K entries or 512 MB of bytes
	config.SetBlockCache(NewBlockCacheStandard(config, 10000, 512*1024*1024))
	config.SetCodec(NewCodecMsgpack())
	config.SetMDOps(&MDOpsStandard{config})
	config.SetBlockOps(&BlockOpsStandard{config})
	config.SetKeyOps(&KeyOpsStandard{config})
	config.SetRekeyQueue(NewRekeyQueueStandard(config))

	config.maxFileBytes = maxFileBytesDefault
	config.maxNameBytes = maxNameBytesDefault
	config.maxDirBytes = maxDirBytesDefault

	// Don't bother creating the registry if UseNilMetrics is set.
	if !metrics.UseNilMetrics {
		registry := metrics.NewRegistry()
		config.SetMetricsRegistry(registry)
	}
	return config
}
开发者ID:gozes,项目名称:kbfs-beta,代码行数:27,代码来源:config_local.go


示例11: GetOrRegisterPrivateDF

func (ir *IndexRegistry) GetOrRegisterPrivateDF(fs sigar.FileSystem) operating.MetricDF {
	ir.PrivateMutex.Lock()
	defer ir.PrivateMutex.Unlock()
	if fs.DirName == "/" {
		fs.DevName = "root"
	} else {
		fs.DevName = strings.Replace(strings.TrimPrefix(fs.DevName, "/dev/"), "/", "-", -1)
	}
	if metric := ir.PrivateDFRegistry.Get(fs.DevName); metric != nil {
		return metric.(operating.MetricDF)
	}
	label := func(tail string) string {
		return fmt.Sprintf("df-%s.df_complex-%s", fs.DevName, tail)
	}
	r, unusedr := ir.Registry, metrics.NewRegistry()
	i := operating.MetricDF{
		DF: &operating.DF{
			DevName:     &operating.StandardMetricString{}, // unregistered
			DirName:     &operating.StandardMetricString{}, // unregistered
			Free:        metrics.NewRegisteredGaugeFloat64(label("free"), r),
			Reserved:    metrics.NewRegisteredGaugeFloat64(label("reserved"), r),
			Total:       metrics.NewRegisteredGauge(label("total"), unusedr),
			Used:        metrics.NewRegisteredGaugeFloat64(label("used"), r),
			Avail:       metrics.NewRegisteredGauge(label("avail"), unusedr),
			UsePercent:  metrics.NewRegisteredGaugeFloat64(label("usepercent"), unusedr),
			Inodes:      metrics.NewRegisteredGauge(label("inodes"), unusedr),
			Iused:       metrics.NewRegisteredGauge(label("iused"), unusedr),
			Ifree:       metrics.NewRegisteredGauge(label("ifree"), unusedr),
			IusePercent: metrics.NewRegisteredGaugeFloat64(label("iusepercent"), unusedr),
		},
	}
	ir.PrivateDFRegistry.Register(fs.DevName, i) // error is ignored
	// errs when the type is not derived from (go-)metrics types
	return i
}
开发者ID:vadv,项目名称:ostent,代码行数:35,代码来源:index.go


示例12: newMemoryMetricaDataSource

func newMemoryMetricaDataSource(pollInterval int) goMetricaDataSource {
	r := metrics.NewRegistry()

	metrics.RegisterRuntimeMemStats(r)
	metrics.CaptureRuntimeMemStatsOnce(r)
	go metrics.CaptureRuntimeMemStats(r, time.Duration(pollInterval)*time.Second)
	return goMetricaDataSource{r}
}
开发者ID:ChrisSmith,项目名称:gorelic,代码行数:8,代码来源:memory_metrics.go


示例13: newStats

func newStats() *stats {
	return &stats{
		registry:   metrics.NewRegistry(),
		startTime:  time.Now(),
		timers:     make(map[Endpoint]endpointTimers),
		recordChan: make(chan *endpointResult, 100),
		terminate:  make(chan chan bool),
	}
}
开发者ID:choirudin2210,项目名称:platform-layer,代码行数:9,代码来源:stats.go


示例14: monitorIssueTracker

// monitorIssueTracker reads the counts for all the types of issues in the Skia
// issue tracker (bugs.chromium.org/p/skia) and stuffs the counts into Graphite.
func monitorIssueTracker(c *http.Client) {
	// Create a new metrics registry for the issue tracker metrics.
	addr, err := net.ResolveTCPAddr("tcp", *graphiteServer)
	if err != nil {
		glog.Fatalln("Failed to resolve the Graphite server: ", err)
	}
	issueRegistry := metrics.NewRegistry()
	go graphite.Graphite(issueRegistry, common.SAMPLE_PERIOD, "issues", addr)

	// IssueStatus has all the info we need to capture and record a single issue status. I.e. capture
	// the count of all issues with a status of "New".
	type IssueStatus struct {
		Name   string
		Metric metrics.Gauge
		URL    string
	}

	allIssueStatusLabels := []string{
		"New", "Accepted", "Unconfirmed", "Started", "Fixed", "Verified", "Invalid", "WontFix", "Done", "Available", "Assigned",
	}

	issueStatus := []*IssueStatus{}
	for _, issueName := range allIssueStatusLabels {
		q := url.Values{}
		q.Set("fields", "totalResults")
		q.Set("status", issueName)
		issueStatus = append(issueStatus, &IssueStatus{
			Name:   issueName,
			Metric: metrics.NewRegisteredGauge(strings.ToLower(issueName), issueRegistry),
			URL:    issues.MONORAIL_BASE_URL + "?" + q.Encode(),
		})
	}

	liveness := imetrics.NewLiveness("issue-tracker")
	for _ = range time.Tick(ISSUE_TRACKER_PERIOD) {
		for _, issue := range issueStatus {
			resp, err := c.Get(issue.URL)
			if err != nil {
				glog.Errorf("Failed to retrieve response from %s: %s", issue.URL, err)
				continue
			}
			jsonResp := map[string]int64{}
			dec := json.NewDecoder(resp.Body)
			if err := dec.Decode(&jsonResp); err != nil {
				glog.Warningf("Failed to decode JSON response: %s", err)
				util.Close(resp.Body)
				continue
			}
			issue.Metric.Update(jsonResp["totalResults"])
			glog.Infof("Num Issues: %s - %d", issue.Name, jsonResp["totalResults"])
			if err == nil && resp.Body != nil {
				util.Close(resp.Body)
			}
		}
		liveness.Update()
	}
}
开发者ID:saltmueller,项目名称:skia-buildbot,代码行数:59,代码来源:main.go


示例15: newStandardBucket

func newStandardBucket(name string) standardBucket {
	registry := gometrics.NewRegistry()

	gometrics.RegisterRuntimeMemStats(registry)
	go gometrics.CaptureRuntimeMemStats(registry, RuntimeMemStatsSampleInterval)

	return standardBucket{
		name:     name,
		registry: registry,
		timers:   make(map[string]Timer),
		gauges:   make(map[string]Gauge),
	}
}
开发者ID:Rozandas,项目名称:etcd,代码行数:13,代码来源:standard.go


示例16: ExtraNewMetricCPU

func ExtraNewMetricCPU(r metrics.Registry, name string, extra CPUUpdater) *MetricCPU {
	return &MetricCPU{
		CPU: &CPU{
			N:     Field(name),
			User:  NewGaugePercent(name+".user", r),
			Nice:  NewGaugePercent(name+".nice", r),
			Sys:   NewGaugePercent(name+".system", r),
			Idle:  NewGaugePercent(name+".idle", r),
			Total: NewGaugeDiff(name+"-total", metrics.NewRegistry()),
			Extra: extra,
		},
	}
}
开发者ID:vadv,项目名称:ostent,代码行数:13,代码来源:operating.go


示例17: gmStatsDRegistry

// gmStatsDRegistry returns a go-metrics registry that reports to a StatsD server.
func gmStatsDRegistry(prefix, addr string, interval time.Duration) (Registry, error) {
	if addr == "" {
		return nil, errors.New(" statsd addr missing")
	}

	a, err := net.ResolveUDPAddr("udp", addr)
	if err != nil {
		return nil, fmt.Errorf(" cannot connect to StatsD: %s", err)
	}

	r := gm.NewRegistry()
	go statsd.StatsD(r, interval, prefix, a)
	return &gmRegistry{r}, nil
}
开发者ID:hilerchyn,项目名称:fabio,代码行数:15,代码来源:gometrics.go


示例18: gmGraphiteRegistry

// gmGraphiteRegistry returns a go-metrics registry that reports to a Graphite server.
func gmGraphiteRegistry(prefix, addr string, interval time.Duration) (Registry, error) {
	if addr == "" {
		return nil, errors.New(" graphite addr missing")
	}

	a, err := net.ResolveTCPAddr("tcp", addr)
	if err != nil {
		return nil, fmt.Errorf(" cannot connect to Graphite: %s", err)
	}

	r := gm.NewRegistry()
	go graphite.Graphite(r, interval, prefix, a)
	return &gmRegistry{r}, nil
}
开发者ID:hilerchyn,项目名称:fabio,代码行数:15,代码来源:gometrics.go


示例19: InitPing

// start the ping for each ip, init metrics.
func InitPing(pi *PingInfo) {
	for _, ip := range pi.Hosts {
		registry := metrics.NewRegistry()
		(*pi.Registries)[ip] = &registry

		// ping each host listed -- print when complete
		go func(ip string, registry *metrics.Registry) {
			for {
				pi.connectAndPing(ip, registry)
				time.Sleep(time.Duration(pi.Repeat) * time.Second)
			}
		}(ip, (*pi.Registries)[ip])
	}
}
开发者ID:mehulsbhatt,项目名称:gollector-monitors,代码行数:15,代码来源:ping.go


示例20: TestFilters

func TestFilters(t *testing.T) {
	mock := &MockPutMetricsClient{}
	cfg := &config.Config{
		Client: mock,
		Filter: &config.AllFilter{},
	}
	registry := metrics.NewRegistry()
	timer := metrics.GetOrRegisterTimer(fmt.Sprintf("timer"), registry)
	timer.Update(10 * time.Second)
	emitMetrics(registry, cfg)

	if mock.metricsPut > 0 {
		t.Fatal("Metrics Put")
	}
}
开发者ID:sclasen,项目名称:go-metrics-cloudwatch,代码行数:15,代码来源:cloudwatch_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang go-metrics.Counter类代码示例发布时间:2022-05-28
下一篇:
Golang go-metrics.NewRegisteredGauge函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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