forked from k1LoW/runn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcapturer.go
157 lines (129 loc) · 3.56 KB
/
capturer.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package runn
import (
"net/http"
"google.golang.org/grpc/metadata"
)
type Capturer interface {
CaptureStart(ids []string, bookPath string)
CaptureEnd(ids []string, bookPath string)
CaptureHTTPRequest(name string, req *http.Request)
CaptureHTTPResponse(name string, res *http.Response)
CaptureGRPCStart(name string, typ GRPCType, service, method string)
CaptureGRPCRequestHeaders(h map[string][]string)
CaptureGRPCRequestMessage(m map[string]interface{})
CaptureGRPCResponseStatus(status int)
CaptureGRPCResponseHeaders(h map[string][]string)
CaptureGRPCResponseMessage(m map[string]interface{})
CaptureGRPCResponseTrailers(t map[string][]string)
CaptureGRPCClientClose()
CaptureGRPCEnd(name string, typ GRPCType, service, method string)
CaptureDBStatement(name string, stmt string)
CaptureDBResponse(name string, res *DBResponse)
CaptureExecCommand(command string)
CaptureExecStdin(stdin string)
CaptureExecStdout(stdin string)
CaptureExecStderr(stderr string)
SetCurrentIDs(ids []string)
Errs() error
}
type capturers []Capturer
func (cs capturers) captureStart(ids []string, bookPath string) {
for _, c := range cs {
c.CaptureStart(ids, bookPath)
}
}
func (cs capturers) captureEnd(ids []string, bookPath string) {
for _, c := range cs {
c.CaptureEnd(ids, bookPath)
}
}
func (cs capturers) captureHTTPRequest(name string, req *http.Request) {
for _, c := range cs {
c.CaptureHTTPRequest(name, req)
}
}
func (cs capturers) captureHTTPResponse(name string, res *http.Response) {
for _, c := range cs {
c.CaptureHTTPResponse(name, res)
}
}
func (cs capturers) captureGRPCStart(name string, typ GRPCType, service, method string) {
for _, c := range cs {
c.CaptureGRPCStart(name, typ, service, method)
}
}
func (cs capturers) captureGRPCRequestHeaders(h metadata.MD) {
for _, c := range cs {
c.CaptureGRPCRequestHeaders(h)
}
}
func (cs capturers) captureGRPCRequestMessage(m map[string]interface{}) {
for _, c := range cs {
c.CaptureGRPCRequestMessage(m)
}
}
func (cs capturers) captureGRPCResponseStatus(status int) {
for _, c := range cs {
c.CaptureGRPCResponseStatus(status)
}
}
func (cs capturers) captureGRPCResponseHeaders(h metadata.MD) {
for _, c := range cs {
c.CaptureGRPCResponseHeaders(h)
}
}
func (cs capturers) captureGRPCResponseMessage(m map[string]interface{}) {
for _, c := range cs {
c.CaptureGRPCResponseMessage(m)
}
}
func (cs capturers) captureGRPCResponseTrailers(t metadata.MD) {
for _, c := range cs {
c.CaptureGRPCResponseTrailers(t)
}
}
func (cs capturers) captureGRPCClientClose() {
for _, c := range cs {
c.CaptureGRPCClientClose()
}
}
func (cs capturers) captureGRPCEnd(name string, typ GRPCType, service, method string) {
for _, c := range cs {
c.CaptureGRPCEnd(name, typ, service, method)
}
}
func (cs capturers) captureDBStatement(name string, stmt string) {
for _, c := range cs {
c.CaptureDBStatement(name, stmt)
}
}
func (cs capturers) captureDBResponse(name string, res *DBResponse) {
for _, c := range cs {
c.CaptureDBResponse(name, res)
}
}
func (cs capturers) captureExecCommand(command string) {
for _, c := range cs {
c.CaptureExecCommand(command)
}
}
func (cs capturers) captureExecStdin(stdin string) {
for _, c := range cs {
c.CaptureExecStdin(stdin)
}
}
func (cs capturers) captureExecStdout(stdout string) {
for _, c := range cs {
c.CaptureExecStdout(stdout)
}
}
func (cs capturers) captureExecStderr(stderr string) {
for _, c := range cs {
c.CaptureExecStderr(stderr)
}
}
func (cs capturers) setCurrentIDs(ids []string) {
for _, c := range cs {
c.SetCurrentIDs(ids)
}
}