github.com/uber-go/tally/v4@v4.1.17/m3/thrift/v1/ttypes.go (about) 1 // Autogenerated by Thrift Compiler (0.9.3) 2 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 3 4 package v1 5 6 import ( 7 "bytes" 8 "fmt" 9 "github.com/uber-go/tally/v4/thirdparty/github.com/apache/thrift/lib/go/thrift" 10 ) 11 12 // (needed to ensure safety because of naive import list construction.) 13 var _ = thrift.ZERO 14 var _ = fmt.Printf 15 var _ = bytes.Equal 16 17 var GoUnusedProtection__ int 18 19 // Different types of values that m3 emits. Each metric 20 // must contain one of these values 21 // 22 // Attributes: 23 // - Count 24 // - Gauge 25 // - Timer 26 type MetricValue struct { 27 Count *CountValue `thrift:"count,1" json:"count,omitempty"` 28 Gauge *GaugeValue `thrift:"gauge,2" json:"gauge,omitempty"` 29 Timer *TimerValue `thrift:"timer,3" json:"timer,omitempty"` 30 } 31 32 func NewMetricValue() *MetricValue { 33 return &MetricValue{} 34 } 35 36 var MetricValue_Count_DEFAULT CountValue 37 38 func (p *MetricValue) GetCount() CountValue { 39 if !p.IsSetCount() { 40 return MetricValue_Count_DEFAULT 41 } 42 return *p.Count 43 } 44 45 var MetricValue_Gauge_DEFAULT GaugeValue 46 47 func (p *MetricValue) GetGauge() GaugeValue { 48 if !p.IsSetGauge() { 49 return MetricValue_Gauge_DEFAULT 50 } 51 return *p.Gauge 52 } 53 54 var MetricValue_Timer_DEFAULT TimerValue 55 56 func (p *MetricValue) GetTimer() TimerValue { 57 if !p.IsSetTimer() { 58 return MetricValue_Timer_DEFAULT 59 } 60 return *p.Timer 61 } 62 func (p *MetricValue) CountSetFieldsMetricValue() int { 63 count := 0 64 if p.IsSetCount() { 65 count++ 66 } 67 if p.IsSetGauge() { 68 count++ 69 } 70 if p.IsSetTimer() { 71 count++ 72 } 73 return count 74 75 } 76 77 func (p *MetricValue) IsSetCount() bool { 78 return p.Count != nil 79 } 80 81 func (p *MetricValue) IsSetGauge() bool { 82 return p.Gauge != nil 83 } 84 85 func (p *MetricValue) IsSetTimer() bool { 86 return p.Timer != nil 87 } 88 89 func (p *MetricValue) Read(iprot thrift.TProtocol) error { 90 if _, err := iprot.ReadStructBegin(); err != nil { 91 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 92 } 93 94 for { 95 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 96 if err != nil { 97 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 98 } 99 if fieldTypeId == thrift.STOP { 100 break 101 } 102 switch fieldId { 103 case 1: 104 if err := p.readField1(iprot); err != nil { 105 return err 106 } 107 case 2: 108 if err := p.readField2(iprot); err != nil { 109 return err 110 } 111 case 3: 112 if err := p.readField3(iprot); err != nil { 113 return err 114 } 115 default: 116 if err := iprot.Skip(fieldTypeId); err != nil { 117 return err 118 } 119 } 120 if err := iprot.ReadFieldEnd(); err != nil { 121 return err 122 } 123 } 124 if err := iprot.ReadStructEnd(); err != nil { 125 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 126 } 127 return nil 128 } 129 130 func (p *MetricValue) readField1(iprot thrift.TProtocol) error { 131 p.Count = &CountValue{} 132 if err := p.Count.Read(iprot); err != nil { 133 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Count), err) 134 } 135 return nil 136 } 137 138 func (p *MetricValue) readField2(iprot thrift.TProtocol) error { 139 p.Gauge = &GaugeValue{} 140 if err := p.Gauge.Read(iprot); err != nil { 141 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Gauge), err) 142 } 143 return nil 144 } 145 146 func (p *MetricValue) readField3(iprot thrift.TProtocol) error { 147 p.Timer = &TimerValue{} 148 if err := p.Timer.Read(iprot); err != nil { 149 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Timer), err) 150 } 151 return nil 152 } 153 154 func (p *MetricValue) Write(oprot thrift.TProtocol) error { 155 if c := p.CountSetFieldsMetricValue(); c != 1 { 156 return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) 157 } 158 if err := oprot.WriteStructBegin("MetricValue"); err != nil { 159 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 160 } 161 if err := p.writeField1(oprot); err != nil { 162 return err 163 } 164 if err := p.writeField2(oprot); err != nil { 165 return err 166 } 167 if err := p.writeField3(oprot); err != nil { 168 return err 169 } 170 if err := oprot.WriteFieldStop(); err != nil { 171 return thrift.PrependError("write field stop error: ", err) 172 } 173 if err := oprot.WriteStructEnd(); err != nil { 174 return thrift.PrependError("write struct stop error: ", err) 175 } 176 return nil 177 } 178 179 func (p *MetricValue) writeField1(oprot thrift.TProtocol) (err error) { 180 if p.IsSetCount() { 181 if err := oprot.WriteFieldBegin("count", thrift.STRUCT, 1); err != nil { 182 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:count: ", p), err) 183 } 184 if err := p.Count.Write(oprot); err != nil { 185 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Count), err) 186 } 187 if err := oprot.WriteFieldEnd(); err != nil { 188 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:count: ", p), err) 189 } 190 } 191 return err 192 } 193 194 func (p *MetricValue) writeField2(oprot thrift.TProtocol) (err error) { 195 if p.IsSetGauge() { 196 if err := oprot.WriteFieldBegin("gauge", thrift.STRUCT, 2); err != nil { 197 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:gauge: ", p), err) 198 } 199 if err := p.Gauge.Write(oprot); err != nil { 200 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Gauge), err) 201 } 202 if err := oprot.WriteFieldEnd(); err != nil { 203 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:gauge: ", p), err) 204 } 205 } 206 return err 207 } 208 209 func (p *MetricValue) writeField3(oprot thrift.TProtocol) (err error) { 210 if p.IsSetTimer() { 211 if err := oprot.WriteFieldBegin("timer", thrift.STRUCT, 3); err != nil { 212 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:timer: ", p), err) 213 } 214 if err := p.Timer.Write(oprot); err != nil { 215 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Timer), err) 216 } 217 if err := oprot.WriteFieldEnd(); err != nil { 218 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:timer: ", p), err) 219 } 220 } 221 return err 222 } 223 224 func (p *MetricValue) String() string { 225 if p == nil { 226 return "<nil>" 227 } 228 return fmt.Sprintf("MetricValue(%+v)", *p) 229 } 230 231 // Different types of count values 232 // 233 // Attributes: 234 // - I64Value 235 type CountValue struct { 236 I64Value *int64 `thrift:"i64Value,1" json:"i64Value,omitempty"` 237 } 238 239 func NewCountValue() *CountValue { 240 return &CountValue{} 241 } 242 243 var CountValue_I64Value_DEFAULT int64 244 245 func (p *CountValue) GetI64Value() int64 { 246 if !p.IsSetI64Value() { 247 return CountValue_I64Value_DEFAULT 248 } 249 return *p.I64Value 250 } 251 func (p *CountValue) CountSetFieldsCountValue() int { 252 count := 0 253 if p.IsSetI64Value() { 254 count++ 255 } 256 return count 257 258 } 259 260 func (p *CountValue) IsSetI64Value() bool { 261 return p.I64Value != nil 262 } 263 264 func (p *CountValue) Read(iprot thrift.TProtocol) error { 265 if _, err := iprot.ReadStructBegin(); err != nil { 266 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 267 } 268 269 for { 270 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 271 if err != nil { 272 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 273 } 274 if fieldTypeId == thrift.STOP { 275 break 276 } 277 switch fieldId { 278 case 1: 279 if err := p.readField1(iprot); err != nil { 280 return err 281 } 282 default: 283 if err := iprot.Skip(fieldTypeId); err != nil { 284 return err 285 } 286 } 287 if err := iprot.ReadFieldEnd(); err != nil { 288 return err 289 } 290 } 291 if err := iprot.ReadStructEnd(); err != nil { 292 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 293 } 294 return nil 295 } 296 297 func (p *CountValue) readField1(iprot thrift.TProtocol) error { 298 if v, err := iprot.ReadI64(); err != nil { 299 return thrift.PrependError("error reading field 1: ", err) 300 } else { 301 p.I64Value = &v 302 } 303 return nil 304 } 305 306 func (p *CountValue) Write(oprot thrift.TProtocol) error { 307 if c := p.CountSetFieldsCountValue(); c != 1 { 308 return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) 309 } 310 if err := oprot.WriteStructBegin("CountValue"); err != nil { 311 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 312 } 313 if err := p.writeField1(oprot); err != nil { 314 return err 315 } 316 if err := oprot.WriteFieldStop(); err != nil { 317 return thrift.PrependError("write field stop error: ", err) 318 } 319 if err := oprot.WriteStructEnd(); err != nil { 320 return thrift.PrependError("write struct stop error: ", err) 321 } 322 return nil 323 } 324 325 func (p *CountValue) writeField1(oprot thrift.TProtocol) (err error) { 326 if p.IsSetI64Value() { 327 if err := oprot.WriteFieldBegin("i64Value", thrift.I64, 1); err != nil { 328 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:i64Value: ", p), err) 329 } 330 if err := oprot.WriteI64(int64(*p.I64Value)); err != nil { 331 return thrift.PrependError(fmt.Sprintf("%T.i64Value (1) field write error: ", p), err) 332 } 333 if err := oprot.WriteFieldEnd(); err != nil { 334 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:i64Value: ", p), err) 335 } 336 } 337 return err 338 } 339 340 func (p *CountValue) String() string { 341 if p == nil { 342 return "<nil>" 343 } 344 return fmt.Sprintf("CountValue(%+v)", *p) 345 } 346 347 // Different types of gauge values 348 // 349 // Attributes: 350 // - I64Value 351 // - DValue 352 type GaugeValue struct { 353 I64Value *int64 `thrift:"i64Value,1" json:"i64Value,omitempty"` 354 DValue *float64 `thrift:"dValue,2" json:"dValue,omitempty"` 355 } 356 357 func NewGaugeValue() *GaugeValue { 358 return &GaugeValue{} 359 } 360 361 var GaugeValue_I64Value_DEFAULT int64 362 363 func (p *GaugeValue) GetI64Value() int64 { 364 if !p.IsSetI64Value() { 365 return GaugeValue_I64Value_DEFAULT 366 } 367 return *p.I64Value 368 } 369 370 var GaugeValue_DValue_DEFAULT float64 371 372 func (p *GaugeValue) GetDValue() float64 { 373 if !p.IsSetDValue() { 374 return GaugeValue_DValue_DEFAULT 375 } 376 return *p.DValue 377 } 378 func (p *GaugeValue) CountSetFieldsGaugeValue() int { 379 count := 0 380 if p.IsSetI64Value() { 381 count++ 382 } 383 if p.IsSetDValue() { 384 count++ 385 } 386 return count 387 388 } 389 390 func (p *GaugeValue) IsSetI64Value() bool { 391 return p.I64Value != nil 392 } 393 394 func (p *GaugeValue) IsSetDValue() bool { 395 return p.DValue != nil 396 } 397 398 func (p *GaugeValue) Read(iprot thrift.TProtocol) error { 399 if _, err := iprot.ReadStructBegin(); err != nil { 400 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 401 } 402 403 for { 404 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 405 if err != nil { 406 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 407 } 408 if fieldTypeId == thrift.STOP { 409 break 410 } 411 switch fieldId { 412 case 1: 413 if err := p.readField1(iprot); err != nil { 414 return err 415 } 416 case 2: 417 if err := p.readField2(iprot); err != nil { 418 return err 419 } 420 default: 421 if err := iprot.Skip(fieldTypeId); err != nil { 422 return err 423 } 424 } 425 if err := iprot.ReadFieldEnd(); err != nil { 426 return err 427 } 428 } 429 if err := iprot.ReadStructEnd(); err != nil { 430 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 431 } 432 return nil 433 } 434 435 func (p *GaugeValue) readField1(iprot thrift.TProtocol) error { 436 if v, err := iprot.ReadI64(); err != nil { 437 return thrift.PrependError("error reading field 1: ", err) 438 } else { 439 p.I64Value = &v 440 } 441 return nil 442 } 443 444 func (p *GaugeValue) readField2(iprot thrift.TProtocol) error { 445 if v, err := iprot.ReadDouble(); err != nil { 446 return thrift.PrependError("error reading field 2: ", err) 447 } else { 448 p.DValue = &v 449 } 450 return nil 451 } 452 453 func (p *GaugeValue) Write(oprot thrift.TProtocol) error { 454 if c := p.CountSetFieldsGaugeValue(); c != 1 { 455 return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) 456 } 457 if err := oprot.WriteStructBegin("GaugeValue"); err != nil { 458 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 459 } 460 if err := p.writeField1(oprot); err != nil { 461 return err 462 } 463 if err := p.writeField2(oprot); err != nil { 464 return err 465 } 466 if err := oprot.WriteFieldStop(); err != nil { 467 return thrift.PrependError("write field stop error: ", err) 468 } 469 if err := oprot.WriteStructEnd(); err != nil { 470 return thrift.PrependError("write struct stop error: ", err) 471 } 472 return nil 473 } 474 475 func (p *GaugeValue) writeField1(oprot thrift.TProtocol) (err error) { 476 if p.IsSetI64Value() { 477 if err := oprot.WriteFieldBegin("i64Value", thrift.I64, 1); err != nil { 478 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:i64Value: ", p), err) 479 } 480 if err := oprot.WriteI64(int64(*p.I64Value)); err != nil { 481 return thrift.PrependError(fmt.Sprintf("%T.i64Value (1) field write error: ", p), err) 482 } 483 if err := oprot.WriteFieldEnd(); err != nil { 484 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:i64Value: ", p), err) 485 } 486 } 487 return err 488 } 489 490 func (p *GaugeValue) writeField2(oprot thrift.TProtocol) (err error) { 491 if p.IsSetDValue() { 492 if err := oprot.WriteFieldBegin("dValue", thrift.DOUBLE, 2); err != nil { 493 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:dValue: ", p), err) 494 } 495 if err := oprot.WriteDouble(float64(*p.DValue)); err != nil { 496 return thrift.PrependError(fmt.Sprintf("%T.dValue (2) field write error: ", p), err) 497 } 498 if err := oprot.WriteFieldEnd(); err != nil { 499 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:dValue: ", p), err) 500 } 501 } 502 return err 503 } 504 505 func (p *GaugeValue) String() string { 506 if p == nil { 507 return "<nil>" 508 } 509 return fmt.Sprintf("GaugeValue(%+v)", *p) 510 } 511 512 // Different types of timer values 513 // 514 // Attributes: 515 // - I64Value 516 // - DValue 517 type TimerValue struct { 518 I64Value *int64 `thrift:"i64Value,1" json:"i64Value,omitempty"` 519 DValue *float64 `thrift:"dValue,2" json:"dValue,omitempty"` 520 } 521 522 func NewTimerValue() *TimerValue { 523 return &TimerValue{} 524 } 525 526 var TimerValue_I64Value_DEFAULT int64 527 528 func (p *TimerValue) GetI64Value() int64 { 529 if !p.IsSetI64Value() { 530 return TimerValue_I64Value_DEFAULT 531 } 532 return *p.I64Value 533 } 534 535 var TimerValue_DValue_DEFAULT float64 536 537 func (p *TimerValue) GetDValue() float64 { 538 if !p.IsSetDValue() { 539 return TimerValue_DValue_DEFAULT 540 } 541 return *p.DValue 542 } 543 func (p *TimerValue) CountSetFieldsTimerValue() int { 544 count := 0 545 if p.IsSetI64Value() { 546 count++ 547 } 548 if p.IsSetDValue() { 549 count++ 550 } 551 return count 552 553 } 554 555 func (p *TimerValue) IsSetI64Value() bool { 556 return p.I64Value != nil 557 } 558 559 func (p *TimerValue) IsSetDValue() bool { 560 return p.DValue != nil 561 } 562 563 func (p *TimerValue) Read(iprot thrift.TProtocol) error { 564 if _, err := iprot.ReadStructBegin(); err != nil { 565 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 566 } 567 568 for { 569 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 570 if err != nil { 571 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 572 } 573 if fieldTypeId == thrift.STOP { 574 break 575 } 576 switch fieldId { 577 case 1: 578 if err := p.readField1(iprot); err != nil { 579 return err 580 } 581 case 2: 582 if err := p.readField2(iprot); err != nil { 583 return err 584 } 585 default: 586 if err := iprot.Skip(fieldTypeId); err != nil { 587 return err 588 } 589 } 590 if err := iprot.ReadFieldEnd(); err != nil { 591 return err 592 } 593 } 594 if err := iprot.ReadStructEnd(); err != nil { 595 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 596 } 597 return nil 598 } 599 600 func (p *TimerValue) readField1(iprot thrift.TProtocol) error { 601 if v, err := iprot.ReadI64(); err != nil { 602 return thrift.PrependError("error reading field 1: ", err) 603 } else { 604 p.I64Value = &v 605 } 606 return nil 607 } 608 609 func (p *TimerValue) readField2(iprot thrift.TProtocol) error { 610 if v, err := iprot.ReadDouble(); err != nil { 611 return thrift.PrependError("error reading field 2: ", err) 612 } else { 613 p.DValue = &v 614 } 615 return nil 616 } 617 618 func (p *TimerValue) Write(oprot thrift.TProtocol) error { 619 if c := p.CountSetFieldsTimerValue(); c != 1 { 620 return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) 621 } 622 if err := oprot.WriteStructBegin("TimerValue"); err != nil { 623 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 624 } 625 if err := p.writeField1(oprot); err != nil { 626 return err 627 } 628 if err := p.writeField2(oprot); err != nil { 629 return err 630 } 631 if err := oprot.WriteFieldStop(); err != nil { 632 return thrift.PrependError("write field stop error: ", err) 633 } 634 if err := oprot.WriteStructEnd(); err != nil { 635 return thrift.PrependError("write struct stop error: ", err) 636 } 637 return nil 638 } 639 640 func (p *TimerValue) writeField1(oprot thrift.TProtocol) (err error) { 641 if p.IsSetI64Value() { 642 if err := oprot.WriteFieldBegin("i64Value", thrift.I64, 1); err != nil { 643 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:i64Value: ", p), err) 644 } 645 if err := oprot.WriteI64(int64(*p.I64Value)); err != nil { 646 return thrift.PrependError(fmt.Sprintf("%T.i64Value (1) field write error: ", p), err) 647 } 648 if err := oprot.WriteFieldEnd(); err != nil { 649 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:i64Value: ", p), err) 650 } 651 } 652 return err 653 } 654 655 func (p *TimerValue) writeField2(oprot thrift.TProtocol) (err error) { 656 if p.IsSetDValue() { 657 if err := oprot.WriteFieldBegin("dValue", thrift.DOUBLE, 2); err != nil { 658 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:dValue: ", p), err) 659 } 660 if err := oprot.WriteDouble(float64(*p.DValue)); err != nil { 661 return thrift.PrependError(fmt.Sprintf("%T.dValue (2) field write error: ", p), err) 662 } 663 if err := oprot.WriteFieldEnd(); err != nil { 664 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:dValue: ", p), err) 665 } 666 } 667 return err 668 } 669 670 func (p *TimerValue) String() string { 671 if p == nil { 672 return "<nil>" 673 } 674 return fmt.Sprintf("TimerValue(%+v)", *p) 675 } 676 677 // Tags that can be applied to a metric 678 // 679 // Attributes: 680 // - TagName 681 // - TagValue 682 type MetricTag struct { 683 TagName string `thrift:"tagName,1" json:"tagName"` 684 TagValue *string `thrift:"tagValue,2" json:"tagValue,omitempty"` 685 } 686 687 func NewMetricTag() *MetricTag { 688 return &MetricTag{} 689 } 690 691 func (p *MetricTag) GetTagName() string { 692 return p.TagName 693 } 694 695 var MetricTag_TagValue_DEFAULT string 696 697 func (p *MetricTag) GetTagValue() string { 698 if !p.IsSetTagValue() { 699 return MetricTag_TagValue_DEFAULT 700 } 701 return *p.TagValue 702 } 703 func (p *MetricTag) IsSetTagValue() bool { 704 return p.TagValue != nil 705 } 706 707 func (p *MetricTag) Read(iprot thrift.TProtocol) error { 708 if _, err := iprot.ReadStructBegin(); err != nil { 709 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 710 } 711 712 for { 713 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 714 if err != nil { 715 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 716 } 717 if fieldTypeId == thrift.STOP { 718 break 719 } 720 switch fieldId { 721 case 1: 722 if err := p.readField1(iprot); err != nil { 723 return err 724 } 725 case 2: 726 if err := p.readField2(iprot); err != nil { 727 return err 728 } 729 default: 730 if err := iprot.Skip(fieldTypeId); err != nil { 731 return err 732 } 733 } 734 if err := iprot.ReadFieldEnd(); err != nil { 735 return err 736 } 737 } 738 if err := iprot.ReadStructEnd(); err != nil { 739 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 740 } 741 return nil 742 } 743 744 func (p *MetricTag) readField1(iprot thrift.TProtocol) error { 745 if v, err := iprot.ReadString(); err != nil { 746 return thrift.PrependError("error reading field 1: ", err) 747 } else { 748 p.TagName = v 749 } 750 return nil 751 } 752 753 func (p *MetricTag) readField2(iprot thrift.TProtocol) error { 754 if v, err := iprot.ReadString(); err != nil { 755 return thrift.PrependError("error reading field 2: ", err) 756 } else { 757 p.TagValue = &v 758 } 759 return nil 760 } 761 762 func (p *MetricTag) Write(oprot thrift.TProtocol) error { 763 if err := oprot.WriteStructBegin("MetricTag"); err != nil { 764 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 765 } 766 if err := p.writeField1(oprot); err != nil { 767 return err 768 } 769 if err := p.writeField2(oprot); err != nil { 770 return err 771 } 772 if err := oprot.WriteFieldStop(); err != nil { 773 return thrift.PrependError("write field stop error: ", err) 774 } 775 if err := oprot.WriteStructEnd(); err != nil { 776 return thrift.PrependError("write struct stop error: ", err) 777 } 778 return nil 779 } 780 781 func (p *MetricTag) writeField1(oprot thrift.TProtocol) (err error) { 782 if err := oprot.WriteFieldBegin("tagName", thrift.STRING, 1); err != nil { 783 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:tagName: ", p), err) 784 } 785 if err := oprot.WriteString(string(p.TagName)); err != nil { 786 return thrift.PrependError(fmt.Sprintf("%T.tagName (1) field write error: ", p), err) 787 } 788 if err := oprot.WriteFieldEnd(); err != nil { 789 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:tagName: ", p), err) 790 } 791 return err 792 } 793 794 func (p *MetricTag) writeField2(oprot thrift.TProtocol) (err error) { 795 if p.IsSetTagValue() { 796 if err := oprot.WriteFieldBegin("tagValue", thrift.STRING, 2); err != nil { 797 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:tagValue: ", p), err) 798 } 799 if err := oprot.WriteString(string(*p.TagValue)); err != nil { 800 return thrift.PrependError(fmt.Sprintf("%T.tagValue (2) field write error: ", p), err) 801 } 802 if err := oprot.WriteFieldEnd(); err != nil { 803 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:tagValue: ", p), err) 804 } 805 } 806 return err 807 } 808 809 func (p *MetricTag) String() string { 810 if p == nil { 811 return "<nil>" 812 } 813 return fmt.Sprintf("MetricTag(%+v)", *p) 814 } 815 816 // The metric that is being emitted 817 // 818 // Attributes: 819 // - Name 820 // - MetricValue 821 // - Timestamp 822 // - Tags 823 type Metric struct { 824 Name string `thrift:"name,1" json:"name"` 825 MetricValue *MetricValue `thrift:"metricValue,2" json:"metricValue,omitempty"` 826 Timestamp *int64 `thrift:"timestamp,3" json:"timestamp,omitempty"` 827 Tags map[*MetricTag]bool `thrift:"tags,4" json:"tags,omitempty"` 828 } 829 830 func NewMetric() *Metric { 831 return &Metric{} 832 } 833 834 func (p *Metric) GetName() string { 835 return p.Name 836 } 837 838 var Metric_MetricValue_DEFAULT *MetricValue 839 840 func (p *Metric) GetMetricValue() *MetricValue { 841 if !p.IsSetMetricValue() { 842 return Metric_MetricValue_DEFAULT 843 } 844 return p.MetricValue 845 } 846 847 var Metric_Timestamp_DEFAULT int64 848 849 func (p *Metric) GetTimestamp() int64 { 850 if !p.IsSetTimestamp() { 851 return Metric_Timestamp_DEFAULT 852 } 853 return *p.Timestamp 854 } 855 856 var Metric_Tags_DEFAULT map[*MetricTag]bool 857 858 func (p *Metric) GetTags() map[*MetricTag]bool { 859 return p.Tags 860 } 861 func (p *Metric) IsSetMetricValue() bool { 862 return p.MetricValue != nil 863 } 864 865 func (p *Metric) IsSetTimestamp() bool { 866 return p.Timestamp != nil 867 } 868 869 func (p *Metric) IsSetTags() bool { 870 return p.Tags != nil 871 } 872 873 func (p *Metric) Read(iprot thrift.TProtocol) error { 874 if _, err := iprot.ReadStructBegin(); err != nil { 875 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 876 } 877 878 for { 879 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 880 if err != nil { 881 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 882 } 883 if fieldTypeId == thrift.STOP { 884 break 885 } 886 switch fieldId { 887 case 1: 888 if err := p.readField1(iprot); err != nil { 889 return err 890 } 891 case 2: 892 if err := p.readField2(iprot); err != nil { 893 return err 894 } 895 case 3: 896 if err := p.readField3(iprot); err != nil { 897 return err 898 } 899 case 4: 900 if err := p.readField4(iprot); err != nil { 901 return err 902 } 903 default: 904 if err := iprot.Skip(fieldTypeId); err != nil { 905 return err 906 } 907 } 908 if err := iprot.ReadFieldEnd(); err != nil { 909 return err 910 } 911 } 912 if err := iprot.ReadStructEnd(); err != nil { 913 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 914 } 915 return nil 916 } 917 918 func (p *Metric) readField1(iprot thrift.TProtocol) error { 919 if v, err := iprot.ReadString(); err != nil { 920 return thrift.PrependError("error reading field 1: ", err) 921 } else { 922 p.Name = v 923 } 924 return nil 925 } 926 927 func (p *Metric) readField2(iprot thrift.TProtocol) error { 928 p.MetricValue = &MetricValue{} 929 if err := p.MetricValue.Read(iprot); err != nil { 930 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MetricValue), err) 931 } 932 return nil 933 } 934 935 func (p *Metric) readField3(iprot thrift.TProtocol) error { 936 if v, err := iprot.ReadI64(); err != nil { 937 return thrift.PrependError("error reading field 3: ", err) 938 } else { 939 p.Timestamp = &v 940 } 941 return nil 942 } 943 944 func (p *Metric) readField4(iprot thrift.TProtocol) error { 945 _, size, err := iprot.ReadSetBegin() 946 if err != nil { 947 return thrift.PrependError("error reading set begin: ", err) 948 } 949 tSet := make(map[*MetricTag]bool, size) 950 p.Tags = tSet 951 for i := 0; i < size; i++ { 952 _elem0 := &MetricTag{} 953 if err := _elem0.Read(iprot); err != nil { 954 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem0), err) 955 } 956 p.Tags[_elem0] = true 957 } 958 if err := iprot.ReadSetEnd(); err != nil { 959 return thrift.PrependError("error reading set end: ", err) 960 } 961 return nil 962 } 963 964 func (p *Metric) Write(oprot thrift.TProtocol) error { 965 if err := oprot.WriteStructBegin("Metric"); err != nil { 966 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 967 } 968 if err := p.writeField1(oprot); err != nil { 969 return err 970 } 971 if err := p.writeField2(oprot); err != nil { 972 return err 973 } 974 if err := p.writeField3(oprot); err != nil { 975 return err 976 } 977 if err := p.writeField4(oprot); err != nil { 978 return err 979 } 980 if err := oprot.WriteFieldStop(); err != nil { 981 return thrift.PrependError("write field stop error: ", err) 982 } 983 if err := oprot.WriteStructEnd(); err != nil { 984 return thrift.PrependError("write struct stop error: ", err) 985 } 986 return nil 987 } 988 989 func (p *Metric) writeField1(oprot thrift.TProtocol) (err error) { 990 if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { 991 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) 992 } 993 if err := oprot.WriteString(string(p.Name)); err != nil { 994 return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) 995 } 996 if err := oprot.WriteFieldEnd(); err != nil { 997 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) 998 } 999 return err 1000 } 1001 1002 func (p *Metric) writeField2(oprot thrift.TProtocol) (err error) { 1003 if p.IsSetMetricValue() { 1004 if err := oprot.WriteFieldBegin("metricValue", thrift.STRUCT, 2); err != nil { 1005 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:metricValue: ", p), err) 1006 } 1007 if err := p.MetricValue.Write(oprot); err != nil { 1008 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MetricValue), err) 1009 } 1010 if err := oprot.WriteFieldEnd(); err != nil { 1011 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:metricValue: ", p), err) 1012 } 1013 } 1014 return err 1015 } 1016 1017 func (p *Metric) writeField3(oprot thrift.TProtocol) (err error) { 1018 if p.IsSetTimestamp() { 1019 if err := oprot.WriteFieldBegin("timestamp", thrift.I64, 3); err != nil { 1020 return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:timestamp: ", p), err) 1021 } 1022 if err := oprot.WriteI64(int64(*p.Timestamp)); err != nil { 1023 return thrift.PrependError(fmt.Sprintf("%T.timestamp (3) field write error: ", p), err) 1024 } 1025 if err := oprot.WriteFieldEnd(); err != nil { 1026 return thrift.PrependError(fmt.Sprintf("%T write field end error 3:timestamp: ", p), err) 1027 } 1028 } 1029 return err 1030 } 1031 1032 func (p *Metric) writeField4(oprot thrift.TProtocol) (err error) { 1033 if p.IsSetTags() { 1034 if err := oprot.WriteFieldBegin("tags", thrift.SET, 4); err != nil { 1035 return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:tags: ", p), err) 1036 } 1037 if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Tags)); err != nil { 1038 return thrift.PrependError("error writing set begin: ", err) 1039 } 1040 for v, _ := range p.Tags { 1041 if err := v.Write(oprot); err != nil { 1042 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) 1043 } 1044 } 1045 if err := oprot.WriteSetEnd(); err != nil { 1046 return thrift.PrependError("error writing set end: ", err) 1047 } 1048 if err := oprot.WriteFieldEnd(); err != nil { 1049 return thrift.PrependError(fmt.Sprintf("%T write field end error 4:tags: ", p), err) 1050 } 1051 } 1052 return err 1053 } 1054 1055 func (p *Metric) String() string { 1056 if p == nil { 1057 return "<nil>" 1058 } 1059 return fmt.Sprintf("Metric(%+v)", *p) 1060 } 1061 1062 // Structure that holds a group of metrics which share 1063 // common properties like the cluster and service. 1064 // 1065 // Attributes: 1066 // - Metrics 1067 // - CommonTags 1068 type MetricBatch struct { 1069 Metrics []*Metric `thrift:"metrics,1" json:"metrics"` 1070 CommonTags map[*MetricTag]bool `thrift:"commonTags,2" json:"commonTags,omitempty"` 1071 } 1072 1073 func NewMetricBatch() *MetricBatch { 1074 return &MetricBatch{} 1075 } 1076 1077 func (p *MetricBatch) GetMetrics() []*Metric { 1078 return p.Metrics 1079 } 1080 1081 var MetricBatch_CommonTags_DEFAULT map[*MetricTag]bool 1082 1083 func (p *MetricBatch) GetCommonTags() map[*MetricTag]bool { 1084 return p.CommonTags 1085 } 1086 func (p *MetricBatch) IsSetCommonTags() bool { 1087 return p.CommonTags != nil 1088 } 1089 1090 func (p *MetricBatch) Read(iprot thrift.TProtocol) error { 1091 if _, err := iprot.ReadStructBegin(); err != nil { 1092 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) 1093 } 1094 1095 for { 1096 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() 1097 if err != nil { 1098 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) 1099 } 1100 if fieldTypeId == thrift.STOP { 1101 break 1102 } 1103 switch fieldId { 1104 case 1: 1105 if err := p.readField1(iprot); err != nil { 1106 return err 1107 } 1108 case 2: 1109 if err := p.readField2(iprot); err != nil { 1110 return err 1111 } 1112 default: 1113 if err := iprot.Skip(fieldTypeId); err != nil { 1114 return err 1115 } 1116 } 1117 if err := iprot.ReadFieldEnd(); err != nil { 1118 return err 1119 } 1120 } 1121 if err := iprot.ReadStructEnd(); err != nil { 1122 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) 1123 } 1124 return nil 1125 } 1126 1127 func (p *MetricBatch) readField1(iprot thrift.TProtocol) error { 1128 _, size, err := iprot.ReadListBegin() 1129 if err != nil { 1130 return thrift.PrependError("error reading list begin: ", err) 1131 } 1132 tSlice := make([]*Metric, 0, size) 1133 p.Metrics = tSlice 1134 for i := 0; i < size; i++ { 1135 _elem1 := &Metric{} 1136 if err := _elem1.Read(iprot); err != nil { 1137 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem1), err) 1138 } 1139 p.Metrics = append(p.Metrics, _elem1) 1140 } 1141 if err := iprot.ReadListEnd(); err != nil { 1142 return thrift.PrependError("error reading list end: ", err) 1143 } 1144 return nil 1145 } 1146 1147 func (p *MetricBatch) readField2(iprot thrift.TProtocol) error { 1148 _, size, err := iprot.ReadSetBegin() 1149 if err != nil { 1150 return thrift.PrependError("error reading set begin: ", err) 1151 } 1152 tSet := make(map[*MetricTag]bool, size) 1153 p.CommonTags = tSet 1154 for i := 0; i < size; i++ { 1155 _elem2 := &MetricTag{} 1156 if err := _elem2.Read(iprot); err != nil { 1157 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem2), err) 1158 } 1159 p.CommonTags[_elem2] = true 1160 } 1161 if err := iprot.ReadSetEnd(); err != nil { 1162 return thrift.PrependError("error reading set end: ", err) 1163 } 1164 return nil 1165 } 1166 1167 func (p *MetricBatch) Write(oprot thrift.TProtocol) error { 1168 if err := oprot.WriteStructBegin("MetricBatch"); err != nil { 1169 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) 1170 } 1171 if err := p.writeField1(oprot); err != nil { 1172 return err 1173 } 1174 if err := p.writeField2(oprot); err != nil { 1175 return err 1176 } 1177 if err := oprot.WriteFieldStop(); err != nil { 1178 return thrift.PrependError("write field stop error: ", err) 1179 } 1180 if err := oprot.WriteStructEnd(); err != nil { 1181 return thrift.PrependError("write struct stop error: ", err) 1182 } 1183 return nil 1184 } 1185 1186 func (p *MetricBatch) writeField1(oprot thrift.TProtocol) (err error) { 1187 if err := oprot.WriteFieldBegin("metrics", thrift.LIST, 1); err != nil { 1188 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:metrics: ", p), err) 1189 } 1190 if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Metrics)); err != nil { 1191 return thrift.PrependError("error writing list begin: ", err) 1192 } 1193 for _, v := range p.Metrics { 1194 if err := v.Write(oprot); err != nil { 1195 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) 1196 } 1197 } 1198 if err := oprot.WriteListEnd(); err != nil { 1199 return thrift.PrependError("error writing list end: ", err) 1200 } 1201 if err := oprot.WriteFieldEnd(); err != nil { 1202 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:metrics: ", p), err) 1203 } 1204 return err 1205 } 1206 1207 func (p *MetricBatch) writeField2(oprot thrift.TProtocol) (err error) { 1208 if p.IsSetCommonTags() { 1209 if err := oprot.WriteFieldBegin("commonTags", thrift.SET, 2); err != nil { 1210 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:commonTags: ", p), err) 1211 } 1212 if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.CommonTags)); err != nil { 1213 return thrift.PrependError("error writing set begin: ", err) 1214 } 1215 for v, _ := range p.CommonTags { 1216 if err := v.Write(oprot); err != nil { 1217 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) 1218 } 1219 } 1220 if err := oprot.WriteSetEnd(); err != nil { 1221 return thrift.PrependError("error writing set end: ", err) 1222 } 1223 if err := oprot.WriteFieldEnd(); err != nil { 1224 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:commonTags: ", p), err) 1225 } 1226 } 1227 return err 1228 } 1229 1230 func (p *MetricBatch) String() string { 1231 if p == nil { 1232 return "<nil>" 1233 } 1234 return fmt.Sprintf("MetricBatch(%+v)", *p) 1235 }