1// Autogenerated by Thrift Compiler (0.9.3) 2// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 3 4package zipkincore 5 6import ( 7 "bytes" 8 "fmt" 9 "github.com/uber/jaeger-client-go/thrift" 10) 11 12// (needed to ensure safety because of naive import list construction.) 13var _ = thrift.ZERO 14var _ = fmt.Printf 15var _ = bytes.Equal 16 17var GoUnusedProtection__ int 18 19type AnnotationType int64 20 21const ( 22 AnnotationType_BOOL AnnotationType = 0 23 AnnotationType_BYTES AnnotationType = 1 24 AnnotationType_I16 AnnotationType = 2 25 AnnotationType_I32 AnnotationType = 3 26 AnnotationType_I64 AnnotationType = 4 27 AnnotationType_DOUBLE AnnotationType = 5 28 AnnotationType_STRING AnnotationType = 6 29) 30 31func (p AnnotationType) String() string { 32 switch p { 33 case AnnotationType_BOOL: 34 return "BOOL" 35 case AnnotationType_BYTES: 36 return "BYTES" 37 case AnnotationType_I16: 38 return "I16" 39 case AnnotationType_I32: 40 return "I32" 41 case AnnotationType_I64: 42 return "I64" 43 case AnnotationType_DOUBLE: 44 return "DOUBLE" 45 case AnnotationType_STRING: 46 return "STRING" 47 } 48 return "<UNSET>" 49} 50 51func AnnotationTypeFromString(s string) (AnnotationType, error) { 52 switch s { 53 case "BOOL": 54 return AnnotationType_BOOL, nil 55 case "BYTES": 56 return AnnotationType_BYTES, nil 57 case "I16": 58 return AnnotationType_I16, nil 59 case "I32": 60 return AnnotationType_I32, nil 61 case "I64": 62 return AnnotationType_I64, nil 63 case "DOUBLE": 64 return AnnotationType_DOUBLE, nil 65 case "STRING": 66 return AnnotationType_STRING, nil 67 } 68 return AnnotationType(0), fmt.Errorf("not a valid AnnotationType string") 69} 70 71func AnnotationTypePtr(v AnnotationType) *AnnotationType { return &v } 72 73func (p AnnotationType) MarshalText() ([]byte, error) { 74 return []byte(p.String()), nil 75} 76 77func (p *AnnotationType) UnmarshalText(text []byte) error { 78 q, err := AnnotationTypeFromString(string(text)) 79 if err != nil { 80 return err 81 } 82 *p = q 83 return nil 84} 85 86// Indicates the network context of a service recording an annotation with two 87// exceptions. 88// 89// When a BinaryAnnotation, and key is CLIENT_ADDR or SERVER_ADDR, 90// the endpoint indicates the source or destination of an RPC. This exception 91// allows zipkin to display network context of uninstrumented services, or 92// clients such as web browsers. 93// 94// Attributes: 95// - Ipv4: IPv4 host address packed into 4 bytes. 96// 97// Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 98// - Port: IPv4 port 99// 100// Note: this is to be treated as an unsigned integer, so watch for negatives. 101// 102// Conventionally, when the port isn't known, port = 0. 103// - ServiceName: Service name in lowercase, such as "memcache" or "zipkin-web" 104// 105// Conventionally, when the service name isn't known, service_name = "unknown". 106// - Ipv6: IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes() 107type Endpoint struct { 108 Ipv4 int32 `thrift:"ipv4,1" json:"ipv4"` 109 Port int16 `thrift:"port,2" json:"port"` 110 ServiceName string `thrift:"service_name,3" json:"service_name"` 111 Ipv6 []byte `thrift:"ipv6,4" json:"ipv6,omitempty"` 112} 113 114func NewEndpoint() *Endpoint { 115 return &Endpoint{} 116} 117 118func (p *Endpoint) GetIpv4() int32 { 119 return p.Ipv4 120} 121 122func (p *Endpoint) GetPort() int16 { 123 return p.Port 124} 125 126func (p *Endpoint) GetServiceName() string { 127 return p.ServiceName 128} 129 130var Endpoint_Ipv6_DEFAULT []byte 131 132func (p *Endpoint) GetIpv6() []byte { 133 return p.Ipv6 134} 135func (p *Endpoint) IsSetIpv6() bool { 136 return p.Ipv6 != nil 137} 138 139func (p *Endpoint) Read(iprot thrift.TProtocol) error { 140 if _, err := iprot.ReadStructBegin(); err != nil { 141 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 142 } 143 144 for { 145 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 146 if err != nil { 147 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 148 } 149 if fieldTypeId == thrift.STOP { 150 break 151 } 152 switch fieldId { 153 case 1: 154 if err := p.readField1(iprot); err != nil { 155 return err 156 } 157 case 2: 158 if err := p.readField2(iprot); err != nil { 159 return err 160 } 161 case 3: 162 if err := p.readField3(iprot); err != nil { 163 return err 164 } 165 case 4: 166 if err := p.readField4(iprot); err != nil { 167 return err 168 } 169 default: 170 if err := iprot.Skip(fieldTypeId); err != nil { 171 return err 172 } 173 } 174 if err := iprot.ReadFieldEnd(); err != nil { 175 return err 176 } 177 } 178 if err := iprot.ReadStructEnd(); err != nil { 179 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 180 } 181 return nil 182} 183 184func (p *Endpoint) readField1(iprot thrift.TProtocol) error { 185 if v, err := iprot.ReadI32(); err != nil { 186 return thrift.PrependError("error reading field 1: ", err) 187 } else { 188 p.Ipv4 = v 189 } 190 return nil 191} 192 193func (p *Endpoint) readField2(iprot thrift.TProtocol) error { 194 if v, err := iprot.ReadI16(); err != nil { 195 return thrift.PrependError("error reading field 2: ", err) 196 } else { 197 p.Port = v 198 } 199 return nil 200} 201 202func (p *Endpoint) readField3(iprot thrift.TProtocol) error { 203 if v, err := iprot.ReadString(); err != nil { 204 return thrift.PrependError("error reading field 3: ", err) 205 } else { 206 p.ServiceName = v 207 } 208 return nil 209} 210 211func (p *Endpoint) readField4(iprot thrift.TProtocol) error { 212 if v, err := iprot.ReadBinary(); err != nil { 213 return thrift.PrependError("error reading field 4: ", err) 214 } else { 215 p.Ipv6 = v 216 } 217 return nil 218} 219 220func (p *Endpoint) Write(oprot thrift.TProtocol) error { 221 if err := oprot.WriteStructBegin("Endpoint"); err != nil { 222 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 223 } 224 if err := p.writeField1(oprot); err != nil { 225 return err 226 } 227 if err := p.writeField2(oprot); err != nil { 228 return err 229 } 230 if err := p.writeField3(oprot); err != nil { 231 return err 232 } 233 if err := p.writeField4(oprot); err != nil { 234 return err 235 } 236 if err := oprot.WriteFieldStop(); err != nil { 237 return thrift.PrependError("write field stop error: ", err) 238 } 239 if err := oprot.WriteStructEnd(); err != nil { 240 return thrift.PrependError("write struct stop error: ", err) 241 } 242 return nil 243} 244 245func (p *Endpoint) writeField1(oprot thrift.TProtocol) (err error) { 246 if err := oprot.WriteFieldBegin("ipv4", thrift.I32, 1); err != nil { 247 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ipv4: ", p), err) 248 } 249 if err := oprot.WriteI32(int32(p.Ipv4)); err != nil { 250 return thrift.PrependError(fmt.Sprintf("%T.ipv4 (1) field write error: ", p), err) 251 } 252 if err := oprot.WriteFieldEnd(); err != nil { 253 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ipv4: ", p), err) 254 } 255 return err 256} 257 258func (p *Endpoint) writeField2(oprot thrift.TProtocol) (err error) { 259 if err := oprot.WriteFieldBegin("port", thrift.I16, 2); err != nil { 260 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:port: ", p), err) 261 } 262 if err := oprot.WriteI16(int16(p.Port)); err != nil { 263 return thrift.PrependError(fmt.Sprintf("%T.port (2) field write error: ", p), err) 264 } 265 if err := oprot.WriteFieldEnd(); err != nil { 266 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:port: ", p), err) 267 } 268 return err 269} 270 271func (p *Endpoint) writeField3(oprot thrift.TProtocol) (err error) { 272 if err := oprot.WriteFieldBegin("service_name", thrift.STRING, 3); err != nil { 273 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:service_name: ", p), err) 274 } 275 if err := oprot.WriteString(string(p.ServiceName)); err != nil { 276 return thrift.PrependError(fmt.Sprintf("%T.service_name (3) field write error: ", p), err) 277 } 278 if err := oprot.WriteFieldEnd(); err != nil { 279 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:service_name: ", p), err) 280 } 281 return err 282} 283 284func (p *Endpoint) writeField4(oprot thrift.TProtocol) (err error) { 285 if p.IsSetIpv6() { 286 if err := oprot.WriteFieldBegin("ipv6", thrift.STRING, 4); err != nil { 287 return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:ipv6: ", p), err) 288 } 289 if err := oprot.WriteBinary(p.Ipv6); err != nil { 290 return thrift.PrependError(fmt.Sprintf("%T.ipv6 (4) field write error: ", p), err) 291 } 292 if err := oprot.WriteFieldEnd(); err != nil { 293 return thrift.PrependError(fmt.Sprintf("%T write field end error 4:ipv6: ", p), err) 294 } 295 } 296 return err 297} 298 299func (p *Endpoint) String() string { 300 if p == nil { 301 return "<nil>" 302 } 303 return fmt.Sprintf("Endpoint(%+v)", *p) 304} 305 306// An annotation is similar to a log statement. It includes a host field which 307// allows these events to be attributed properly, and also aggregatable. 308// 309// Attributes: 310// - Timestamp: Microseconds from epoch. 311// 312// This value should use the most precise value possible. For example, 313// gettimeofday or syncing nanoTime against a tick of currentTimeMillis. 314// - Value 315// - Host: Always the host that recorded the event. By specifying the host you allow 316// rollup of all events (such as client requests to a service) by IP address. 317type Annotation struct { 318 Timestamp int64 `thrift:"timestamp,1" json:"timestamp"` 319 Value string `thrift:"value,2" json:"value"` 320 Host *Endpoint `thrift:"host,3" json:"host,omitempty"` 321} 322 323func NewAnnotation() *Annotation { 324 return &Annotation{} 325} 326 327func (p *Annotation) GetTimestamp() int64 { 328 return p.Timestamp 329} 330 331func (p *Annotation) GetValue() string { 332 return p.Value 333} 334 335var Annotation_Host_DEFAULT *Endpoint 336 337func (p *Annotation) GetHost() *Endpoint { 338 if !p.IsSetHost() { 339 return Annotation_Host_DEFAULT 340 } 341 return p.Host 342} 343func (p *Annotation) IsSetHost() bool { 344 return p.Host != nil 345} 346 347func (p *Annotation) Read(iprot thrift.TProtocol) error { 348 if _, err := iprot.ReadStructBegin(); err != nil { 349 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 350 } 351 352 for { 353 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 354 if err != nil { 355 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 356 } 357 if fieldTypeId == thrift.STOP { 358 break 359 } 360 switch fieldId { 361 case 1: 362 if err := p.readField1(iprot); err != nil { 363 return err 364 } 365 case 2: 366 if err := p.readField2(iprot); err != nil { 367 return err 368 } 369 case 3: 370 if err := p.readField3(iprot); err != nil { 371 return err 372 } 373 default: 374 if err := iprot.Skip(fieldTypeId); err != nil { 375 return err 376 } 377 } 378 if err := iprot.ReadFieldEnd(); err != nil { 379 return err 380 } 381 } 382 if err := iprot.ReadStructEnd(); err != nil { 383 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 384 } 385 return nil 386} 387 388func (p *Annotation) readField1(iprot thrift.TProtocol) error { 389 if v, err := iprot.ReadI64(); err != nil { 390 return thrift.PrependError("error reading field 1: ", err) 391 } else { 392 p.Timestamp = v 393 } 394 return nil 395} 396 397func (p *Annotation) readField2(iprot thrift.TProtocol) error { 398 if v, err := iprot.ReadString(); err != nil { 399 return thrift.PrependError("error reading field 2: ", err) 400 } else { 401 p.Value = v 402 } 403 return nil 404} 405 406func (p *Annotation) readField3(iprot thrift.TProtocol) error { 407 p.Host = &Endpoint{} 408 if err := p.Host.Read(iprot); err != nil { 409 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Host), err) 410 } 411 return nil 412} 413 414func (p *Annotation) Write(oprot thrift.TProtocol) error { 415 if err := oprot.WriteStructBegin("Annotation"); err != nil { 416 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 417 } 418 if err := p.writeField1(oprot); err != nil { 419 return err 420 } 421 if err := p.writeField2(oprot); err != nil { 422 return err 423 } 424 if err := p.writeField3(oprot); err != nil { 425 return err 426 } 427 if err := oprot.WriteFieldStop(); err != nil { 428 return thrift.PrependError("write field stop error: ", err) 429 } 430 if err := oprot.WriteStructEnd(); err != nil { 431 return thrift.PrependError("write struct stop error: ", err) 432 } 433 return nil 434} 435 436func (p *Annotation) writeField1(oprot thrift.TProtocol) (err error) { 437 if err := oprot.WriteFieldBegin("timestamp", thrift.I64, 1); err != nil { 438 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:timestamp: ", p), err) 439 } 440 if err := oprot.WriteI64(int64(p.Timestamp)); err != nil { 441 return thrift.PrependError(fmt.Sprintf("%T.timestamp (1) field write error: ", p), err) 442 } 443 if err := oprot.WriteFieldEnd(); err != nil { 444 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:timestamp: ", p), err) 445 } 446 return err 447} 448 449func (p *Annotation) writeField2(oprot thrift.TProtocol) (err error) { 450 if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil { 451 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) 452 } 453 if err := oprot.WriteString(string(p.Value)); err != nil { 454 return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) 455 } 456 if err := oprot.WriteFieldEnd(); err != nil { 457 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) 458 } 459 return err 460} 461 462func (p *Annotation) writeField3(oprot thrift.TProtocol) (err error) { 463 if p.IsSetHost() { 464 if err := oprot.WriteFieldBegin("host", thrift.STRUCT, 3); err != nil { 465 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:host: ", p), err) 466 } 467 if err := p.Host.Write(oprot); err != nil { 468 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Host), err) 469 } 470 if err := oprot.WriteFieldEnd(); err != nil { 471 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:host: ", p), err) 472 } 473 } 474 return err 475} 476 477func (p *Annotation) String() string { 478 if p == nil { 479 return "<nil>" 480 } 481 return fmt.Sprintf("Annotation(%+v)", *p) 482} 483 484// Binary annotations are tags applied to a Span to give it context. For 485// example, a binary annotation of "http.uri" could the path to a resource in a 486// RPC call. 487// 488// Binary annotations of type STRING are always queryable, though more a 489// historical implementation detail than a structural concern. 490// 491// Binary annotations can repeat, and vary on the host. Similar to Annotation, 492// the host indicates who logged the event. This allows you to tell the 493// difference between the client and server side of the same key. For example, 494// the key "http.uri" might be different on the client and server side due to 495// rewriting, like "/api/v1/myresource" vs "/myresource. Via the host field, 496// you can see the different points of view, which often help in debugging. 497// 498// Attributes: 499// - Key 500// - Value 501// - AnnotationType 502// - Host: The host that recorded tag, which allows you to differentiate between 503// multiple tags with the same key. There are two exceptions to this. 504// 505// When the key is CLIENT_ADDR or SERVER_ADDR, host indicates the source or 506// destination of an RPC. This exception allows zipkin to display network 507// context of uninstrumented services, or clients such as web browsers. 508type BinaryAnnotation struct { 509 Key string `thrift:"key,1" json:"key"` 510 Value []byte `thrift:"value,2" json:"value"` 511 AnnotationType AnnotationType `thrift:"annotation_type,3" json:"annotation_type"` 512 Host *Endpoint `thrift:"host,4" json:"host,omitempty"` 513} 514 515func NewBinaryAnnotation() *BinaryAnnotation { 516 return &BinaryAnnotation{} 517} 518 519func (p *BinaryAnnotation) GetKey() string { 520 return p.Key 521} 522 523func (p *BinaryAnnotation) GetValue() []byte { 524 return p.Value 525} 526 527func (p *BinaryAnnotation) GetAnnotationType() AnnotationType { 528 return p.AnnotationType 529} 530 531var BinaryAnnotation_Host_DEFAULT *Endpoint 532 533func (p *BinaryAnnotation) GetHost() *Endpoint { 534 if !p.IsSetHost() { 535 return BinaryAnnotation_Host_DEFAULT 536 } 537 return p.Host 538} 539func (p *BinaryAnnotation) IsSetHost() bool { 540 return p.Host != nil 541} 542 543func (p *BinaryAnnotation) Read(iprot thrift.TProtocol) error { 544 if _, err := iprot.ReadStructBegin(); err != nil { 545 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 546 } 547 548 for { 549 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 550 if err != nil { 551 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 552 } 553 if fieldTypeId == thrift.STOP { 554 break 555 } 556 switch fieldId { 557 case 1: 558 if err := p.readField1(iprot); err != nil { 559 return err 560 } 561 case 2: 562 if err := p.readField2(iprot); err != nil { 563 return err 564 } 565 case 3: 566 if err := p.readField3(iprot); err != nil { 567 return err 568 } 569 case 4: 570 if err := p.readField4(iprot); err != nil { 571 return err 572 } 573 default: 574 if err := iprot.Skip(fieldTypeId); err != nil { 575 return err 576 } 577 } 578 if err := iprot.ReadFieldEnd(); err != nil { 579 return err 580 } 581 } 582 if err := iprot.ReadStructEnd(); err != nil { 583 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 584 } 585 return nil 586} 587 588func (p *BinaryAnnotation) readField1(iprot thrift.TProtocol) error { 589 if v, err := iprot.ReadString(); err != nil { 590 return thrift.PrependError("error reading field 1: ", err) 591 } else { 592 p.Key = v 593 } 594 return nil 595} 596 597func (p *BinaryAnnotation) readField2(iprot thrift.TProtocol) error { 598 if v, err := iprot.ReadBinary(); err != nil { 599 return thrift.PrependError("error reading field 2: ", err) 600 } else { 601 p.Value = v 602 } 603 return nil 604} 605 606func (p *BinaryAnnotation) readField3(iprot thrift.TProtocol) error { 607 if v, err := iprot.ReadI32(); err != nil { 608 return thrift.PrependError("error reading field 3: ", err) 609 } else { 610 temp := AnnotationType(v) 611 p.AnnotationType = temp 612 } 613 return nil 614} 615 616func (p *BinaryAnnotation) readField4(iprot thrift.TProtocol) error { 617 p.Host = &Endpoint{} 618 if err := p.Host.Read(iprot); err != nil { 619 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Host), err) 620 } 621 return nil 622} 623 624func (p *BinaryAnnotation) Write(oprot thrift.TProtocol) error { 625 if err := oprot.WriteStructBegin("BinaryAnnotation"); err != nil { 626 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 627 } 628 if err := p.writeField1(oprot); err != nil { 629 return err 630 } 631 if err := p.writeField2(oprot); err != nil { 632 return err 633 } 634 if err := p.writeField3(oprot); err != nil { 635 return err 636 } 637 if err := p.writeField4(oprot); err != nil { 638 return err 639 } 640 if err := oprot.WriteFieldStop(); err != nil { 641 return thrift.PrependError("write field stop error: ", err) 642 } 643 if err := oprot.WriteStructEnd(); err != nil { 644 return thrift.PrependError("write struct stop error: ", err) 645 } 646 return nil 647} 648 649func (p *BinaryAnnotation) writeField1(oprot thrift.TProtocol) (err error) { 650 if err := oprot.WriteFieldBegin("key", thrift.STRING, 1); err != nil { 651 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) 652 } 653 if err := oprot.WriteString(string(p.Key)); err != nil { 654 return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) 655 } 656 if err := oprot.WriteFieldEnd(); err != nil { 657 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) 658 } 659 return err 660} 661 662func (p *BinaryAnnotation) writeField2(oprot thrift.TProtocol) (err error) { 663 if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil { 664 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) 665 } 666 if err := oprot.WriteBinary(p.Value); err != nil { 667 return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) 668 } 669 if err := oprot.WriteFieldEnd(); err != nil { 670 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) 671 } 672 return err 673} 674 675func (p *BinaryAnnotation) writeField3(oprot thrift.TProtocol) (err error) { 676 if err := oprot.WriteFieldBegin("annotation_type", thrift.I32, 3); err != nil { 677 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:annotation_type: ", p), err) 678 } 679 if err := oprot.WriteI32(int32(p.AnnotationType)); err != nil { 680 return thrift.PrependError(fmt.Sprintf("%T.annotation_type (3) field write error: ", p), err) 681 } 682 if err := oprot.WriteFieldEnd(); err != nil { 683 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:annotation_type: ", p), err) 684 } 685 return err 686} 687 688func (p *BinaryAnnotation) writeField4(oprot thrift.TProtocol) (err error) { 689 if p.IsSetHost() { 690 if err := oprot.WriteFieldBegin("host", thrift.STRUCT, 4); err != nil { 691 return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:host: ", p), err) 692 } 693 if err := p.Host.Write(oprot); err != nil { 694 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Host), err) 695 } 696 if err := oprot.WriteFieldEnd(); err != nil { 697 return thrift.PrependError(fmt.Sprintf("%T write field end error 4:host: ", p), err) 698 } 699 } 700 return err 701} 702 703func (p *BinaryAnnotation) String() string { 704 if p == nil { 705 return "<nil>" 706 } 707 return fmt.Sprintf("BinaryAnnotation(%+v)", *p) 708} 709 710// A trace is a series of spans (often RPC calls) which form a latency tree. 711// 712// The root span is where trace_id = id and parent_id = Nil. The root span is 713// usually the longest interval in the trace, starting with a SERVER_RECV 714// annotation and ending with a SERVER_SEND. 715// 716// Attributes: 717// - TraceID 718// - Name: Span name in lowercase, rpc method for example 719// 720// Conventionally, when the span name isn't known, name = "unknown". 721// - ID 722// - ParentID 723// - Annotations 724// - BinaryAnnotations 725// - Debug 726// - Timestamp: Microseconds from epoch of the creation of this span. 727// 728// This value should be set directly by instrumentation, using the most 729// precise value possible. For example, gettimeofday or syncing nanoTime 730// against a tick of currentTimeMillis. 731// 732// For compatibilty with instrumentation that precede this field, collectors 733// or span stores can derive this via Annotation.timestamp. 734// For example, SERVER_RECV.timestamp or CLIENT_SEND.timestamp. 735// 736// This field is optional for compatibility with old data: first-party span 737// stores are expected to support this at time of introduction. 738// - Duration: Measurement of duration in microseconds, used to support queries. 739// 740// This value should be set directly, where possible. Doing so encourages 741// precise measurement decoupled from problems of clocks, such as skew or NTP 742// updates causing time to move backwards. 743// 744// For compatibilty with instrumentation that precede this field, collectors 745// or span stores can derive this by subtracting Annotation.timestamp. 746// For example, SERVER_SEND.timestamp - SERVER_RECV.timestamp. 747// 748// If this field is persisted as unset, zipkin will continue to work, except 749// duration query support will be implementation-specific. Similarly, setting 750// this field non-atomically is implementation-specific. 751// 752// This field is i64 vs i32 to support spans longer than 35 minutes. 753// - TraceIDHigh: Optional unique 8-byte additional identifier for a trace. If non zero, this 754// means the trace uses 128 bit traceIds instead of 64 bit. 755type Span struct { 756 TraceID int64 `thrift:"trace_id,1" json:"trace_id"` 757 // unused field # 2 758 Name string `thrift:"name,3" json:"name"` 759 ID int64 `thrift:"id,4" json:"id"` 760 ParentID *int64 `thrift:"parent_id,5" json:"parent_id,omitempty"` 761 Annotations []*Annotation `thrift:"annotations,6" json:"annotations"` 762 // unused field # 7 763 BinaryAnnotations []*BinaryAnnotation `thrift:"binary_annotations,8" json:"binary_annotations"` 764 Debug bool `thrift:"debug,9" json:"debug,omitempty"` 765 Timestamp *int64 `thrift:"timestamp,10" json:"timestamp,omitempty"` 766 Duration *int64 `thrift:"duration,11" json:"duration,omitempty"` 767 TraceIDHigh *int64 `thrift:"trace_id_high,12" json:"trace_id_high,omitempty"` 768} 769 770func NewSpan() *Span { 771 return &Span{} 772} 773 774func (p *Span) GetTraceID() int64 { 775 return p.TraceID 776} 777 778func (p *Span) GetName() string { 779 return p.Name 780} 781 782func (p *Span) GetID() int64 { 783 return p.ID 784} 785 786var Span_ParentID_DEFAULT int64 787 788func (p *Span) GetParentID() int64 { 789 if !p.IsSetParentID() { 790 return Span_ParentID_DEFAULT 791 } 792 return *p.ParentID 793} 794 795func (p *Span) GetAnnotations() []*Annotation { 796 return p.Annotations 797} 798 799func (p *Span) GetBinaryAnnotations() []*BinaryAnnotation { 800 return p.BinaryAnnotations 801} 802 803var Span_Debug_DEFAULT bool = false 804 805func (p *Span) GetDebug() bool { 806 return p.Debug 807} 808 809var Span_Timestamp_DEFAULT int64 810 811func (p *Span) GetTimestamp() int64 { 812 if !p.IsSetTimestamp() { 813 return Span_Timestamp_DEFAULT 814 } 815 return *p.Timestamp 816} 817 818var Span_Duration_DEFAULT int64 819 820func (p *Span) GetDuration() int64 { 821 if !p.IsSetDuration() { 822 return Span_Duration_DEFAULT 823 } 824 return *p.Duration 825} 826 827var Span_TraceIDHigh_DEFAULT int64 828 829func (p *Span) GetTraceIDHigh() int64 { 830 if !p.IsSetTraceIDHigh() { 831 return Span_TraceIDHigh_DEFAULT 832 } 833 return *p.TraceIDHigh 834} 835func (p *Span) IsSetParentID() bool { 836 return p.ParentID != nil 837} 838 839func (p *Span) IsSetDebug() bool { 840 return p.Debug != Span_Debug_DEFAULT 841} 842 843func (p *Span) IsSetTimestamp() bool { 844 return p.Timestamp != nil 845} 846 847func (p *Span) IsSetDuration() bool { 848 return p.Duration != nil 849} 850 851func (p *Span) IsSetTraceIDHigh() bool { 852 return p.TraceIDHigh != nil 853} 854 855func (p *Span) Read(iprot thrift.TProtocol) error { 856 if _, err := iprot.ReadStructBegin(); err != nil { 857 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 858 } 859 860 for { 861 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 862 if err != nil { 863 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 864 } 865 if fieldTypeId == thrift.STOP { 866 break 867 } 868 switch fieldId { 869 case 1: 870 if err := p.readField1(iprot); err != nil { 871 return err 872 } 873 case 3: 874 if err := p.readField3(iprot); err != nil { 875 return err 876 } 877 case 4: 878 if err := p.readField4(iprot); err != nil { 879 return err 880 } 881 case 5: 882 if err := p.readField5(iprot); err != nil { 883 return err 884 } 885 case 6: 886 if err := p.readField6(iprot); err != nil { 887 return err 888 } 889 case 8: 890 if err := p.readField8(iprot); err != nil { 891 return err 892 } 893 case 9: 894 if err := p.readField9(iprot); err != nil { 895 return err 896 } 897 case 10: 898 if err := p.readField10(iprot); err != nil { 899 return err 900 } 901 case 11: 902 if err := p.readField11(iprot); err != nil { 903 return err 904 } 905 case 12: 906 if err := p.readField12(iprot); err != nil { 907 return err 908 } 909 default: 910 if err := iprot.Skip(fieldTypeId); err != nil { 911 return err 912 } 913 } 914 if err := iprot.ReadFieldEnd(); err != nil { 915 return err 916 } 917 } 918 if err := iprot.ReadStructEnd(); err != nil { 919 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 920 } 921 return nil 922} 923 924func (p *Span) readField1(iprot thrift.TProtocol) error { 925 if v, err := iprot.ReadI64(); err != nil { 926 return thrift.PrependError("error reading field 1: ", err) 927 } else { 928 p.TraceID = v 929 } 930 return nil 931} 932 933func (p *Span) readField3(iprot thrift.TProtocol) error { 934 if v, err := iprot.ReadString(); err != nil { 935 return thrift.PrependError("error reading field 3: ", err) 936 } else { 937 p.Name = v 938 } 939 return nil 940} 941 942func (p *Span) readField4(iprot thrift.TProtocol) error { 943 if v, err := iprot.ReadI64(); err != nil { 944 return thrift.PrependError("error reading field 4: ", err) 945 } else { 946 p.ID = v 947 } 948 return nil 949} 950 951func (p *Span) readField5(iprot thrift.TProtocol) error { 952 if v, err := iprot.ReadI64(); err != nil { 953 return thrift.PrependError("error reading field 5: ", err) 954 } else { 955 p.ParentID = &v 956 } 957 return nil 958} 959 960func (p *Span) readField6(iprot thrift.TProtocol) error { 961 _, size, err := iprot.ReadListBegin() 962 if err != nil { 963 return thrift.PrependError("error reading list begin: ", err) 964 } 965 tSlice := make([]*Annotation, 0, size) 966 p.Annotations = tSlice 967 for i := 0; i < size; i++ { 968 _elem0 := &Annotation{} 969 if err := _elem0.Read(iprot); err != nil { 970 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem0), err) 971 } 972 p.Annotations = append(p.Annotations, _elem0) 973 } 974 if err := iprot.ReadListEnd(); err != nil { 975 return thrift.PrependError("error reading list end: ", err) 976 } 977 return nil 978} 979 980func (p *Span) readField8(iprot thrift.TProtocol) error { 981 _, size, err := iprot.ReadListBegin() 982 if err != nil { 983 return thrift.PrependError("error reading list begin: ", err) 984 } 985 tSlice := make([]*BinaryAnnotation, 0, size) 986 p.BinaryAnnotations = tSlice 987 for i := 0; i < size; i++ { 988 _elem1 := &BinaryAnnotation{} 989 if err := _elem1.Read(iprot); err != nil { 990 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem1), err) 991 } 992 p.BinaryAnnotations = append(p.BinaryAnnotations, _elem1) 993 } 994 if err := iprot.ReadListEnd(); err != nil { 995 return thrift.PrependError("error reading list end: ", err) 996 } 997 return nil 998} 999 1000func (p *Span) readField9(iprot thrift.TProtocol) error { 1001 if v, err := iprot.ReadBool(); err != nil { 1002 return thrift.PrependError("error reading field 9: ", err) 1003 } else { 1004 p.Debug = v 1005 } 1006 return nil 1007} 1008 1009func (p *Span) readField10(iprot thrift.TProtocol) error { 1010 if v, err := iprot.ReadI64(); err != nil { 1011 return thrift.PrependError("error reading field 10: ", err) 1012 } else { 1013 p.Timestamp = &v 1014 } 1015 return nil 1016} 1017 1018func (p *Span) readField11(iprot thrift.TProtocol) error { 1019 if v, err := iprot.ReadI64(); err != nil { 1020 return thrift.PrependError("error reading field 11: ", err) 1021 } else { 1022 p.Duration = &v 1023 } 1024 return nil 1025} 1026 1027func (p *Span) readField12(iprot thrift.TProtocol) error { 1028 if v, err := iprot.ReadI64(); err != nil { 1029 return thrift.PrependError("error reading field 12: ", err) 1030 } else { 1031 p.TraceIDHigh = &v 1032 } 1033 return nil 1034} 1035 1036func (p *Span) Write(oprot thrift.TProtocol) error { 1037 if err := oprot.WriteStructBegin("Span"); err != nil { 1038 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 1039 } 1040 if err := p.writeField1(oprot); err != nil { 1041 return err 1042 } 1043 if err := p.writeField3(oprot); err != nil { 1044 return err 1045 } 1046 if err := p.writeField4(oprot); err != nil { 1047 return err 1048 } 1049 if err := p.writeField5(oprot); err != nil { 1050 return err 1051 } 1052 if err := p.writeField6(oprot); err != nil { 1053 return err 1054 } 1055 if err := p.writeField8(oprot); err != nil { 1056 return err 1057 } 1058 if err := p.writeField9(oprot); err != nil { 1059 return err 1060 } 1061 if err := p.writeField10(oprot); err != nil { 1062 return err 1063 } 1064 if err := p.writeField11(oprot); err != nil { 1065 return err 1066 } 1067 if err := p.writeField12(oprot); err != nil { 1068 return err 1069 } 1070 if err := oprot.WriteFieldStop(); err != nil { 1071 return thrift.PrependError("write field stop error: ", err) 1072 } 1073 if err := oprot.WriteStructEnd(); err != nil { 1074 return thrift.PrependError("write struct stop error: ", err) 1075 } 1076 return nil 1077} 1078 1079func (p *Span) writeField1(oprot thrift.TProtocol) (err error) { 1080 if err := oprot.WriteFieldBegin("trace_id", thrift.I64, 1); err != nil { 1081 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:trace_id: ", p), err) 1082 } 1083 if err := oprot.WriteI64(int64(p.TraceID)); err != nil { 1084 return thrift.PrependError(fmt.Sprintf("%T.trace_id (1) field write error: ", p), err) 1085 } 1086 if err := oprot.WriteFieldEnd(); err != nil { 1087 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:trace_id: ", p), err) 1088 } 1089 return err 1090} 1091 1092func (p *Span) writeField3(oprot thrift.TProtocol) (err error) { 1093 if err := oprot.WriteFieldBegin("name", thrift.STRING, 3); err != nil { 1094 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:name: ", p), err) 1095 } 1096 if err := oprot.WriteString(string(p.Name)); err != nil { 1097 return thrift.PrependError(fmt.Sprintf("%T.name (3) field write error: ", p), err) 1098 } 1099 if err := oprot.WriteFieldEnd(); err != nil { 1100 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:name: ", p), err) 1101 } 1102 return err 1103} 1104 1105func (p *Span) writeField4(oprot thrift.TProtocol) (err error) { 1106 if err := oprot.WriteFieldBegin("id", thrift.I64, 4); err != nil { 1107 return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:id: ", p), err) 1108 } 1109 if err := oprot.WriteI64(int64(p.ID)); err != nil { 1110 return thrift.PrependError(fmt.Sprintf("%T.id (4) field write error: ", p), err) 1111 } 1112 if err := oprot.WriteFieldEnd(); err != nil { 1113 return thrift.PrependError(fmt.Sprintf("%T write field end error 4:id: ", p), err) 1114 } 1115 return err 1116} 1117 1118func (p *Span) writeField5(oprot thrift.TProtocol) (err error) { 1119 if p.IsSetParentID() { 1120 if err := oprot.WriteFieldBegin("parent_id", thrift.I64, 5); err != nil { 1121 return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:parent_id: ", p), err) 1122 } 1123 if err := oprot.WriteI64(int64(*p.ParentID)); err != nil { 1124 return thrift.PrependError(fmt.Sprintf("%T.parent_id (5) field write error: ", p), err) 1125 } 1126 if err := oprot.WriteFieldEnd(); err != nil { 1127 return thrift.PrependError(fmt.Sprintf("%T write field end error 5:parent_id: ", p), err) 1128 } 1129 } 1130 return err 1131} 1132 1133func (p *Span) writeField6(oprot thrift.TProtocol) (err error) { 1134 if err := oprot.WriteFieldBegin("annotations", thrift.LIST, 6); err != nil { 1135 return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:annotations: ", p), err) 1136 } 1137 if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Annotations)); err != nil { 1138 return thrift.PrependError("error writing list begin: ", err) 1139 } 1140 for _, v := range p.Annotations { 1141 if err := v.Write(oprot); err != nil { 1142 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) 1143 } 1144 } 1145 if err := oprot.WriteListEnd(); err != nil { 1146 return thrift.PrependError("error writing list end: ", err) 1147 } 1148 if err := oprot.WriteFieldEnd(); err != nil { 1149 return thrift.PrependError(fmt.Sprintf("%T write field end error 6:annotations: ", p), err) 1150 } 1151 return err 1152} 1153 1154func (p *Span) writeField8(oprot thrift.TProtocol) (err error) { 1155 if err := oprot.WriteFieldBegin("binary_annotations", thrift.LIST, 8); err != nil { 1156 return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:binary_annotations: ", p), err) 1157 } 1158 if err := oprot.WriteListBegin(thrift.STRUCT, len(p.BinaryAnnotations)); err != nil { 1159 return thrift.PrependError("error writing list begin: ", err) 1160 } 1161 for _, v := range p.BinaryAnnotations { 1162 if err := v.Write(oprot); err != nil { 1163 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) 1164 } 1165 } 1166 if err := oprot.WriteListEnd(); err != nil { 1167 return thrift.PrependError("error writing list end: ", err) 1168 } 1169 if err := oprot.WriteFieldEnd(); err != nil { 1170 return thrift.PrependError(fmt.Sprintf("%T write field end error 8:binary_annotations: ", p), err) 1171 } 1172 return err 1173} 1174 1175func (p *Span) writeField9(oprot thrift.TProtocol) (err error) { 1176 if p.IsSetDebug() { 1177 if err := oprot.WriteFieldBegin("debug", thrift.BOOL, 9); err != nil { 1178 return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:debug: ", p), err) 1179 } 1180 if err := oprot.WriteBool(bool(p.Debug)); err != nil { 1181 return thrift.PrependError(fmt.Sprintf("%T.debug (9) field write error: ", p), err) 1182 } 1183 if err := oprot.WriteFieldEnd(); err != nil { 1184 return thrift.PrependError(fmt.Sprintf("%T write field end error 9:debug: ", p), err) 1185 } 1186 } 1187 return err 1188} 1189 1190func (p *Span) writeField10(oprot thrift.TProtocol) (err error) { 1191 if p.IsSetTimestamp() { 1192 if err := oprot.WriteFieldBegin("timestamp", thrift.I64, 10); err != nil { 1193 return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:timestamp: ", p), err) 1194 } 1195 if err := oprot.WriteI64(int64(*p.Timestamp)); err != nil { 1196 return thrift.PrependError(fmt.Sprintf("%T.timestamp (10) field write error: ", p), err) 1197 } 1198 if err := oprot.WriteFieldEnd(); err != nil { 1199 return thrift.PrependError(fmt.Sprintf("%T write field end error 10:timestamp: ", p), err) 1200 } 1201 } 1202 return err 1203} 1204 1205func (p *Span) writeField11(oprot thrift.TProtocol) (err error) { 1206 if p.IsSetDuration() { 1207 if err := oprot.WriteFieldBegin("duration", thrift.I64, 11); err != nil { 1208 return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:duration: ", p), err) 1209 } 1210 if err := oprot.WriteI64(int64(*p.Duration)); err != nil { 1211 return thrift.PrependError(fmt.Sprintf("%T.duration (11) field write error: ", p), err) 1212 } 1213 if err := oprot.WriteFieldEnd(); err != nil { 1214 return thrift.PrependError(fmt.Sprintf("%T write field end error 11:duration: ", p), err) 1215 } 1216 } 1217 return err 1218} 1219 1220func (p *Span) writeField12(oprot thrift.TProtocol) (err error) { 1221 if p.IsSetTraceIDHigh() { 1222 if err := oprot.WriteFieldBegin("trace_id_high", thrift.I64, 12); err != nil { 1223 return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:trace_id_high: ", p), err) 1224 } 1225 if err := oprot.WriteI64(int64(*p.TraceIDHigh)); err != nil { 1226 return thrift.PrependError(fmt.Sprintf("%T.trace_id_high (12) field write error: ", p), err) 1227 } 1228 if err := oprot.WriteFieldEnd(); err != nil { 1229 return thrift.PrependError(fmt.Sprintf("%T write field end error 12:trace_id_high: ", p), err) 1230 } 1231 } 1232 return err 1233} 1234 1235func (p *Span) String() string { 1236 if p == nil { 1237 return "<nil>" 1238 } 1239 return fmt.Sprintf("Span(%+v)", *p) 1240} 1241 1242// Attributes: 1243// - Ok 1244type Response struct { 1245 Ok bool `thrift:"ok,1,required" json:"ok"` 1246} 1247 1248func NewResponse() *Response { 1249 return &Response{} 1250} 1251 1252func (p *Response) GetOk() bool { 1253 return p.Ok 1254} 1255func (p *Response) Read(iprot thrift.TProtocol) error { 1256 if _, err := iprot.ReadStructBegin(); err != nil { 1257 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 1258 } 1259 1260 var issetOk bool = false 1261 1262 for { 1263 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 1264 if err != nil { 1265 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 1266 } 1267 if fieldTypeId == thrift.STOP { 1268 break 1269 } 1270 switch fieldId { 1271 case 1: 1272 if err := p.readField1(iprot); err != nil { 1273 return err 1274 } 1275 issetOk = true 1276 default: 1277 if err := iprot.Skip(fieldTypeId); err != nil { 1278 return err 1279 } 1280 } 1281 if err := iprot.ReadFieldEnd(); err != nil { 1282 return err 1283 } 1284 } 1285 if err := iprot.ReadStructEnd(); err != nil { 1286 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 1287 } 1288 if !issetOk { 1289 return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field Ok is not set")) 1290 } 1291 return nil 1292} 1293 1294func (p *Response) readField1(iprot thrift.TProtocol) error { 1295 if v, err := iprot.ReadBool(); err != nil { 1296 return thrift.PrependError("error reading field 1: ", err) 1297 } else { 1298 p.Ok = v 1299 } 1300 return nil 1301} 1302 1303func (p *Response) Write(oprot thrift.TProtocol) error { 1304 if err := oprot.WriteStructBegin("Response"); err != nil { 1305 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 1306 } 1307 if err := p.writeField1(oprot); err != nil { 1308 return err 1309 } 1310 if err := oprot.WriteFieldStop(); err != nil { 1311 return thrift.PrependError("write field stop error: ", err) 1312 } 1313 if err := oprot.WriteStructEnd(); err != nil { 1314 return thrift.PrependError("write struct stop error: ", err) 1315 } 1316 return nil 1317} 1318 1319func (p *Response) writeField1(oprot thrift.TProtocol) (err error) { 1320 if err := oprot.WriteFieldBegin("ok", thrift.BOOL, 1); err != nil { 1321 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ok: ", p), err) 1322 } 1323 if err := oprot.WriteBool(bool(p.Ok)); err != nil { 1324 return thrift.PrependError(fmt.Sprintf("%T.ok (1) field write error: ", p), err) 1325 } 1326 if err := oprot.WriteFieldEnd(); err != nil { 1327 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ok: ", p), err) 1328 } 1329 return err 1330} 1331 1332func (p *Response) String() string { 1333 if p == nil { 1334 return "<nil>" 1335 } 1336 return fmt.Sprintf("Response(%+v)", *p) 1337} 1338