github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/trace/driver.go (about) 1 package trace 2 3 // tool gtrace used from ./internal/cmd/gtrace 4 5 //go:generate gtrace 6 7 import ( 8 "context" 9 "fmt" 10 "strings" 11 "time" 12 ) 13 14 type ( 15 // Driver specified trace of common driver activity. 16 // gtrace:gen 17 Driver struct { 18 // Driver runtime events 19 OnInit func(DriverInitStartInfo) func(DriverInitDoneInfo) 20 OnWith func(DriverWithStartInfo) func(DriverWithDoneInfo) 21 OnClose func(DriverCloseStartInfo) func(DriverCloseDoneInfo) 22 23 // Pool of connections 24 OnPoolNew func(DriverConnPoolNewStartInfo) func(DriverConnPoolNewDoneInfo) 25 OnPoolRelease func(DriverConnPoolReleaseStartInfo) func(DriverConnPoolReleaseDoneInfo) 26 27 // Deprecated: driver not notificate about this event 28 OnNetRead func(DriverNetReadStartInfo) func(DriverNetReadDoneInfo) 29 // Deprecated: driver not notificate about this event 30 OnNetWrite func(DriverNetWriteStartInfo) func(DriverNetWriteDoneInfo) 31 // Deprecated: driver not notificate about this event 32 OnNetDial func(DriverNetDialStartInfo) func(DriverNetDialDoneInfo) 33 // Deprecated: driver not notificate about this event 34 OnNetClose func(DriverNetCloseStartInfo) func(DriverNetCloseDoneInfo) 35 36 // Resolver events 37 OnResolve func(DriverResolveStartInfo) func(DriverResolveDoneInfo) 38 39 // Conn events 40 OnConnStateChange func(DriverConnStateChangeStartInfo) func(DriverConnStateChangeDoneInfo) 41 OnConnInvoke func(DriverConnInvokeStartInfo) func(DriverConnInvokeDoneInfo) 42 OnConnNewStream func( 43 DriverConnNewStreamStartInfo, 44 ) func( 45 DriverConnNewStreamRecvInfo, 46 ) func( 47 DriverConnNewStreamDoneInfo, 48 ) 49 // Deprecated: driver not notificate about this event 50 OnConnTake func(DriverConnTakeStartInfo) func(DriverConnTakeDoneInfo) 51 OnConnDial func(DriverConnDialStartInfo) func(DriverConnDialDoneInfo) 52 OnConnPark func(DriverConnParkStartInfo) func(DriverConnParkDoneInfo) 53 OnConnBan func(DriverConnBanStartInfo) func(DriverConnBanDoneInfo) 54 OnConnAllow func(DriverConnAllowStartInfo) func(DriverConnAllowDoneInfo) 55 OnConnClose func(DriverConnCloseStartInfo) func(DriverConnCloseDoneInfo) 56 57 // Repeater events 58 OnRepeaterWakeUp func(DriverRepeaterWakeUpStartInfo) func(DriverRepeaterWakeUpDoneInfo) 59 60 // Balancer events 61 OnBalancerInit func(DriverBalancerInitStartInfo) func(DriverBalancerInitDoneInfo) 62 63 // Deprecated: driver not notificate about this event 64 OnBalancerDialEntrypoint func( 65 DriverBalancerDialEntrypointStartInfo, 66 ) func( 67 DriverBalancerDialEntrypointDoneInfo, 68 ) 69 OnBalancerClose func(DriverBalancerCloseStartInfo) func(DriverBalancerCloseDoneInfo) 70 OnBalancerChooseEndpoint func( 71 DriverBalancerChooseEndpointStartInfo, 72 ) func( 73 DriverBalancerChooseEndpointDoneInfo, 74 ) 75 OnBalancerClusterDiscoveryAttempt func( 76 DriverBalancerClusterDiscoveryAttemptStartInfo, 77 ) func( 78 DriverBalancerClusterDiscoveryAttemptDoneInfo, 79 ) 80 OnBalancerUpdate func(DriverBalancerUpdateStartInfo) func(DriverBalancerUpdateDoneInfo) 81 82 // Credentials events 83 OnGetCredentials func(DriverGetCredentialsStartInfo) func(DriverGetCredentialsDoneInfo) 84 } 85 ) 86 87 // Method represents rpc method. 88 type Method string 89 90 // Name returns the rpc method name. 91 func (m Method) Name() (s string) { 92 _, s = m.Split() 93 94 return 95 } 96 97 // Service returns the rpc service name. 98 func (m Method) Service() (s string) { 99 s, _ = m.Split() 100 101 return 102 } 103 104 // Issue declare interface of operation error issues 105 type Issue interface { 106 GetMessage() string 107 GetIssueCode() uint32 108 GetSeverity() uint32 109 } 110 111 // Split returns service name and method. 112 func (m Method) Split() (service, method string) { 113 i := strings.LastIndex(string(m), "/") 114 if i == -1 { 115 return string(m), string(m) 116 } 117 118 return strings.TrimPrefix(string(m[:i]), "/"), string(m[i+1:]) 119 } 120 121 type ConnState interface { 122 fmt.Stringer 123 124 IsValid() bool 125 Code() int 126 } 127 128 type EndpointInfo interface { 129 fmt.Stringer 130 131 NodeID() uint32 132 Address() string 133 LocalDC() bool 134 Location() string 135 LoadFactor() float32 136 LastUpdated() time.Time 137 } 138 139 type ( 140 DriverConnStateChangeStartInfo struct { 141 // Context make available context in trace callback function. 142 // Pointer to context provide replacement of context in trace callback function. 143 // Warning: concurrent access to pointer on client side must be excluded. 144 // Safe replacement of context are provided only inside callback function 145 Context *context.Context 146 Call call 147 Endpoint EndpointInfo 148 State ConnState 149 } 150 DriverConnStateChangeDoneInfo struct { 151 State ConnState 152 } 153 DriverResolveStartInfo struct { 154 Call call 155 Target string 156 Resolved []string 157 } 158 DriverResolveDoneInfo struct { 159 Error error 160 } 161 DriverBalancerUpdateStartInfo struct { 162 // Context make available context in trace callback function. 163 // Pointer to context provide replacement of context in trace callback function. 164 // Warning: concurrent access to pointer on client side must be excluded. 165 // Safe replacement of context are provided only inside callback function 166 Context *context.Context 167 Call call 168 NeedLocalDC bool 169 } 170 DriverBalancerUpdateDoneInfo struct { 171 Endpoints []EndpointInfo 172 Added []EndpointInfo 173 Dropped []EndpointInfo 174 LocalDC string 175 // Deprecated: this field always nil 176 Error error 177 } 178 DriverBalancerClusterDiscoveryAttemptStartInfo struct { 179 // Context make available context in trace callback function. 180 // Pointer to context provide replacement of context in trace callback function. 181 // Warning: concurrent access to pointer on client side must be excluded. 182 // Safe replacement of context are provided only inside callback function 183 Context *context.Context 184 Call call 185 Address string 186 } 187 DriverBalancerClusterDiscoveryAttemptDoneInfo struct { 188 Error error 189 } 190 DriverNetReadStartInfo struct { 191 Call call 192 Address string 193 Buffer int 194 } 195 DriverNetReadDoneInfo struct { 196 Received int 197 Error error 198 } 199 DriverNetWriteStartInfo struct { 200 Call call 201 Address string 202 Bytes int 203 } 204 DriverNetWriteDoneInfo struct { 205 Sent int 206 Error error 207 } 208 DriverNetDialStartInfo struct { 209 // Context make available context in trace callback function. 210 // Pointer to context provide replacement of context in trace callback function. 211 // Warning: concurrent access to pointer on client side must be excluded. 212 // Safe replacement of context are provided only inside callback function 213 Context *context.Context 214 Call call 215 Address string 216 } 217 DriverNetDialDoneInfo struct { 218 Error error 219 } 220 DriverNetCloseStartInfo struct { 221 Call call 222 Address string 223 } 224 DriverNetCloseDoneInfo struct { 225 Error error 226 } 227 DriverConnTakeStartInfo struct { 228 // Context make available context in trace callback function. 229 // Pointer to context provide replacement of context in trace callback function. 230 // Warning: concurrent access to pointer on client side must be excluded. 231 // Safe replacement of context are provided only inside callback function 232 Context *context.Context 233 Call call 234 Endpoint EndpointInfo 235 } 236 DriverConnTakeDoneInfo struct { 237 Error error 238 } 239 DriverConnDialStartInfo struct { 240 // Context make available context in trace callback function. 241 // Pointer to context provide replacement of context in trace callback function. 242 // Warning: concurrent access to pointer on client side must be excluded. 243 // Safe replacement of context are provided only inside callback function 244 Context *context.Context 245 Call call 246 Endpoint EndpointInfo 247 } 248 DriverConnDialDoneInfo struct { 249 Error error 250 } 251 DriverConnParkStartInfo struct { 252 // Context make available context in trace callback function. 253 // Pointer to context provide replacement of context in trace callback function. 254 // Warning: concurrent access to pointer on client side must be excluded. 255 // Safe replacement of context are provided only inside callback function 256 Context *context.Context 257 Call call 258 Endpoint EndpointInfo 259 } 260 DriverConnParkDoneInfo struct { 261 Error error 262 } 263 DriverConnCloseStartInfo struct { 264 // Context make available context in trace callback function. 265 // Pointer to context provide replacement of context in trace callback function. 266 // Warning: concurrent access to pointer on client side must be excluded. 267 // Safe replacement of context are provided only inside callback function 268 Context *context.Context 269 Call call 270 Endpoint EndpointInfo 271 } 272 DriverConnCloseDoneInfo struct { 273 Error error 274 } 275 DriverConnBanStartInfo struct { 276 // Context make available context in trace callback function. 277 // Pointer to context provide replacement of context in trace callback function. 278 // Warning: concurrent access to pointer on client side must be excluded. 279 // Safe replacement of context are provided only inside callback function 280 Context *context.Context 281 Call call 282 Endpoint EndpointInfo 283 State ConnState 284 Cause error 285 } 286 DriverConnBanDoneInfo struct { 287 State ConnState 288 } 289 DriverConnAllowStartInfo struct { 290 // Context make available context in trace callback function. 291 // Pointer to context provide replacement of context in trace callback function. 292 // Warning: concurrent access to pointer on client side must be excluded. 293 // Safe replacement of context are provided only inside callback function 294 Context *context.Context 295 Call call 296 Endpoint EndpointInfo 297 State ConnState 298 } 299 DriverConnAllowDoneInfo struct { 300 State ConnState 301 } 302 DriverConnInvokeStartInfo struct { 303 // Context make available context in trace callback function. 304 // Pointer to context provide replacement of context in trace callback function. 305 // Warning: concurrent access to pointer on client side must be excluded. 306 // Safe replacement of context are provided only inside callback function 307 Context *context.Context 308 Call call 309 Endpoint EndpointInfo 310 Method Method 311 } 312 DriverConnInvokeDoneInfo struct { 313 Error error 314 Issues []Issue 315 OpID string 316 State ConnState 317 Metadata map[string][]string 318 } 319 DriverConnNewStreamStartInfo struct { 320 // Context make available context in trace callback function. 321 // Pointer to context provide replacement of context in trace callback function. 322 // Warning: concurrent access to pointer on client side must be excluded. 323 // Safe replacement of context are provided only inside callback function 324 Context *context.Context 325 Call call 326 Endpoint EndpointInfo 327 Method Method 328 } 329 DriverConnNewStreamRecvInfo struct { 330 Error error 331 } 332 DriverConnNewStreamDoneInfo struct { 333 Error error 334 State ConnState 335 Metadata map[string][]string 336 } 337 DriverBalancerInitStartInfo struct { 338 // Context make available context in trace callback function. 339 // Pointer to context provide replacement of context in trace callback function. 340 // Warning: concurrent access to pointer on client side must be excluded. 341 // Safe replacement of context are provided only inside callback function 342 Context *context.Context 343 Call call 344 Name string 345 } 346 DriverBalancerInitDoneInfo struct { 347 Error error 348 } 349 DriverBalancerDialEntrypointStartInfo struct { 350 // Context make available context in trace callback function. 351 // Pointer to context provide replacement of context in trace callback function. 352 // Warning: concurrent access to pointer on client side must be excluded. 353 // Safe replacement of context are provided only inside callback function 354 Context *context.Context 355 Call call 356 Address string 357 } 358 DriverBalancerDialEntrypointDoneInfo struct { 359 Error error 360 } 361 DriverBalancerCloseStartInfo struct { 362 // Context make available context in trace callback function. 363 // Pointer to context provide replacement of context in trace callback function. 364 // Warning: concurrent access to pointer on client side must be excluded. 365 // Safe replacement of context are provided only inside callback function 366 Context *context.Context 367 Call call 368 } 369 DriverBalancerCloseDoneInfo struct { 370 Error error 371 } 372 DriverBalancerChooseEndpointStartInfo struct { 373 // Context make available context in trace callback function. 374 // Pointer to context provide replacement of context in trace callback function. 375 // Warning: concurrent access to pointer on client side must be excluded. 376 // Safe replacement of context are provided only inside callback function 377 Context *context.Context 378 Call call 379 } 380 DriverBalancerChooseEndpointDoneInfo struct { 381 Endpoint EndpointInfo 382 Error error 383 } 384 DriverRepeaterWakeUpStartInfo struct { 385 // Context make available context in trace callback function. 386 // Pointer to context provide replacement of context in trace callback function. 387 // Warning: concurrent access to pointer on client side must be excluded. 388 // Safe replacement of context are provided only inside callback function 389 Context *context.Context 390 Call call 391 Name string 392 Event string 393 } 394 DriverRepeaterWakeUpDoneInfo struct { 395 Error error 396 } 397 DriverGetCredentialsStartInfo struct { 398 // Context make available context in trace callback function. 399 // Pointer to context provide replacement of context in trace callback function. 400 // Warning: concurrent access to pointer on client side must be excluded. 401 // Safe replacement of context are provided only inside callback function 402 Context *context.Context 403 Call call 404 } 405 DriverGetCredentialsDoneInfo struct { 406 Token string 407 Error error 408 } 409 DriverInitStartInfo struct { 410 // Context make available context in trace callback function. 411 // Pointer to context provide replacement of context in trace callback function. 412 // Warning: concurrent access to pointer on client side must be excluded. 413 // Safe replacement of context are provided only inside callback function 414 Context *context.Context 415 Call call 416 Endpoint string 417 Database string 418 Secure bool 419 } 420 DriverInitDoneInfo struct { 421 Error error 422 } 423 DriverWithStartInfo struct { 424 // Context make available context in trace callback function. 425 // Pointer to context provide replacement of context in trace callback function. 426 // Warning: concurrent access to pointer on client side must be excluded. 427 // Safe replacement of context are provided only inside callback function 428 Context *context.Context 429 Call call 430 Endpoint string 431 Database string 432 Secure bool 433 } 434 DriverWithDoneInfo struct { 435 Error error 436 } 437 DriverConnPoolNewStartInfo struct { 438 // Context make available context in trace callback function. 439 // Pointer to context provide replacement of context in trace callback function. 440 // Warning: concurrent access to pointer on client side must be excluded. 441 // Safe replacement of context are provided only inside callback function 442 Context *context.Context 443 Call call 444 } 445 DriverConnPoolNewDoneInfo struct{} 446 DriverConnPoolReleaseStartInfo struct { 447 // Context make available context in trace callback function. 448 // Pointer to context provide replacement of context in trace callback function. 449 // Warning: concurrent access to pointer on client side must be excluded. 450 // Safe replacement of context are provided only inside callback function 451 Context *context.Context 452 Call call 453 } 454 DriverConnPoolReleaseDoneInfo struct { 455 Error error 456 } 457 DriverCloseStartInfo struct { 458 // Context make available context in trace callback function. 459 // Pointer to context provide replacement of context in trace callback function. 460 // Warning: concurrent access to pointer on client side must be excluded. 461 // Safe replacement of context are provided only inside callback function 462 Context *context.Context 463 Call call 464 } 465 DriverCloseDoneInfo struct { 466 Error error 467 } 468 )