技术控

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

[其他] goappmonitor:Golang 应用或业务性能监控

[复制链接]
考试那天我哭了 发表于 2016-11-29 10:39:38
328 0

goappmonitor:Golang 应用或业务性能监控

goappmonitor:Golang 应用或业务性能监控

  goappmonitor

         
  Golang application performance data monitoring.
  GoAppMonitor is a library which provides a monitor on your golang applications. It contains system level based monitoring and business level monitoring(custom monitoring).Just add the repository into your apps and registe what you want to monitoring.
  Summary

  Using GoAppMonitor to monitor the golang applications, in general as following:
  In your golang application code, the user calls the statistics function provided by goappmonitor; when the statistics function is called, the appmonitor generates a statistical record, and is stored in memory.GoAppMonitor will automatically and regularly record these statistics push to the agent such as Open-Falcon agent.
  Version

  version support agent:
   v0.0.1 -Open-Falcon (Open source monitoring system of Xiaomi)
  todo....

  
       
  • support more type metrics,such as ewma and flow type.   
  • remove third-part library.   
  • support more agent frameworks,such as elasticsearch...  
  Install

  1. go get github.com/wgliang/goappmonitor
复制代码
Demo

   

goappmonitor:Golang 应用或业务性能监控

goappmonitor:Golang 应用或业务性能监控

  Usage

   Below is an example which shows some common use cases for goappmonitor. Checkexample for more usage.
   DetailAPI
  1. package main
  2. import (
  3.     "math/rand"
  4.     "time"
  5.     appm "github.com/wgliang/goappmonitor"
  6. )
  7. // Base or system perfomance data,such as memeory,gc,network and so on.
  8. func baseOrsystem() {
  9.     for _ = range time.Tick(time.Second * time.Duration(10)) {
  10.         // (commonly used) Meter, used to sum and calculate the rate of change. Use scenarios
  11.         // such as the number of home visits statistics, CG etc..
  12.         pv := int64(rand.Int() % 100)
  13.         appm.Meter("appm.meter", pv)
  14.         appm.Meter("appm.meter.2", pv-50)
  15.         // (commonly used) Gauge, used to preserve the value of the instantaneous value of the
  16.         // type of record. Use scenarios such as statistical queue length, statistics CPU usage,
  17.         // and so on.
  18.         queueSize := int64(rand.Int()%100 - 50)
  19.         appm.Gauge("appm.gauge", queueSize)
  20.         cpuUtil := float64(rand.Int()%10000) / float64(100)
  21.         appm.GaugeFloat64("appm.gauge.float64", cpuUtil)
  22.     }
  23. }
  24. // Custom or business perfomance data,such as qps,num of function be called, task queue and so on.
  25. func customOrbusiness() {
  26.     for _ = range time.Tick(time.Second) {
  27.         // Histogram, using the exponential decay sampling method, the probability distribution of
  28.         // the statistical object is calculated. Using scenarios such as the probability distribution
  29.         // of the statistics home page to access the delay
  30.         delay := int64(rand.Int() % 100)
  31.         appm.Histogram("appm.histogram", delay)
  32.     }
  33. }
  34. func main() {
  35.     var ch chan int
  36.     go baseOrsystem()
  37.     go customOrbusiness()
  38.     <-ch
  39. }
复制代码
Credits

   Repository is base on goperfcounter ofniean
   Logo is desigend byxuri
我要投稿

推荐阅读


回页顶回复上一篇下一篇回列表
手机版/c.CoLaBug.com ( 粤ICP备05003221号 | 粤公网安备 44010402000842号 )

© 2001-2017 Comsenz Inc.

返回顶部 返回列表