monitor

package module
v0.0.0-...-71797eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2015 License: MIT Imports: 4 Imported by: 0

README

Build Status GoDoc

gosvr-monitor

Customize Your Monitor Items, Inspect the time each of them spend

自定义监控条目,检测程序运行时的各个操作耗费时长

Complie

go get github.com/zheng-ji/gosvr-monitor

Example

import (
    "github.com/zheng-ji/gosvr-monitor"
)
func func_test() {
	timeStart := time.Now()
	defer func() {
		//defer 的时候统计监控, 用goroutine 使得不影响性能
		go monitor.StatByAction("WRITE", timeStart)
	}()
    ....
}

func main() {
	// 初始化monitor, 自定义监控的命令,如READ,WRITE等自定义名称, 以及每次统计的阀值
    // 启动监控服务
	monitor.InitMonitor([]string{"WRITE", "READ"}, 1)
	monitor.StartMonitorServer("0.0.0.0:7070")
    func_test()
    ...
}

How To Use

curl "http://127.0.0.1:7070/info"

OutPut

curl "http://127.0.0.1:7070/info"
WRITE (ms):15.000000
READ (ms):3.000000

License

Copyright (c) 2015 by zheng-ji released under a MIT style license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMonitor

func InitMonitor(stat_items []string, num_of_limit int)

func Since

func Since(t time.Time) int

func StartMonitorServer

func StartMonitorServer(addr string)

启动http服务监听

func StatByAction

func StatByAction(statType string, t time.Time)

各种类型时长统计,加锁统计

Types

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

统计机

type StatUnit

type StatUnit struct {
	// contains filtered or unexported fields
}

统计单元

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL