请选择 进入手机版 | 继续访问电脑版

技术控

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

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

[复制链接]
香樟 发表于 2016-10-3 16:31:30
133 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

  1. 2016/10/03 00:27:34 message=found file=../../events.go trace=main
  2. 2016/10/03 00:27:34 message=found file=../../examples/gogrep/main.go trace=main
  3. 2016/10/03 00:27:34 message=found file=../../log.go trace=main
  4. 2016/10/03 00:27:34 message=found file=../../trace.go trace=main
  5. 2016/10/03 00:27:34 message=found file=../../metrics.go trace=main
  6. 2016/10/03 00:27:34 trace=main : hit count 5
  7. 2016/10/03 00:27:34 message=finished hits=5 trace=main
复制代码
Log Output - EventLog

  1. 2016/10/03 00:34:05 name=http - Listening on :3000
复制代码
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
帖子很有深度!
回复 支持 反对

使用道具 举报

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

本版积分规则

我要投稿

推荐阅读


回页顶回复上一篇下一篇回列表
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )

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

返回顶部 返回列表