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

Golang statsd.Client类代码示例

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

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



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

示例1: SendLineStats

// SendLineStats sends the stats to Datadog.
func SendLineStats(dog *statsd.Client, line string, metric string) {
	Log(fmt.Sprintf("%s: %s", metric, line), "debug")
	oldTags := dog.Tags
	dog.Tags = append(dog.Tags, fmt.Sprintf("record:%s", metric))
	dog.Count("dnsmasq.event", 1, dog.Tags, 1)
	dog.Tags = oldTags
}
开发者ID:darron,项目名称:goshe,代码行数:8,代码来源:dnsmasq_full_logs.go


示例2: sendHistogramStats

func sendHistogramStats(metric string, value float64, additionalTag string, dog *statsd.Client) {
	tags := dog.Tags
	dog.Tags = append(dog.Tags, additionalTag)
	if os.Getenv("GOSHE_ADDITIONAL_TAGS") != "" {
		dog.Tags = append(dog.Tags, os.Getenv("GOSHE_ADDITIONAL_TAGS"))
	}
	dog.Histogram(metric, value, tags, 1)
	dog.Tags = tags
}
开发者ID:darron,项目名称:goshe,代码行数:9,代码来源:dnsmasq_signal_stats.go


示例3: sendQueriesStats

// sendQueriesStats actually sends the stats to Dogstatsd.
func sendQueriesStats(metric string, value int64, additionalTag string, dog *statsd.Client) {
	tags := dog.Tags
	dog.Tags = append(dog.Tags, additionalTag)
	if os.Getenv("GOSHE_ADDITIONAL_TAGS") != "" {
		dog.Tags = append(dog.Tags, os.Getenv("GOSHE_ADDITIONAL_TAGS"))
	}
	dog.Count(metric, value, tags, signalInterval)
	dog.Tags = tags
}
开发者ID:darron,项目名称:goshe,代码行数:10,代码来源:dnsmasq_signal_stats.go


示例4: sendPingStats

func sendPingStats(dog *statsd.Client, rtt time.Duration) {
	var err error
	seconds := (float64(rtt) / 1000000000)
	address := strings.ToLower(strings.Replace(Endpoint, ".", "_", -1))
	metricName := fmt.Sprintf("ping.%s", address)
	err = dog.Histogram(metricName, seconds, dog.Tags, 1)
	if err != nil {
		Log(fmt.Sprintf("Error sending ping stats for '%s'", Endpoint), "info")
	}
}
开发者ID:darron,项目名称:goshe,代码行数:10,代码来源:ping.go


示例5: InstrumentMiddleware

// InstrumentMiddleware collects metrics about the current request.
func InstrumentMiddleware(stats *statsd.Client) echo.MiddlewareFunc {
	return func(next echo.HandlerFunc) echo.HandlerFunc {
		return func(c echo.Context) error {
			defer func(start time.Time) {
				tags := []string{
					"method:" + c.Request().Method(),
					"status:" + strconv.Itoa(c.Response().Status()),
				}

				stats.Count("laika.request_total", 1, tags, 1)
				stats.Histogram("laika.request_duration_microseconds", float64(int(time.Since(start).Seconds()*1000000)), tags, 1)
			}(time.Now())

			return next(c)
		}
	}
}
开发者ID:MEDIGO,项目名称:laika,代码行数:18,代码来源:middleware.go


示例6: TailLog

// TailLog tails a file and sends stats to Datadog.
func TailLog(t *tail.Tail, dog *statsd.Client, r *regexp.Regexp) {
	for line := range t.Lines {
		// Blank lines really mess this up - this protects against it.
		if line.Text == "" {
			continue
		}
		match := r.FindAllStringSubmatch(line.Text, -1)
		if match != nil {
			Log(fmt.Sprintf("Match: %s", match), "debug")
			Log(fmt.Sprintf("Sending Stat: %s", MetricName), "debug")
			tags := dog.Tags
			if MetricTag != "" {
				tags = append(tags, MetricTag)
			}
			dog.Count(MetricName, 1, tags, 1)
		}
	}
}
开发者ID:darron,项目名称:goshe,代码行数:19,代码来源:tail.go


示例7: runCommand

func runCommand(cli string, args []string, r *regexp.Regexp, dog *statsd.Client) {
	cmd := exec.Command(cli, args...)
	cmdReader, err := cmd.StdoutPipe()
	if err != nil {
		Log(fmt.Sprintf("There was an error running '%s': %s", ProgramStdout, err), "info")
		os.Exit(1)
	}
	scanner := bufio.NewScanner(cmdReader)
	go func() {
		for scanner.Scan() {
			line := scanner.Text()
			Log(fmt.Sprintf("Line: %s", line), "debug")
			// Blank lines are bad for the matching software - it freaks out.
			if line == "" {
				continue
			}
			match := r.FindAllStringSubmatch(line, -1)
			if match != nil {
				Log(fmt.Sprintf("Match: %s", match), "debug")
				Log(fmt.Sprintf("Sending Stat: %s", MetricName), "debug")
				tags := dog.Tags
				if MetricTag != "" {
					tags = append(tags, MetricTag)
				}
				dog.Count(MetricName, 1, tags, 1)
			}
		}
	}()

	err = cmd.Start()
	if err != nil {
		Log("There was and error starting the command.", "info")
	}

	err = cmd.Wait()
	if err != nil {
		Log("There was and error waiting for the command.", "info")
	}
}
开发者ID:darron,项目名称:goshe,代码行数:39,代码来源:tail.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang assert.Equal函数代码示例发布时间:2022-05-23
下一篇:
Golang ts.TimeSeries类代码示例发布时间: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