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

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

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

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



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

示例1: NewLocalMetrics

func NewLocalMetrics(reportInterval time.Duration) *LocalMetrics {
	metrics := LocalMetrics{
		Logger:         log.NewPrefixLogger("metrics"),
		reportInterval: reportInterval,
		windowsCounter: gometrics.NewCounter(),
		linuxCounter:   gometrics.NewCounter(),
		osxCounter:     gometrics.NewCounter(),
		otherCounter:   gometrics.NewCounter(),

		tunnelMeter:        gometrics.NewMeter(),
		tcpTunnelMeter:     gometrics.NewMeter(),
		httpTunnelMeter:    gometrics.NewMeter(),
		connMeter:          gometrics.NewMeter(),
		lostHeartbeatMeter: gometrics.NewMeter(),

		connTimer: gometrics.NewTimer(),

		bytesInCount:  gometrics.NewCounter(),
		bytesOutCount: gometrics.NewCounter(),

		/*
		   metrics.tunnelGauge = gometrics.NewGauge(),
		   metrics.tcpTunnelGauge = gometrics.NewGauge(),
		   metrics.connGauge = gometrics.NewGauge(),
		*/
	}

	go metrics.Report()

	return &metrics
}
开发者ID:0x19,项目名称:ngrok,代码行数:31,代码来源:metrics.go


示例2: NewMetricsDB

func NewMetricsDB() *MetricsDB {
	return &MetricsDB{
		connections: mt.NewHistogram(mt.NewExpDecaySample(1028, 0.015)),
		queries:     mt.NewMeter(),
		executes:    mt.NewMeter(),
		rows:        mt.NewMeter(),
		affects:     mt.NewMeter(),
		timers:      &MeticsTimers{timers: make(map[string]mt.Timer)},
	}
}
开发者ID:najeira,项目名称:goutils,代码行数:10,代码来源:metrics.go


示例3: NewMetricsHttp

func NewMetricsHttp() *MetricsHttp {
	return &MetricsHttp{
		clients:        mt.NewHistogram(mt.NewExpDecaySample(1028, 0.015)),
		clientsCounter: mt.NewCounter(),
		requests:       mt.NewTimer(),
		status2xx:      mt.NewMeter(),
		status3xx:      mt.NewMeter(),
		status4xx:      mt.NewMeter(),
		status5xx:      mt.NewMeter(),
	}
}
开发者ID:najeira,项目名称:goutils,代码行数:11,代码来源:metrics.go


示例4: NewProcessCpuMetrics

func NewProcessCpuMetrics(prefix string) *ProcessCpuMetrics {
	cpu := &ProcessCpuMetrics{
		User:  gmetrics.NewMeter(),
		Sys:   gmetrics.NewMeter(),
		Total: gmetrics.NewMeter(),
	}

	gmetrics.Register(prefix+".cpu.user", cpu.User)
	gmetrics.Register(prefix+".cpu.sys", cpu.Sys)
	gmetrics.Register(prefix+".cpu.total", cpu.Total)

	return cpu
}
开发者ID:ninjasphere,项目名称:mqtt-proxy,代码行数:13,代码来源:runtime.go


示例5: NewProxyMetrics

func NewProxyMetrics() ProxyMetrics {
	pm := ProxyMetrics{
		Requests:        gmetrics.NewMeter(),
		CmdReply:        gmetrics.NewMeter(),
		CmdForward:      gmetrics.NewMeter(),
		RequestBodySize: gmetrics.NewHistogram(gmetrics.NewExpDecaySample(1028, 0.015)),
	}

	gmetrics.Register("vulcan.proxy.requests", pm.Requests)
	gmetrics.Register("vulcan.proxy.cmd_reply", pm.CmdReply)
	gmetrics.Register("vulcan.proxy.cmd_forward", pm.CmdForward)
	gmetrics.Register("vulcan.proxy.request_body_size", pm.RequestBodySize)

	return pm
}
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:15,代码来源:metrics.go


示例6: NewUpstreamMetrics

func NewUpstreamMetrics(upstreamId string) UpstreamMetrics {
	hm := NewHttpMetrics(fmt.Sprintf("vulcan.upstream.%s", upstreamId))
	um := UpstreamMetrics{
		Requests:  gmetrics.NewMeter(),
		Failovers: gmetrics.NewMeter(),
		Latency:   gmetrics.NewTimer(),
		Http:      &hm,
	}

	gmetrics.Register(fmt.Sprintf("vulcan.upstream.%s.requests", upstreamId), um.Requests)
	gmetrics.Register(fmt.Sprintf("vulcan.upstream.%s.latency", upstreamId), um.Failovers)
	gmetrics.Register(fmt.Sprintf("vulcan.upstream.%s.failovers", upstreamId), um.Failovers)

	return um
}
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:15,代码来源:metrics.go


示例7: NewFileHandlerAdapter

func NewFileHandlerAdapter(updater Updater, factory mailfile.MailFileFactory) *FileHandlerAdapter {
	total := metrics.NewCounter()
	meter := metrics.NewMeter()
	metrics.Register("FileHandlerAdapter-Total", total)
	metrics.Register("FileHandlerAdapter-Size", meter)
	return &FileHandlerAdapter{updater, factory, total, meter}
}
开发者ID:postfix,项目名称:spamdefender,代码行数:7,代码来源:filehandleradapter.go


示例8: NewHttp

func NewHttp() *Http {
	return &Http{
		Txns:     util.NewBroadcast(),
		reqGauge: metrics.NewGauge(),
		reqMeter: metrics.NewMeter(),
		reqTimer: metrics.NewTimer(),
	}
}
开发者ID:koolshare,项目名称:ngrok-1.7,代码行数:8,代码来源:http.go


示例9: NewRocksDB

func NewRocksDB(path string) (*RocksDB, error) {
	opts := gorocksdb.NewDefaultOptions()
	filter := gorocksdb.NewBloomFilter(14)
	opts.SetFilterPolicy(filter)
	opts.SetMaxOpenFiles(10000)
	db, err := gorocksdb.OpenDbForReadOnly(opts, path, false)
	if err != nil {
		return nil, err
	}
	return &RocksDB{
		db:     db,
		ro:     gorocksdb.NewDefaultReadOptions(),
		hits:   metrics.NewMeter(),
		misses: metrics.NewMeter(),
		cache:  lru.New(1000000),
	}, nil
}
开发者ID:robcat,项目名称:ripple,代码行数:17,代码来源:rocksdb.go


示例10: NewClientMetrics

func NewClientMetrics() *ClientMetrics {
	return &ClientMetrics{
		connGauge:       metrics.NewGauge(),
		connMeter:       metrics.NewMeter(),
		connTimer:       metrics.NewTimer(),
		proxySetupTimer: metrics.NewTimer(),
		bytesIn:         metrics.NewHistogram(metrics.NewExpDecaySample(sampleSize, sampleAlpha)),
		bytesOut:        metrics.NewHistogram(metrics.NewExpDecaySample(sampleSize, sampleAlpha)),
		bytesInCount:    metrics.NewCounter(),
		bytesOutCount:   metrics.NewCounter(),
	}
}
开发者ID:0x19,项目名称:ngrok,代码行数:12,代码来源:metrics.go


示例11: addGCMetrics

func addGCMetrics(p *newrelic.Plugin) {
	numGC := metrics.NewMeter()
	pauseDur := metrics.NewMeter()
	pauseTime := metrics.NewHistogram(metrics.NewExpDecaySample(10000, 0.015))
	gcr := &gcReader{
		sampleRate: time.Second * 10,
		numGC:      numGC,
		pauseDur:   pauseDur,
		pauseTime:  pauseTime,
	}
	gcr.Run()

	nrmetrics.AddMeterMetric(p, numGC, nrmetrics.MetricConfig{Name: "GC/GC Pauses Per Second", Unit: "pauses", Rate1: true, Rate5: true, Rate15: true})
	nrmetrics.AddMeterMetric(p, pauseDur, nrmetrics.MetricConfig{Name: "GC/GC Pause Time Per Second", Unit: "nanoseconds", Rate1: true, Rate5: true, Rate15: true})
	nrmetrics.AddHistogramMetric(p, pauseTime, nrmetrics.MetricConfig{
		Name:        "GC/GC Time Per Pause",
		Unit:        "pauses",
		Duration:    time.Microsecond,
		Mean:        true,
		Percentiles: []float64{0.5, 0.75, 0.9, 0.99, 0.999},
	})
}
开发者ID:neocortical,项目名称:gonr,代码行数:22,代码来源:gc.go


