Documentation ¶
Index ¶
Constants ¶
const ( ServerStatusInTrans uint16 = 0x0001 ServerStatusAutocommit uint16 = 0x0002 ServerStatusResultsExists uint16 = 0x0008 ServerStatusNoGoodIndexUsed uint16 = 0x0010 ServerStatusNoIndexUsed uint16 = 0x0020 ServerStatusCursorExists uint16 = 0x0040 ServerStatusLastRowSnet uint16 = 0x0080 ServerStatusDbDropped uint16 = 0x0100 ServerStatusNoBackslashEscapes uint16 = 0x0200 ServerStatusMetadataChanged uint16 = 0x0400 ServerQueryWasSlow uint16 = 0x0800 ServerPsOutParams uint16 = 0x1000 ServerStatusInTransReadonly uint16 = 0x2000 ServerSessionStateChanged uint16 = 0x4000 )
reponse status
Variables ¶
var GlobalSQLHashCache = newSQLHashCache()
GlobalSQLHashCache is cache the SQL=>Hash(SQL) pairs
Functions ¶
func EncodeReportToBytes ¶
EncodeReportToBytes marshal a Report to bytes
Types ¶
type AssemblySummary ¶
type AssemblySummary struct { DB string `json:"a"` // DB name IP string `json:"b"` // server ip LastSeen int64 `json:"c"` // timestamp Group *SummaryGroup `json:"d"` // summary group by query Client *ClientSummaryGroup `json:"e"` // summary group by client UnknownExec int64 `json:"f"` // counter of execute commands without sql }
AssemblySummary group Summary by db and server ip
func (*AssemblySummary) AddMessage ¶
func (s *AssemblySummary) AddMessage(m *Message, slow bool) bool
AddMessage asseble a Message to this summary
type ClientSummaryGroup ¶
type ClientSummaryGroup struct {
ClientGroup map[string]*SummaryGroup
}
ClientSummaryGroup is a wrapper of map[string]*SummaryGroup
func (*ClientSummaryGroup) AddMessage ¶
func (g *ClientSummaryGroup) AddMessage(m *Message, slow bool) bool
AddMessage asseble a Message to this summary
func (*ClientSummaryGroup) MarshalJSON ¶
func (g *ClientSummaryGroup) MarshalJSON() ([]byte, error)
MarshalJSON interface
func (*ClientSummaryGroup) UnmarshalJSON ¶
func (g *ClientSummaryGroup) UnmarshalJSON(b []byte) error
UnmarshalJSON interface
type ClientSummaryUnit ¶
type ClientSummaryUnit struct { IP string `json:"a"` Group *SummaryGroup `json:"b"` }
ClientSummaryUnit flattens the ClientSummaryGroup
type Message ¶
type Message struct { DB string `json:"-"` // db name SQL string `json:"-"` // templated sql Raw string `json:"c,omitempty"` // raw sql Err bool `json:"d"` // sql process error ErrMsg string `json:"e,omitempty"` // sql process error message Errno uint16 `json:"f,omitempty"` // sql process error number ServerStatus uint16 `json:"g"` // server response status code AffectRows uint64 `json:"h"` // affect rows TimestampReq int64 `json:"i"` // timestamp for request package TimestampRsp int64 `json:"j"` // timestamp for response package Latency float32 `json:"k"` // latency in millisecond Vars map[string]string `json:"l,omitempty"` // Vars retrieved form Raw ServerIP string `json:"-"` // server ip ServerPort uint16 `json:"-"` // server port ClientIP string `json:"n"` // client ip ClientPort uint16 `json:"-"` // client port AssemblyKey string `json:"-"` // hash key for assembly UnknownExec bool `json:"-"` // execute command without crossponding sql }
Message is the info of a sql query
func (*Message) AssemblyHashKey ¶
AssemblyHashKey hash(db+ip+sql) for map, same as AssembleHashKey()
func (*Message) SummaryHashKey ¶
SummaryHashKey is the hash key of the corresponding AssemblySummary
type Report ¶
type Report struct {
DB map[string]*AssemblySummary
}
Report group captured info by DB
func DecodeReportFromBytes ¶
DecodeReportFromBytes unmarshal bytes to a Report
func (*Report) AddMessage ¶
AddMessage asseble a Message to this Report
func (*Report) UnmarshalJSON ¶
UnmarshalJSON interface
type SQLHashCache ¶
SQLHashCache cache the SQL=>MD5(SQL) pairs
type Summary ¶
type Summary struct { Key string `json:"a"` // hash key of SQL SQL string `json:"b,omitempty"` // SQL template SuccessCount int `json:"c"` // success query number FailedCount int `json:"d"` // failed query number LastSeen int64 `json:"e"` // the latest timestamp SuccCostTotal float32 `json:"f"` // total cost of success query in millisecond FailedCostTotal float32 `json:"g"` // total cost of failed query in millisecond NoGoodIndexUsed int64 `json:"h"` // count of SERVER_STATUS_NO_GOOD_INDEX_USED NoIndexUsed int64 `json:"i"` // count of SERVER_STATUS_NO_INDEX_USED QueryWasSlow int64 `json:"j"` // count of SERVER_QUERY_WAS_SLOW QPS *int `json:"k,omitempty"` // qps AverageLatency *float32 `json:"l,omitempty"` // average latency in millisecond MinLatency *float32 `json:"m,omitempty"` // min latency in millisecond MaxLatency *float32 `json:"n,omitempty"` // max latency in millisecond Latency99 *float32 `json:"o,omitempty"` // latency of 99 quantile in milliseconds Slow []*Message `json:"p,omitempty"` // slow queries AssemblyKey string `json:"-"` // hash key for assembly Sample *Message `json:"r,omitempty"` // one normal query sample }
Summary is a collection of counters and recoreds
type SummaryGroup ¶
SummaryGroup groups summary by sql
func (*SummaryGroup) AddMessage ¶
func (s *SummaryGroup) AddMessage(m *Message, slow bool, client bool) bool
AddMessage asseble a Message to this summary
func (*SummaryGroup) MarshalJSON ¶
func (s *SummaryGroup) MarshalJSON() ([]byte, error)
MarshalJSON interface
func (*SummaryGroup) UnmarshalJSON ¶
func (s *SummaryGroup) UnmarshalJSON(b []byte) error
UnmarshalJSON interface