utils

package
v0.0.0-...-7429660 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package utils提供了stats上报功能

Background

目前公司内部很多监控都基于open-faclon使用,为了让业务更加方便简洁的使用这块功能, 基础库了一个stat的基础组件,用于程序内直接上报统计。

设计文档: http://wiki.inkept.cn/pages/viewpage.action?pageId=14815580

Index

Constants

View Source
const (
	SUCC_CODE int = 0
)

Variables

This section is empty.

Functions

func AddSBatchuccCode

func AddSBatchuccCode(codeMap map[int]int)

func AddSuccCode

func AddSuccCode(code int)

func EndStat

func EndStat(st *StatEntry, category string, code int)

EndStat 结束st的统计

func GetLocalIP

func GetLocalIP() ([]string, error)

GetLocalIP 获取本机IP

func ReportEvent

func ReportEvent(event, category string, start, end time.Time, code int)

ReportEvent 直接上报一条统计信息

func ReportEventGauge

func ReportEventGauge(name string, value int, tags ...interface{})

func ReportServiceEvent

func ReportServiceEvent(client, event, category string, start, end time.Time, code int)

ReportServiceEvent 直接上报一条统计信息

func SetStat

func SetStat(stFileName, stMetric string)

SetStat设置stat日志文件的路径和Metric

Types

type StatEntry

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

stats对象, 这个对象提供了一些方法用来上报数据

func NewServiceStatEntry

func NewServiceStatEntry(client string, event string) *StatEntry

在rpc-go内部使用的函数

func NewStatEntry

func NewStatEntry(event string) *StatEntry

NewStatEntry开始一个statEntry实例, 参数为需要监控的metric信息的首部.

func (*StatEntry) End

func (st *StatEntry) End(category string, code int)

End结束statEntry实例. category: 需要监控的metric的尾部,最后上报的metric结果:event.category code: 当前metric的 错误码,0代表成功,非0失败

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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