-
Notifications
You must be signed in to change notification settings - Fork 135
/
report.go
65 lines (55 loc) · 1.67 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
55
56
57
58
59
60
61
62
63
64
65
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 contains the scene information when profile triggers,
// including current value, average value and configurations.
type Scene struct {
typeOption
// current value while dump event occurs
CurVal int
// Avg is the average of the past values
Avg int
}
type ReasonType uint8
const (
// ReasonCurlLessMin means current value is less than min value.
ReasonCurlLessMin ReasonType = iota
// ReasonCurlGreaterMin means current value is greater than min value,
// but don't meet any trigger conditions.
ReasonCurlGreaterMin
// ReasonCurGreaterMax means current value is greater than max value.
ReasonCurGreaterMax
// ReasonCurGreaterAbs means current value meets the trigger condition where
// it is greater than abs value.
ReasonCurGreaterAbs
// ReasonDiff means current value is greater than the value: (diff + 1) * agv.
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
}