示例12: NewProxyMetrics

// conf.Environment, conf.Region
func NewProxyMetrics(env string, region string) ProxyMetrics {

	prefix := buildPrefix(env, region)

	pm := ProxyMetrics{
		Msgs:        gmetrics.NewMeter(),
		MsgReply:    gmetrics.NewMeter(),
		MsgForward:  gmetrics.NewMeter(),
		MsgBodySize: gmetrics.NewHistogram(gmetrics.NewExpDecaySample(1028, 0.015)),
		Connects:    gmetrics.NewMeter(),
		Connections: gmetrics.NewGauge(),
	}

	gmetrics.Register(prefix+".proxy.msgs", pm.Msgs)
	gmetrics.Register(prefix+".proxy.msg_reply", pm.Msgs)
	gmetrics.Register(prefix+".proxy.msg_forward", pm.Msgs)
	gmetrics.Register(prefix+".proxy.msg_body_size", pm.MsgBodySize)
	gmetrics.Register(prefix+".proxy.connects", pm.Connects)
	gmetrics.Register(prefix+".proxy.connections", pm.Connections)

	return pm
}
开发者ID:ninjasphere,项目名称:mqtt-proxy,代码行数:23,代码来源:proxy.go


示例13: initializeFieldTagPath

// initializeFieldTagPath traverses the given struct trying to initialize
// metric values.  The "metric" struct tag is used to determine the name of the
// metrics for each struct field. If there is no "metric" struct tag, the
// lowercased struct field name is used for the metric name. The name is
// prefixed with tags from previous struct fields if any, separated by a dot.
// For example:
//
//     	Messages struct {
//          Smtp struct {
//              Latency metrics.Timer `metric:"latency"`
//          } `metric:"smtp"`
//          Http struct {
//              Latency metrics.Timer `metric:"latency"`
//          } `metric:"http"`
//      } `metric:"messages"`
//
// yields timers with names "messages.smtp.latency" and "messages.http.latency"
// respectively.
//
// If there is no metric tag for a field it is skipped and assumed it is used
// for other purposes such as configuration.
func (m *MetricTags) initializeFieldTagPath(fieldType reflect.Value, prefix string) {
	for i := 0; i < fieldType.NumField(); i++ {
		val := fieldType.Field(i)
		field := fieldType.Type().Field(i)

		tag := field.Tag.Get("metric")
		if tag == "" {
			// If tag isn't found, derive tag from the lower case name of
			// the field.
			tag = strings.ToLower(field.Name)
		}
		if prefix != "" {
			tag = prefix + m.separator + tag
		}

		if field.Type.Kind() == reflect.Struct {
			// Recursively traverse an embedded struct
			m.initializeFieldTagPath(val, tag)
		} else if field.Type.Kind() == reflect.Map && field.Type.Key().Kind() == reflect.String {
			// If this is a map[string]Something, then use the string key as bucket name and recursively generate the metrics below
			for _, k := range val.MapKeys() {
				m.initializeFieldTagPath(val.MapIndex(k).Elem(), tag+m.separator+k.String())
			}
		} else {
			// Found a field, initialize
			switch field.Type.String() {
			case "metrics.Counter":
				c := metrics.NewCounter()
				metrics.Register(tag, c)
				val.Set(reflect.ValueOf(c))
			case "metrics.Timer":
				t := metrics.NewTimer()
				metrics.Register(tag, t)
				val.Set(reflect.ValueOf(t))
			case "metrics.Meter":
				m := metrics.NewMeter()
				metrics.Register(tag, m)
				val.Set(reflect.ValueOf(m))
			case "metrics.Gauge":
				g := metrics.NewGauge()
				metrics.Register(tag, g)
				val.Set(reflect.ValueOf(g))
			case "metrics.Histogram":
				s := metrics.NewUniformSample(1028)
				h := metrics.NewHistogram(s)
				metrics.Register(tag, h)
				val.Set(reflect.ValueOf(h))
			}
		}
	}
}
开发者ID:sendgrid,项目名称:tagtrics,代码行数:72,代码来源:tagtrics.go


示例14: NewHttpMetric

