forked from mosn/holmes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.go
54 lines (45 loc) · 1.17 KB
/
report.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package holmes
import "time"
type ProfileReporter interface {
Report(pType string, filename string, reason ReasonType, eventID string, sampleTime time.Time, pprofBytes []byte, scene Scene) error
}
// rptEvent stands of the args of report event
type rptEvent struct {
PType string
FileName string
Reason ReasonType
EventID string
SampleTime time.Time
PprofBytes []byte
Scene Scene
}
// Scene 包含profile触发时的场景信息,包括当前值、平均值和配置。
type Scene struct {
typeOption
CurVal int // dump时的值
Avg int // Avg是过去值的平均值
}
type ReasonType uint8
const (
ReasonCurlLessMin ReasonType = iota
ReasonCurlGreaterMin
ReasonCurGreaterMax
ReasonCurGreaterAbs
ReasonDiff
)
func (rt ReasonType) String() string {
var reason string
switch rt {
case ReasonCurlLessMin:
reason = "curVal < ruleMin"
case ReasonCurlGreaterMin:
reason = "curVal >= ruleMin, but don't meet diff trigger condition"
case ReasonCurGreaterMax:
reason = "curVal >= ruleMax"
case ReasonCurGreaterAbs:
reason = "curVal > ruleAbs"
case ReasonDiff:
reason = "curVal >= ruleMin, and meet diff trigger condition"
}
return reason
}