技术控

    今日:10| 主题:49195
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Trace - adds logging and metrics to net trace

[复制链接]
香樟 发表于 2016-10-3 16:31:30
103 2

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
Trace

      traceis a wrapper for    the net/trace packagethat adds logging and metrics to de-clutter your functions.  
      tracewraps all of the functionality of net/trace, but also replicates the logs to a structured logger built on Go's standard logging library.  
  Metrics are exported to Prometheus with trace duration histograms by name/family, trace counts by name/family, and errors by trace name/family.
  the net/trace#EventLog is also implemented in the same manner, minus metrics exposition, which doesn't make sense there.
  examples/gogrep has an example command-line application that shows usage of the    tracefunctionality to both capture trace information and logs with a single tool.  
  examples/service has an example web application that shows usage of the    tracefunctionality to both capture trace information and logs with a single tool, combined with the    trace.EventLogwhich serves as a single logging and event source for your application.  
  Log Output - trace

  [code]2016/10/03 00:27:34 message=found file=../../events.go trace=main
2016/10/03 00:27:34 message=found file=../../examples/gogrep/main.go trace=main
2016/10/03 00:27:34 message=found file=../../log.go trace=main
2016/10/03 00:27:34 message=found file=../../trace.go trace=main
2016/10/03 00:27:34 message=found file=../../metrics.go trace=main
2016/10/03 00:27:34 trace=main : hit count 5
2016/10/03 00:27:34 message=finished hits=5 trace=main[/code]  Log Output - EventLog

  [code]2016/10/03 00:34:05 name=http - Listening on :3000[/code]  Metrics Output

      traceoffers two useful and one fun way to expose your metrics.  
      trace.ServeMetrics()will serve the metrics in Prometheus text format. Use this for long-running apps/services.  
      trace.PushMetrics()will push the metrics to a Prometheus push server. Use this for command-line utilities.  
      trace.DumpMetrics()will return a string with the metrics that Prometheus would serve, suitable for inspection, printing, tests.  
  /debug endpoints

      traceexposes the underlying net/trace /debug/requests and /debug/events endpoints for handy visual representation of the traces, their timing/histograms, and the event log of your application.  
      Trace - adds logging and metrics to net trace-1 (structured,examples,standard,library,service)
Trace - adds logging and metrics to net trace-2 (structured,examples,standard,library,service)
友荐云推荐




上一篇:Optimizing parallel HTTP request batches
下一篇:深入浅出交换类排序算法(冒泡排序,快速排序)
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

Sean12345876 发表于 2016-10-12 12:39:37
那些路人甲乙丙丁在年生散场的剧场里将五彩纷呈和苍白无力潇洒的演绎。
回复 支持 反对

使用道具 举报

m啦风潇潇? 发表于 2016-10-28 10:32:14
帖子很有深度!
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表