-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtrace.go
158 lines (142 loc) · 3.04 KB
/
trace.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
158
package ydb
//go:generate gtrace
import (
"context"
"strings"
)
type (
//gtrace:gen
//gtrace:set shortcut
//gtrace:set context
DriverTrace struct {
OnDial func(DialStartInfo) func(DialDoneInfo)
OnGetConn func(GetConnStartInfo) func(GetConnDoneInfo)
OnPessimization func(PessimizationStartInfo) func(PessimizationDoneInfo)
// Only for background.
TrackConnStart func(TrackConnStartInfo)
TrackConnDone func(TrackConnDoneInfo)
OnGetCredentials func(GetCredentialsStartInfo) func(GetCredentialsDoneInfo)
OnDiscovery func(DiscoveryStartInfo) func(DiscoveryDoneInfo)
OnOperation func(OperationStartInfo) func(OperationDoneInfo)
OnOperationWait func(OperationWaitInfo)
OnStream func(StreamStartInfo) func(StreamDoneInfo)
OnStreamRecv func(StreamRecvStartInfo) func(StreamRecvDoneInfo)
}
)
// Method represents rpc method.
type Method string
// Name returns the rpc method name.
func (m Method) Name() (s string) {
_, s = m.Split()
return
}
// Service returns the rpc service name.
func (m Method) Service() (s string) {
s, _ = m.Split()
return
}
// Split returns service name and method.
func (m Method) Split() (service, method string) {
i := strings.LastIndex(string(m), "/")
if i == -1 {
return string(m), string(m)
}
return strings.TrimPrefix(string(m[:i]), "/"), string(m[i+1:])
}
type (
DialStartInfo struct {
Context context.Context
Address string
}
DialDoneInfo struct {
Context context.Context
Address string
Error error
}
GetConnStartInfo struct {
Context context.Context
}
GetConnDoneInfo struct {
Context context.Context
Address string
Error error
}
PessimizationStartInfo struct {
Context context.Context
Address string
Cause error
}
PessimizationDoneInfo struct {
Context context.Context
Address string
Error error
}
TrackConnStartInfo struct {
Address string
}
TrackConnDoneInfo struct {
Address string
}
GetCredentialsStartInfo struct {
Context context.Context
}
GetCredentialsDoneInfo struct {
Context context.Context
Token bool
Error error
}
DiscoveryStartInfo struct {
Context context.Context
Address string
}
DiscoveryDoneInfo struct {
Context context.Context
Endpoints []Endpoint
Error error
}
OperationStartInfo struct {
Context context.Context
Address string
Method Method
Params OperationParams
}
OperationWaitInfo struct {
Context context.Context
Address string
Method Method
Params OperationParams
OpID string
}
OperationDoneInfo struct {
Context context.Context
Address string
Method Method
Params OperationParams
OpID string
Issues IssueIterator
Error error
}
StreamStartInfo struct {
Context context.Context
Address string
Method Method
}
StreamRecvStartInfo struct {
Context context.Context
Address string
Method Method
}
StreamRecvDoneInfo struct {
Context context.Context
Address string
Method Method
Issues IssueIterator
Error error
}
StreamDoneInfo struct {
Context context.Context
Address string
Method Method
Error error
}
)