stats

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package stats used to record pl metrics

Index

Constants

View Source
const (
	StatsTimeFormat = "2006-01-02T15:04:05.999Z07:00"

	MaxEventLen   int = 100
	MaxErrorCount int = 100

	EventOpAdd                EventOP = "ADD"
	EventOpUpdate             EventOP = "UPDATE"
	EventOpDelete             EventOP = "DELETE"
	EventOpIndex              EventOP = "INDEX"
	EventOpIndexUpdate        EventOP = "INDEX_UPDATE"
	EventOpIndexDelete        EventOP = "INDEX_DELETE"
	EventOpIndexDeleteAndBack EventOP = "INDEX_DELETE_AND_BACK"
	EventOpCompileError       EventOP = "COMPILE_ERROR"
)

Variables

This section is empty.

Functions

func InitLog

func InitLog()

func Metrics

func Metrics() []prometheus.Collector

func StatsKey

func StatsKey(category point.Category, ns, name string) string

func UpdateScriptStatsMeta

func UpdateScriptStatsMeta(category point.Category, ns, name, script string, enable, deleted bool, err string)

func WriteEvent

func WriteEvent(event *ChangeEvent)

func WriteScriptStats

func WriteScriptStats(category point.Category, ns, name string, pt, ptDrop, ptError uint64, cost int64, err error)

Types

type ChangeEvent

type ChangeEvent struct {
	Name              string
	Category          point.Category
	NS, NSOld         string
	Script, ScriptOld string

	Op EventOP //

	CompileError string
	Time         time.Time
}

func ReadEvent

func ReadEvent() []ChangeEvent

func (ChangeEvent) String

func (event ChangeEvent) String() string

type EventOP

type EventOP string

type ScriptChangeEvent

type ScriptChangeEvent struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*ScriptChangeEvent) Read

func (event *ScriptChangeEvent) Read() []ChangeEvent

func (*ScriptChangeEvent) Write

func (event *ScriptChangeEvent) Write(change *ChangeEvent)

type ScriptMeta

type ScriptMeta struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type ScriptStats

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

func (*ScriptStats) Read

func (stats *ScriptStats) Read() *ScriptStatsROnly

func (*ScriptStats) UpdateMeta

func (stats *ScriptStats) UpdateMeta(script string, enable, deleted bool, err ...string)

func (*ScriptStats) WriteErr

func (stats *ScriptStats) WriteErr(err string)

func (*ScriptStats) WritePtCount

func (stats *ScriptStats) WritePtCount(pt, ptDrop, ptError uint64, cost int64)

type ScriptStatsROnly

type ScriptStatsROnly struct {
	Pt, PtDrop, PtError uint64

	TotalCost int64 // ns
	MetaTS    time.Time

	Script            string
	FirstTS           time.Time
	ScriptTS          time.Time
	ScriptUpdateTimes uint64

	Category point.Category
	NS, Name string

	Enable       bool
	Deleted      bool
	CompileError string
}

func (ScriptStatsROnly) String

func (statsR ScriptStatsROnly) String() string

type Stats

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

func (*Stats) ReadEvent

func (stats *Stats) ReadEvent() []ChangeEvent

func (*Stats) ReadStats

func (stats *Stats) ReadStats() []ScriptStatsROnly

func (*Stats) UpdateScriptStatsMeta

func (stats *Stats) UpdateScriptStatsMeta(category point.Category, ns, name, script string, enable, deleted bool, err string)

func (*Stats) WriteEvent

func (stats *Stats) WriteEvent(event *ChangeEvent)

func (*Stats) WriteScriptStats

func (stats *Stats) WriteScriptStats(category point.Category, ns, name string, pt, ptDrop, ptError uint64, cost int64, err error)

Jump to

Keyboard shortcuts

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