项目作者: wgliang

项目描述 :
Golang应用程序性能数据监控。
高级语言: Go
项目地址: git://github.com/wgliang/goappmonitor.git
创建时间: 2016-11-18T05:54:16Z
项目社区:https://github.com/wgliang/goappmonitor

开源协议:Apache License 2.0

下载


goappmonitor

goappmonitor

Build Status
codecov
GoDoc
Join the chat at https://gitter.im/goappmonitor/Lobby
Code Health
Go Report Card
License

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 register 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

Current version support:

  • v0.0.2

    • Open-Falcon (Open source monitoring system of Xiaomi)
    • InfluxDB (Scalable datastore for metrics, events, and real-time analytics)

todo….

  • support more agent frameworks,such as elasticsearch…
  • go processes manager and debug online…

Install

  1. go get github.com/wgliang/goappmonitor

Demo

demo

Usage

Below is an example which shows some common use cases for goappmonitor. Check
example for more
usage.

Detail API

  1. package main
  2. import (
  3. "math/rand"
  4. "time"
  5. appm "github.com/wgliang/goappmonitor"
  6. )
  7. // Base or system performance 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.Int31n(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.Int31n(100) - 50)
  19. appm.Gauge("appm.gauge", queueSize)
  20. cpuUtil := float64(rand.Int31n(10000)) / float64(100)
  21. appm.GaugeFloat64("appm.gauge.float64", cpuUtil)
  22. }
  23. }
  24. // Custom or business performance 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.Int31n(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 of niean

Logo is desigend by xuri