func NewHttpMetric() *HttpMetric {
	x := &HttpMetric{
		Requests: metrics.NewCounter(),
		Rate:     metrics.NewMeter(),

		Responses2xx: metrics.NewCounter(),
		Responses3xx: metrics.NewCounter(),
		Responses4xx: metrics.NewCounter(),
		Responses5xx: metrics.NewCounter(),
		ResponsesXxx: metrics.NewCounter(),
		Latency:      metrics.NewHistogram(metrics.NewExpDecaySample(1028, 0.015)),
	}
	return x
}
开发者ID:hanjinze,项目名称:gorouter,代码行数:14,代码来源:varz.go


示例15: NewProcessMemoryMetrics

func NewProcessMemoryMetrics(prefix string) *ProcessMemoryMetrics {

	mem := &ProcessMemoryMetrics{
		Resident:   gmetrics.NewGauge(),
		Shared:     gmetrics.NewGauge(),
		PageFaults: gmetrics.NewMeter(),
	}

	gmetrics.Register(prefix+".mem.resident", mem.Resident)
	gmetrics.Register(prefix+".mem.shared", mem.Shared)
	gmetrics.Register(prefix+".mem.pagefaults", mem.PageFaults)

	return mem
}
开发者ID:ninjasphere,项目名称:mqtt-proxy,代码行数:14,代码来源:runtime.go


示例16: init

func init() {
	metrics = &metricsDB{
		connections: mt.NewHistogram(mt.NewExpDecaySample(1028, 0.015)),
		queries:     mt.NewMeter(),
		executes:    mt.NewMeter(),
		rows:        mt.NewMeter(),
		affects:     mt.NewMeter(),
		begins:      mt.NewMeter(),
		commits:     mt.NewMeter(),
		rollbacks:   mt.NewMeter(),
	}
	timers = &timersDB{timers: make(map[string]mt.Timer)}
}
开发者ID:najeira,项目名称:sql,代码行数:13,代码来源:metrics.go


示例17: markSingleCode

func (hm *HttpMetrics) markSingleCode(statusCode int) {
	// TOOD(pquerna): profile to see if this is horrible
	hm.rcmutex.Lock()
	defer hm.rcmutex.Unlock()
	var meter gmetrics.Meter

	meter, ok := hm.ResponseCodes[statusCode]

	if !ok {
		hm.ResponseCodes[statusCode] = gmetrics.NewMeter()
		meter = hm.ResponseCodes[statusCode]
		gmetrics.Register(fmt.Sprintf("%s.http.status.%d", hm.prefix, statusCode), meter)
	}

	meter.Mark(1)
}
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:16,代码来源:metrics.go


示例18: NewHttpMetrics

func NewHttpMetrics(prefix string) HttpMetrics {
	hm := HttpMetrics{prefix: prefix,
		ResponseRanges: map[string]gmetrics.Meter{
			"1XX": gmetrics.NewMeter(),
			"2XX": gmetrics.NewMeter(),
			"3XX": gmetrics.NewMeter(),
			"4XX": gmetrics.NewMeter(),
			"5XX": gmetrics.NewMeter(),
			"UNK": gmetrics.NewMeter(),
		},
		ResponseCodes: make(map[int]gmetrics.Meter),
	}

	for k, v := range hm.ResponseRanges {
		gmetrics.Register(fmt.Sprintf("%s.http.%s", prefix, k), v)
	}

	return hm
}
开发者ID:karlpilkington,项目名称:golang-devops-stuff,代码行数:19,代码来源:metrics.go


示例19: addMemoryMetrics

