file

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 14 Imported by: 0

README

统计上报到智研监控以及日志系统

Documentation

Index

Constants

View Source
const (
	// ServerTagStrPattern 标签字符串模板
	ServerTagStrPattern = "inf=%s&err_code=%d&duration=%s&msg_type=%s&limit_service=%s"
	// ServerTagValuePatter 数据字符串模板
	ServerTagValuePatter = "latency.max.interface=%d&latency.avg.interface=%d&count.network_err=%d" +
		"&count.system_err=%d&count.user_err=%d&count.success=%d&count.total=%d"
)

Variables

This section is empty.

Functions

func PoolPutLogStatValue

func PoolPutLogStatValue(value *LogStatValue)

PoolPutLogStatValue 对象重新入池

Types

type EventLogReporter

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

EventLogReporter 事件日志上报器

func NewEventLogReporter

func NewEventLogReporter(cfg *ReportConfig) *EventLogReporter

NewEventLogReporter 创建对象

func (*EventLogReporter) AddEvent

func (e *EventLogReporter) AddEvent(event plugin.EventToLog)

AddEvent 写入事件

func (*EventLogReporter) LogAllEvents

func (e *EventLogReporter) LogAllEvents() int

LogAllEvents 获取所有的事件日志

type EventQueue

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

EventQueue 事件收集器

type LogStatHandler

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

LogStatHandler 统计日志打印处理器

func NewLogStatHandler

func NewLogStatHandler(cfg *ReportConfig) *LogStatHandler

NewLogStatHandler 创建曲线上报系统

func (*LogStatHandler) LogPrecisionRecord

func (l *LogStatHandler) LogPrecisionRecord(values map[interface{}]plugin.RateLimitStatValue) int

LogPrecisionRecord 打印精度上报记录

type LogStatKey

type LogStatKey struct {
	Namespace string `json:"namespace"`
	Service   string `json:"service"`
	Method    string `json:"method"`
	AppId     string `json:"app_id"`
	Uin       string `json:"uin"`
	Labels    string `json:"labels"`
	Duration  int64  `json:"duration"`
}

LogStatKey 日志上报的Key

func (LogStatKey) String

func (s LogStatKey) String() string

String ToString方法

type LogStatValue

type LogStatValue struct {
	LogStatKey
	Passed     int64  `json:"passed"`
	Total      int64  `json:"total"`
	Limited    int64  `json:"limited"`
	TimeNumber int64  `json:"time_number"`
	TimeStr    string `json:"time_str"`
}

LogStatValue 日志总体统计内容

func PoolGetLogStatValue

func PoolGetLogStatValue() *LogStatValue

PoolGetLogStatValue 从池中获取上报值对象

func (LogStatValue) String

func (i LogStatValue) String() string

String ToString方法

type RateLimitCurveReporter

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

RateLimitCurveReporter 限流曲线上报

func NewRateLimitCurveReporter

func NewRateLimitCurveReporter(config *ReportConfig) *RateLimitCurveReporter

NewRateLimitCurveReporter 创建曲线上报系统

func (*RateLimitCurveReporter) BuildReportRecord

func (s *RateLimitCurveReporter) BuildReportRecord() *ReportRecord

BuildReportRecord 构建上报记录

func (*RateLimitCurveReporter) CreateCollectorV1

func (s *RateLimitCurveReporter) CreateCollectorV1() *plugin.RateLimitStatCollectorV1

CreateCollectorV1 创建采集器V2

func (*RateLimitCurveReporter) CreateCollectorV2

func (s *RateLimitCurveReporter) CreateCollectorV2() *plugin.RateLimitStatCollectorV2

CreateCollectorV2 创建采集器V2

func (*RateLimitCurveReporter) DropCollector

func (s *RateLimitCurveReporter) DropCollector(collector plugin.RateLimitStatCollector)

DropCollector 创建采集器V2

func (*RateLimitCurveReporter) GetTagStr

GetTagStr 上报的Tag字符串

func (*RateLimitCurveReporter) GetValueStr

GetValueStr 上报的数据值

func (*RateLimitCurveReporter) MergeAllStatValues

func (s *RateLimitCurveReporter) MergeAllStatValues(isCurve bool) map[interface{}]plugin.RateLimitStatValue

MergeAllStatValues 汇总所有的统计数据