func addMemoryMetrics(p *newrelic.Plugin) {
	allocInUse := metrics.NewGauge()
	allocTotal := metrics.NewGauge()
	sys := metrics.NewGauge()

	pointerLookups := metrics.NewMeter()
	mallocs := metrics.NewMeter()
	frees := metrics.NewMeter()

	allocHeap := metrics.NewGauge()
	heapSys := metrics.NewGauge()
	heapIdle := metrics.NewGauge()
	heapInUse := metrics.NewGauge()
	heapReleased := metrics.NewGauge()
	heapObjects := metrics.NewGauge()

	stackInUse := metrics.NewGauge()
	stackSys := metrics.NewGauge()

	mspanInUse := metrics.NewGauge()
	mspanSys := metrics.NewGauge()
	mcacheInUse := metrics.NewGauge()
	mcacheSys := metrics.NewGauge()
	buckHashSys := metrics.NewGauge()
	gcSys := metrics.NewGauge()
	otherSys := metrics.NewGauge()

	mr := &memReader{
		sampleRate:     time.Minute,
		allocInUse:     allocInUse,
		allocTotal:     allocTotal,
		pointerLookups: pointerLookups,
		mallocs:        mallocs,
		frees:          frees,
		allocHeap:      allocHeap,
		heapSys:        heapSys,
		heapIdle:       heapIdle,
		heapInUse:      heapInUse,
		heapReleased:   heapReleased,
		heapObjects:    heapObjects,
		stackInUse:     stackInUse,
		stackSys:       stackSys,
		mspanInUse:     mspanInUse,
		mspanSys:       mspanSys,
		mcacheInUse:    mcacheInUse,
		mcacheSys:      mcacheSys,
		buckHashSys:    buckHashSys,
		gcSys:          gcSys,
		otherSys:       otherSys,
	}
	mr.Run()

	nrmetrics.AddGaugeMetric(p, allocTotal, nrmetrics.MetricConfig{Name: "Memory/Summary/Allocated Over Time", Unit: "bytes", Value: true})

	nrmetrics.AddGaugeMetric(p, sys, nrmetrics.MetricConfig{Name: "Memory/Summary/System/Total", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapSys, nrmetrics.MetricConfig{Name: "Memory/System/Heap", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, stackSys, nrmetrics.MetricConfig{Name: "Memory/System/Stack", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, mspanSys, nrmetrics.MetricConfig{Name: "Memory/System/MSpan", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, mcacheSys, nrmetrics.MetricConfig{Name: "Memory/System/MCache", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, buckHashSys, nrmetrics.MetricConfig{Name: "Memory/System/BuckHash", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, gcSys, nrmetrics.MetricConfig{Name: "Memory/System/GC", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, otherSys, nrmetrics.MetricConfig{Name: "Memory/System/Other", Unit: "bytes", Value: true})

	nrmetrics.AddGaugeMetric(p, allocInUse, nrmetrics.MetricConfig{Name: "Memory/Summary/In Use/Total", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapInUse, nrmetrics.MetricConfig{Name: "Memory/In Use/Heap", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, stackInUse, nrmetrics.MetricConfig{Name: "Memory/In Use/Stack", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, mspanInUse, nrmetrics.MetricConfig{Name: "Memory/In Use/MSpan", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, mcacheInUse, nrmetrics.MetricConfig{Name: "Memory/In Use/MCache", Unit: "bytes", Value: true})

	nrmetrics.AddGaugeMetric(p, allocHeap, nrmetrics.MetricConfig{Name: "Memory/Heap/Allocated", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapIdle, nrmetrics.MetricConfig{Name: "Memory/Heap/Idle", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapInUse, nrmetrics.MetricConfig{Name: "Memory/Heap/In Use", Unit: "bytes", Value: true})
	nrmetrics.AddGaugeMetric(p, heapReleased, nrmetrics.MetricConfig{Name: "Memory/Heap/Released", Unit: "bytes", Value: true})

	nrmetrics.AddGaugeMetric(p, heapObjects, nrmetrics.MetricConfig{Name: "Memory/Events/Allocated Heap Objects", Unit: "objects", Value: true})

	nrmetrics.AddMeterMetric(p, pointerLookups, nrmetrics.MetricConfig{
		Name:   "Memory/Events/Pointer Lookups",
		Unit:   "lookups",
		Rate1:  true,
		Rate5:  true,
		Rate15: true,
	})
	nrmetrics.AddMeterMetric(p, mallocs, nrmetrics.MetricConfig{
		Name:   "Memory/Events/Mallocs",
		Unit:   "mallocs",
		Rate1:  true,
		Rate5:  true,
		Rate15: true,
	})
	nrmetrics.AddMeterMetric(p, frees, nrmetrics.MetricConfig{
		Name:   "Memory/Events/Frees",
		Unit:   "frees",
		Rate1:  true,
		Rate5:  true,
		Rate15: true,
	})
}
开发者ID:neocortical,项目名称:gonr,代码行数:98,代码来源:memory.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang go-metrics.NewRegisteredGauge函数代码示例发布时间:2022-05-28
下一篇:
Golang go-metrics.NewCounter函数代码示例发布时间: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