type ReportConfig

type ReportConfig struct {
	RateLimitAppName          string `json:"ratelimit-app-name"`
	RateLimitReportLogPath    string `json:"ratelimit_report_log_path"`
	RateLimitPrecisionLogPath string `json:"ratelimit_precision_log_path"`
	RateLimitEventLogPath     string `json:"ratelimit_event_log_path"`
	ServerAppName             string `json:"server-app-name"`
	ServerReportLogPath       string `json:"server_report_log_path"`
	PrecisionLogInterval      int    `json:"precision_log_interval"`
	LogInterval               int    `json:"log_interval"`
	LogSize                   int    `json:"log_size"`
	LogBackups                int    `json:"log_backups"`
	LogMaxAge                 int    `json:"log_max_age"`
}

ReportConfig 智研上报配置项

func (*ReportConfig) Validate

func (r *ReportConfig) Validate() error

Validate 校验

type ReportHandler

type ReportHandler interface {
	// Report 上报
	Report(*ReportRecord)
}

ReportHandler 上报处理器

func NewReportHandler

func NewReportHandler(cfg *ReportConfig) ReportHandler

NewReportHandler 新建上报处理器

type ReportItem

type ReportItem struct {
	TagStr   string
	ValueStr string
}

ReportItem 单条上报记录

type ReportRecord

type ReportRecord struct {
	AppName string
	Tags    []*ReportItem
}

ReportRecord 上报数据

func (*ReportRecord) HasTags

func (r *ReportRecord) HasTags() bool

HasTags 是否存在数据

type ServerCurveReporter

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

ServerCurveReporter 限流曲线上报

func NewServerCurveReporter

func NewServerCurveReporter(config *ReportConfig) *ServerCurveReporter

NewServerCurveReporter 创建曲线上报系统

func (*ServerCurveReporter) AddIncrement

func (s *ServerCurveReporter) AddIncrement(apiCallStatValue plugin.APICallStatValue)

AddIncrement 添加增量数据

func (*ServerCurveReporter) BuildReportRecord

func (s *ServerCurveReporter) BuildReportRecord() *ReportRecord

BuildReportRecord 构建上报记录

func (*ServerCurveReporter) GetTagStr

func (s *ServerCurveReporter) GetTagStr(value plugin.APICallStatValue) string

GetTagStr 上报的Tag字符串

func (*ServerCurveReporter) GetValueStr

func (s *ServerCurveReporter) GetValueStr(value plugin.APICallStatValue) string

GetValueStr 上报的数据值

type StaticsWorker

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

StaticsWorker 智研上报处理器

func (*StaticsWorker) AddAPICall

func (s *StaticsWorker) AddAPICall(value plugin.APICallStatValue)

AddAPICall 服务方法调用结果反馈,含有规则的计算周期

func (*StaticsWorker) AddEventToLog

func (s *StaticsWorker) AddEventToLog(value plugin.EventToLog)

AddEventToLog 添加事件

func (*StaticsWorker) CreateRateLimitStatCollectorV1

func (s *StaticsWorker) CreateRateLimitStatCollectorV1() *plugin.RateLimitStatCollectorV1

CreateRateLimitStatCollectorV1 创建采集器V1,每个stream上来后获取一次

func (*StaticsWorker) CreateRateLimitStatCollectorV2

func (s *StaticsWorker) CreateRateLimitStatCollectorV2() *plugin.RateLimitStatCollectorV2

CreateRateLimitStatCollectorV2 创建采集器V2,每个stream上来后获取一次

func (*StaticsWorker) Destroy

func (s *StaticsWorker) Destroy() error

Destroy 销毁统计插件

func (*StaticsWorker) DropRateLimitStatCollector

func (s *StaticsWorker) DropRateLimitStatCollector(value plugin.RateLimitStatCollector)

DropRateLimitStatCollector 归还采集器

func (*StaticsWorker) Initialize

func (s *StaticsWorker) Initialize(conf *plugin.ConfigEntry) error

Initialize 初始化统计插件

func (*StaticsWorker) Name

func (s *StaticsWorker) Name() string

Name 获取统计插件名称

func (*StaticsWorker) Start

func (s *StaticsWorker) Start(ctx context.Context)

Start 启动调度

Jump to

Keyboard shortcuts

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