github.com/waldiirawan/apm-agent-go/v2@v2.2.2/model/marshal_fastjson.go (about) 1 // Licensed to Elasticsearch B.V. under one or more contributor 2 // license agreements. See the NOTICE file distributed with 3 // this work for additional information regarding copyright 4 // ownership. Elasticsearch B.V. licenses this file to you under 5 // the Apache License, Version 2.0 (the "License"); you may 6 // not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, 12 // software distributed under the License is distributed on an 13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 // KIND, either express or implied. See the License for the 15 // specific language governing permissions and limitations 16 // under the License. 17 18 // Code generated by "generate-fastjson". DO NOT EDIT. 19 20 package model 21 22 import ( 23 "go.elastic.co/fastjson" 24 ) 25 26 func (v *Service) MarshalFastJSON(w *fastjson.Writer) error { 27 var firstErr error 28 w.RawByte('{') 29 first := true 30 if v.Agent != nil { 31 const prefix = ",\"agent\":" 32 if first { 33 first = false 34 w.RawString(prefix[1:]) 35 } else { 36 w.RawString(prefix) 37 } 38 if err := v.Agent.MarshalFastJSON(w); err != nil && firstErr == nil { 39 firstErr = err 40 } 41 } 42 if v.Environment != "" { 43 const prefix = ",\"environment\":" 44 if first { 45 first = false 46 w.RawString(prefix[1:]) 47 } else { 48 w.RawString(prefix) 49 } 50 w.String(v.Environment) 51 } 52 if v.Framework != nil { 53 const prefix = ",\"framework\":" 54 if first { 55 first = false 56 w.RawString(prefix[1:]) 57 } else { 58 w.RawString(prefix) 59 } 60 if err := v.Framework.MarshalFastJSON(w); err != nil && firstErr == nil { 61 firstErr = err 62 } 63 } 64 if v.Language != nil { 65 const prefix = ",\"language\":" 66 if first { 67 first = false 68 w.RawString(prefix[1:]) 69 } else { 70 w.RawString(prefix) 71 } 72 if err := v.Language.MarshalFastJSON(w); err != nil && firstErr == nil { 73 firstErr = err 74 } 75 } 76 if v.Name != "" { 77 const prefix = ",\"name\":" 78 if first { 79 first = false 80 w.RawString(prefix[1:]) 81 } else { 82 w.RawString(prefix) 83 } 84 w.String(v.Name) 85 } 86 if v.Node != nil { 87 const prefix = ",\"node\":" 88 if first { 89 first = false 90 w.RawString(prefix[1:]) 91 } else { 92 w.RawString(prefix) 93 } 94 if err := v.Node.MarshalFastJSON(w); err != nil && firstErr == nil { 95 firstErr = err 96 } 97 } 98 if v.Runtime != nil { 99 const prefix = ",\"runtime\":" 100 if first { 101 first = false 102 w.RawString(prefix[1:]) 103 } else { 104 w.RawString(prefix) 105 } 106 if err := v.Runtime.MarshalFastJSON(w); err != nil && firstErr == nil { 107 firstErr = err 108 } 109 } 110 if v.Version != "" { 111 const prefix = ",\"version\":" 112 if first { 113 first = false 114 w.RawString(prefix[1:]) 115 } else { 116 w.RawString(prefix) 117 } 118 w.String(v.Version) 119 } 120 w.RawByte('}') 121 return firstErr 122 } 123 124 func (v *Agent) MarshalFastJSON(w *fastjson.Writer) error { 125 w.RawByte('{') 126 w.RawString("\"name\":") 127 w.String(v.Name) 128 w.RawString(",\"version\":") 129 w.String(v.Version) 130 w.RawByte('}') 131 return nil 132 } 133 134 func (v *Framework) MarshalFastJSON(w *fastjson.Writer) error { 135 w.RawByte('{') 136 w.RawString("\"name\":") 137 w.String(v.Name) 138 w.RawString(",\"version\":") 139 w.String(v.Version) 140 w.RawByte('}') 141 return nil 142 } 143 144 func (v *Language) MarshalFastJSON(w *fastjson.Writer) error { 145 w.RawByte('{') 146 w.RawString("\"name\":") 147 w.String(v.Name) 148 if v.Version != "" { 149 w.RawString(",\"version\":") 150 w.String(v.Version) 151 } 152 w.RawByte('}') 153 return nil 154 } 155 156 func (v *Runtime) MarshalFastJSON(w *fastjson.Writer) error { 157 w.RawByte('{') 158 w.RawString("\"name\":") 159 w.String(v.Name) 160 w.RawString(",\"version\":") 161 w.String(v.Version) 162 w.RawByte('}') 163 return nil 164 } 165 166 func (v *ServiceNode) MarshalFastJSON(w *fastjson.Writer) error { 167 w.RawByte('{') 168 if v.ConfiguredName != "" { 169 w.RawString("\"configured_name\":") 170 w.String(v.ConfiguredName) 171 } 172 w.RawByte('}') 173 return nil 174 } 175 176 func (v *System) MarshalFastJSON(w *fastjson.Writer) error { 177 var firstErr error 178 w.RawByte('{') 179 first := true 180 if v.Architecture != "" { 181 const prefix = ",\"architecture\":" 182 if first { 183 first = false 184 w.RawString(prefix[1:]) 185 } else { 186 w.RawString(prefix) 187 } 188 w.String(v.Architecture) 189 } 190 if v.Container != nil { 191 const prefix = ",\"container\":" 192 if first { 193 first = false 194 w.RawString(prefix[1:]) 195 } else { 196 w.RawString(prefix) 197 } 198 if err := v.Container.MarshalFastJSON(w); err != nil && firstErr == nil { 199 firstErr = err 200 } 201 } 202 if v.Hostname != "" { 203 const prefix = ",\"hostname\":" 204 if first { 205 first = false 206 w.RawString(prefix[1:]) 207 } else { 208 w.RawString(prefix) 209 } 210 w.String(v.Hostname) 211 } 212 if v.Kubernetes != nil { 213 const prefix = ",\"kubernetes\":" 214 if first { 215 first = false 216 w.RawString(prefix[1:]) 217 } else { 218 w.RawString(prefix) 219 } 220 if err := v.Kubernetes.MarshalFastJSON(w); err != nil && firstErr == nil { 221 firstErr = err 222 } 223 } 224 if v.Platform != "" { 225 const prefix = ",\"platform\":" 226 if first { 227 first = false 228 w.RawString(prefix[1:]) 229 } else { 230 w.RawString(prefix) 231 } 232 w.String(v.Platform) 233 } 234 w.RawByte('}') 235 return firstErr 236 } 237 238 func (v *Process) MarshalFastJSON(w *fastjson.Writer) error { 239 w.RawByte('{') 240 w.RawString("\"pid\":") 241 w.Int64(int64(v.Pid)) 242 if v.Argv != nil { 243 w.RawString(",\"argv\":") 244 w.RawByte('[') 245 for i, v := range v.Argv { 246 if i != 0 { 247 w.RawByte(',') 248 } 249 w.String(v) 250 } 251 w.RawByte(']') 252 } 253 if v.Ppid != nil { 254 w.RawString(",\"ppid\":") 255 w.Int64(int64(*v.Ppid)) 256 } 257 if v.Title != "" { 258 w.RawString(",\"title\":") 259 w.String(v.Title) 260 } 261 w.RawByte('}') 262 return nil 263 } 264 265 func (v *Container) MarshalFastJSON(w *fastjson.Writer) error { 266 w.RawByte('{') 267 w.RawString("\"id\":") 268 w.String(v.ID) 269 w.RawByte('}') 270 return nil 271 } 272 273 func (v *Kubernetes) MarshalFastJSON(w *fastjson.Writer) error { 274 var firstErr error 275 w.RawByte('{') 276 first := true 277 if v.Namespace != "" { 278 const prefix = ",\"namespace\":" 279 if first { 280 first = false 281 w.RawString(prefix[1:]) 282 } else { 283 w.RawString(prefix) 284 } 285 w.String(v.Namespace) 286 } 287 if v.Node != nil { 288 const prefix = ",\"node\":" 289 if first { 290 first = false 291 w.RawString(prefix[1:]) 292 } else { 293 w.RawString(prefix) 294 } 295 if err := v.Node.MarshalFastJSON(w); err != nil && firstErr == nil { 296 firstErr = err 297 } 298 } 299 if v.Pod != nil { 300 const prefix = ",\"pod\":" 301 if first { 302 first = false 303 w.RawString(prefix[1:]) 304 } else { 305 w.RawString(prefix) 306 } 307 if err := v.Pod.MarshalFastJSON(w); err != nil && firstErr == nil { 308 firstErr = err 309 } 310 } 311 w.RawByte('}') 312 return firstErr 313 } 314 315 func (v *KubernetesNode) MarshalFastJSON(w *fastjson.Writer) error { 316 w.RawByte('{') 317 if v.Name != "" { 318 w.RawString("\"name\":") 319 w.String(v.Name) 320 } 321 w.RawByte('}') 322 return nil 323 } 324 325 func (v *KubernetesPod) MarshalFastJSON(w *fastjson.Writer) error { 326 w.RawByte('{') 327 first := true 328 if v.Name != "" { 329 const prefix = ",\"name\":" 330 if first { 331 first = false 332 w.RawString(prefix[1:]) 333 } else { 334 w.RawString(prefix) 335 } 336 w.String(v.Name) 337 } 338 if v.UID != "" { 339 const prefix = ",\"uid\":" 340 if first { 341 first = false 342 w.RawString(prefix[1:]) 343 } else { 344 w.RawString(prefix) 345 } 346 w.String(v.UID) 347 } 348 w.RawByte('}') 349 return nil 350 } 351 352 func (v *Cloud) MarshalFastJSON(w *fastjson.Writer) error { 353 var firstErr error 354 w.RawByte('{') 355 w.RawString("\"provider\":") 356 w.String(v.Provider) 357 if v.Account != nil { 358 w.RawString(",\"account\":") 359 if err := v.Account.MarshalFastJSON(w); err != nil && firstErr == nil { 360 firstErr = err 361 } 362 } 363 if v.AvailabilityZone != "" { 364 w.RawString(",\"availability_zone\":") 365 w.String(v.AvailabilityZone) 366 } 367 if v.Instance != nil { 368 w.RawString(",\"instance\":") 369 if err := v.Instance.MarshalFastJSON(w); err != nil && firstErr == nil { 370 firstErr = err 371 } 372 } 373 if v.Machine != nil { 374 w.RawString(",\"machine\":") 375 if err := v.Machine.MarshalFastJSON(w); err != nil && firstErr == nil { 376 firstErr = err 377 } 378 } 379 if v.Project != nil { 380 w.RawString(",\"project\":") 381 if err := v.Project.MarshalFastJSON(w); err != nil && firstErr == nil { 382 firstErr = err 383 } 384 } 385 if v.Region != "" { 386 w.RawString(",\"region\":") 387 w.String(v.Region) 388 } 389 w.RawByte('}') 390 return firstErr 391 } 392 393 func (v *CloudInstance) MarshalFastJSON(w *fastjson.Writer) error { 394 w.RawByte('{') 395 first := true 396 if v.ID != "" { 397 const prefix = ",\"id\":" 398 if first { 399 first = false 400 w.RawString(prefix[1:]) 401 } else { 402 w.RawString(prefix) 403 } 404 w.String(v.ID) 405 } 406 if v.Name != "" { 407 const prefix = ",\"name\":" 408 if first { 409 first = false 410 w.RawString(prefix[1:]) 411 } else { 412 w.RawString(prefix) 413 } 414 w.String(v.Name) 415 } 416 w.RawByte('}') 417 return nil 418 } 419 420 func (v *CloudMachine) MarshalFastJSON(w *fastjson.Writer) error { 421 w.RawByte('{') 422 if v.Type != "" { 423 w.RawString("\"type\":") 424 w.String(v.Type) 425 } 426 w.RawByte('}') 427 return nil 428 } 429 430 func (v *CloudAccount) MarshalFastJSON(w *fastjson.Writer) error { 431 w.RawByte('{') 432 first := true 433 if v.ID != "" { 434 const prefix = ",\"id\":" 435 if first { 436 first = false 437 w.RawString(prefix[1:]) 438 } else { 439 w.RawString(prefix) 440 } 441 w.String(v.ID) 442 } 443 if v.Name != "" { 444 const prefix = ",\"name\":" 445 if first { 446 first = false 447 w.RawString(prefix[1:]) 448 } else { 449 w.RawString(prefix) 450 } 451 w.String(v.Name) 452 } 453 w.RawByte('}') 454 return nil 455 } 456 457 func (v *CloudProject) MarshalFastJSON(w *fastjson.Writer) error { 458 w.RawByte('{') 459 first := true 460 if v.ID != "" { 461 const prefix = ",\"id\":" 462 if first { 463 first = false 464 w.RawString(prefix[1:]) 465 } else { 466 w.RawString(prefix) 467 } 468 w.String(v.ID) 469 } 470 if v.Name != "" { 471 const prefix = ",\"name\":" 472 if first { 473 first = false 474 w.RawString(prefix[1:]) 475 } else { 476 w.RawString(prefix) 477 } 478 w.String(v.Name) 479 } 480 w.RawByte('}') 481 return nil 482 } 483 484 func (v *Transaction) MarshalFastJSON(w *fastjson.Writer) error { 485 var firstErr error 486 w.RawByte('{') 487 w.RawString("\"duration\":") 488 w.Float64(v.Duration) 489 w.RawString(",\"id\":") 490 if err := v.ID.MarshalFastJSON(w); err != nil && firstErr == nil { 491 firstErr = err 492 } 493 w.RawString(",\"name\":") 494 w.String(v.Name) 495 w.RawString(",\"span_count\":") 496 if err := v.SpanCount.MarshalFastJSON(w); err != nil && firstErr == nil { 497 firstErr = err 498 } 499 w.RawString(",\"timestamp\":") 500 if err := v.Timestamp.MarshalFastJSON(w); err != nil && firstErr == nil { 501 firstErr = err 502 } 503 w.RawString(",\"trace_id\":") 504 if err := v.TraceID.MarshalFastJSON(w); err != nil && firstErr == nil { 505 firstErr = err 506 } 507 w.RawString(",\"type\":") 508 w.String(v.Type) 509 if v.Context != nil { 510 w.RawString(",\"context\":") 511 if err := v.Context.MarshalFastJSON(w); err != nil && firstErr == nil { 512 firstErr = err 513 } 514 } 515 if v.DroppedSpansStats != nil { 516 w.RawString(",\"dropped_spans_stats\":") 517 w.RawByte('[') 518 for i, v := range v.DroppedSpansStats { 519 if i != 0 { 520 w.RawByte(',') 521 } 522 if err := v.MarshalFastJSON(w); err != nil && firstErr == nil { 523 firstErr = err 524 } 525 } 526 w.RawByte(']') 527 } 528 if v.FAAS != nil { 529 w.RawString(",\"faas\":") 530 if err := v.FAAS.MarshalFastJSON(w); err != nil && firstErr == nil { 531 firstErr = err 532 } 533 } 534 if v.Links != nil { 535 w.RawString(",\"links\":") 536 w.RawByte('[') 537 for i, v := range v.Links { 538 if i != 0 { 539 w.RawByte(',') 540 } 541 if err := v.MarshalFastJSON(w); err != nil && firstErr == nil { 542 firstErr = err 543 } 544 } 545 w.RawByte(']') 546 } 547 if v.OTel != nil { 548 w.RawString(",\"otel\":") 549 if err := v.OTel.MarshalFastJSON(w); err != nil && firstErr == nil { 550 firstErr = err 551 } 552 } 553 if v.Outcome != "" { 554 w.RawString(",\"outcome\":") 555 w.String(v.Outcome) 556 } 557 if !v.ParentID.isZero() { 558 w.RawString(",\"parent_id\":") 559 if err := v.ParentID.MarshalFastJSON(w); err != nil && firstErr == nil { 560 firstErr = err 561 } 562 } 563 if v.Result != "" { 564 w.RawString(",\"result\":") 565 w.String(v.Result) 566 } 567 if v.SampleRate != nil { 568 w.RawString(",\"sample_rate\":") 569 w.Float64(*v.SampleRate) 570 } 571 if v.Sampled != nil { 572 w.RawString(",\"sampled\":") 573 w.Bool(*v.Sampled) 574 } 575 w.RawByte('}') 576 return firstErr 577 } 578 579 func (v *OTel) MarshalFastJSON(w *fastjson.Writer) error { 580 var firstErr error 581 w.RawByte('{') 582 w.RawString("\"span_kind\":") 583 w.String(v.SpanKind) 584 if v.Attributes != nil { 585 w.RawString(",\"attributes\":") 586 w.RawByte('{') 587 { 588 first := true 589 for k, v := range v.Attributes { 590 if first { 591 first = false 592 } else { 593 w.RawByte(',') 594 } 595 w.String(k) 596 w.RawByte(':') 597 if err := fastjson.Marshal(w, v); err != nil && firstErr == nil { 598 firstErr = err 599 } 600 } 601 } 602 w.RawByte('}') 603 } 604 w.RawByte('}') 605 return firstErr 606 } 607 608 func (v *SpanCount) MarshalFastJSON(w *fastjson.Writer) error { 609 w.RawByte('{') 610 w.RawString("\"dropped\":") 611 w.Int64(int64(v.Dropped)) 612 w.RawString(",\"started\":") 613 w.Int64(int64(v.Started)) 614 w.RawByte('}') 615 return nil 616 } 617 618 func (v *DroppedSpansStats) MarshalFastJSON(w *fastjson.Writer) error { 619 var firstErr error 620 w.RawByte('{') 621 w.RawString("\"destination_service_resource\":") 622 w.String(v.DestinationServiceResource) 623 w.RawString(",\"duration\":") 624 if err := v.Duration.MarshalFastJSON(w); err != nil && firstErr == nil { 625 firstErr = err 626 } 627 w.RawString(",\"outcome\":") 628 w.String(v.Outcome) 629 if v.ServiceTargetName != "" { 630 w.RawString(",\"service_target_name\":") 631 w.String(v.ServiceTargetName) 632 } 633 if v.ServiceTargetType != "" { 634 w.RawString(",\"service_target_type\":") 635 w.String(v.ServiceTargetType) 636 } 637 w.RawByte('}') 638 return firstErr 639 } 640 641 func (v *AggregateDuration) MarshalFastJSON(w *fastjson.Writer) error { 642 var firstErr error 643 w.RawByte('{') 644 w.RawString("\"count\":") 645 w.Int64(int64(v.Count)) 646 w.RawString(",\"sum\":") 647 if err := v.Sum.MarshalFastJSON(w); err != nil && firstErr == nil { 648 firstErr = err 649 } 650 w.RawByte('}') 651 return firstErr 652 } 653 654 func (v *DurationSum) MarshalFastJSON(w *fastjson.Writer) error { 655 w.RawByte('{') 656 w.RawString("\"us\":") 657 w.Int64(v.Us) 658 w.RawByte('}') 659 return nil 660 } 661 662 func (v *Span) MarshalFastJSON(w *fastjson.Writer) error { 663 var firstErr error 664 w.RawByte('{') 665 w.RawString("\"duration\":") 666 w.Float64(v.Duration) 667 w.RawString(",\"id\":") 668 if err := v.ID.MarshalFastJSON(w); err != nil && firstErr == nil { 669 firstErr = err 670 } 671 w.RawString(",\"name\":") 672 w.String(v.Name) 673 w.RawString(",\"timestamp\":") 674 if err := v.Timestamp.MarshalFastJSON(w); err != nil && firstErr == nil { 675 firstErr = err 676 } 677 w.RawString(",\"trace_id\":") 678 if err := v.TraceID.MarshalFastJSON(w); err != nil && firstErr == nil { 679 firstErr = err 680 } 681 w.RawString(",\"type\":") 682 w.String(v.Type) 683 if v.Action != "" { 684 w.RawString(",\"action\":") 685 w.String(v.Action) 686 } 687 if v.Composite != nil { 688 w.RawString(",\"composite\":") 689 if err := v.Composite.MarshalFastJSON(w); err != nil && firstErr == nil { 690 firstErr = err 691 } 692 } 693 if v.Context != nil { 694 w.RawString(",\"context\":") 695 if err := v.Context.MarshalFastJSON(w); err != nil && firstErr == nil { 696 firstErr = err 697 } 698 } 699 if v.Links != nil { 700 w.RawString(",\"links\":") 701 w.RawByte('[') 702 for i, v := range v.Links { 703 if i != 0 { 704 w.RawByte(',') 705 } 706 if err := v.MarshalFastJSON(w); err != nil && firstErr == nil { 707 firstErr = err 708 } 709 } 710 w.RawByte(']') 711 } 712 if v.OTel != nil { 713 w.RawString(",\"otel\":") 714 if err := v.OTel.MarshalFastJSON(w); err != nil && firstErr == nil { 715 firstErr = err 716 } 717 } 718 if v.Outcome != "" { 719 w.RawString(",\"outcome\":") 720 w.String(v.Outcome) 721 } 722 if !v.ParentID.isZero() { 723 w.RawString(",\"parent_id\":") 724 if err := v.ParentID.MarshalFastJSON(w); err != nil && firstErr == nil { 725 firstErr = err 726 } 727 } 728 if v.SampleRate != nil { 729 w.RawString(",\"sample_rate\":") 730 w.Float64(*v.SampleRate) 731 } 732 if v.Stacktrace != nil { 733 w.RawString(",\"stacktrace\":") 734 w.RawByte('[') 735 for i, v := range v.Stacktrace { 736 if i != 0 { 737 w.RawByte(',') 738 } 739 if err := v.MarshalFastJSON(w); err != nil && firstErr == nil { 740 firstErr = err 741 } 742 } 743 w.RawByte(']') 744 } 745 if v.Subtype != "" { 746 w.RawString(",\"subtype\":") 747 w.String(v.Subtype) 748 } 749 if !v.TransactionID.isZero() { 750 w.RawString(",\"transaction_id\":") 751 if err := v.TransactionID.MarshalFastJSON(w); err != nil && firstErr == nil { 752 firstErr = err 753 } 754 } 755 w.RawByte('}') 756 return firstErr 757 } 758 759 func (v *SpanContext) MarshalFastJSON(w *fastjson.Writer) error { 760 var firstErr error 761 w.RawByte('{') 762 first := true 763 if v.Database != nil { 764 const prefix = ",\"db\":" 765 if first { 766 first = false 767 w.RawString(prefix[1:]) 768 } else { 769 w.RawString(prefix) 770 } 771 if err := v.Database.MarshalFastJSON(w); err != nil && firstErr == nil { 772 firstErr = err 773 } 774 } 775 if v.Destination != nil { 776 const prefix = ",\"destination\":" 777 if first { 778 first = false 779 w.RawString(prefix[1:]) 780 } else { 781 w.RawString(prefix) 782 } 783 if err := v.Destination.MarshalFastJSON(w); err != nil && firstErr == nil { 784 firstErr = err 785 } 786 } 787 if v.HTTP != nil { 788 const prefix = ",\"http\":" 789 if first { 790 first = false 791 w.RawString(prefix[1:]) 792 } else { 793 w.RawString(prefix) 794 } 795 if err := v.HTTP.MarshalFastJSON(w); err != nil && firstErr == nil { 796 firstErr = err 797 } 798 } 799 if v.Message != nil { 800 const prefix = ",\"message\":" 801 if first { 802 first = false 803 w.RawString(prefix[1:]) 804 } else { 805 w.RawString(prefix) 806 } 807 if err := v.Message.MarshalFastJSON(w); err != nil && firstErr == nil { 808 firstErr = err 809 } 810 } 811 if v.Service != nil { 812 const prefix = ",\"service\":" 813 if first { 814 first = false 815 w.RawString(prefix[1:]) 816 } else { 817 w.RawString(prefix) 818 } 819 if err := v.Service.MarshalFastJSON(w); err != nil && firstErr == nil { 820 firstErr = err 821 } 822 } 823 if !v.Tags.isZero() { 824 const prefix = ",\"tags\":" 825 if first { 826 first = false 827 w.RawString(prefix[1:]) 828 } else { 829 w.RawString(prefix) 830 } 831 if err := v.Tags.MarshalFastJSON(w); err != nil && firstErr == nil { 832 firstErr = err 833 } 834 } 835 w.RawByte('}') 836 return firstErr 837 } 838 839 func (v *SpanLink) MarshalFastJSON(w *fastjson.Writer) error { 840 var firstErr error 841 w.RawByte('{') 842 w.RawString("\"span_id\":") 843 if err := v.SpanID.MarshalFastJSON(w); err != nil && firstErr == nil { 844 firstErr = err 845 } 846 w.RawString(",\"trace_id\":") 847 if err := v.TraceID.MarshalFastJSON(w); err != nil && firstErr == nil { 848 firstErr = err 849 } 850 w.RawByte('}') 851 return firstErr 852 } 853 854 func (v *DestinationSpanContext) MarshalFastJSON(w *fastjson.Writer) error { 855 var firstErr error 856 w.RawByte('{') 857 first := true 858 if v.Address != "" { 859 const prefix = ",\"address\":" 860 if first { 861 first = false 862 w.RawString(prefix[1:]) 863 } else { 864 w.RawString(prefix) 865 } 866 w.String(v.Address) 867 } 868 if v.Cloud != nil { 869 const prefix = ",\"cloud\":" 870 if first { 871 first = false 872 w.RawString(prefix[1:]) 873 } else { 874 w.RawString(prefix) 875 } 876 if err := v.Cloud.MarshalFastJSON(w); err != nil && firstErr == nil { 877 firstErr = err 878 } 879 } 880 if v.Port != 0 { 881 const prefix = ",\"port\":" 882 if first { 883 first = false 884 w.RawString(prefix[1:]) 885 } else { 886 w.RawString(prefix) 887 } 888 w.Int64(int64(v.Port)) 889 } 890 if v.Service != nil { 891 const prefix = ",\"service\":" 892 if first { 893 first = false 894 w.RawString(prefix[1:]) 895 } else { 896 w.RawString(prefix) 897 } 898 if err := v.Service.MarshalFastJSON(w); err != nil && firstErr == nil { 899 firstErr = err 900 } 901 } 902 w.RawByte('}') 903 return firstErr 904 } 905 906 func (v *ServiceSpanContext) MarshalFastJSON(w *fastjson.Writer) error { 907 var firstErr error 908 w.RawByte('{') 909 if v.Target != nil { 910 w.RawString("\"target\":") 911 if err := v.Target.MarshalFastJSON(w); err != nil && firstErr == nil { 912 firstErr = err 913 } 914 } 915 w.RawByte('}') 916 return firstErr 917 } 918 919 func (v *ServiceTargetSpanContext) MarshalFastJSON(w *fastjson.Writer) error { 920 w.RawByte('{') 921 w.RawString("\"name\":") 922 w.String(v.Name) 923 if v.Type != "" { 924 w.RawString(",\"type\":") 925 w.String(v.Type) 926 } 927 w.RawByte('}') 928 return nil 929 } 930 931 func (v *DestinationServiceSpanContext) MarshalFastJSON(w *fastjson.Writer) error { 932 w.RawByte('{') 933 w.RawString("\"name\":") 934 w.String(v.Name) 935 if v.Resource != "" { 936 w.RawString(",\"resource\":") 937 w.String(v.Resource) 938 } 939 if v.Type != "" { 940 w.RawString(",\"type\":") 941 w.String(v.Type) 942 } 943 w.RawByte('}') 944 return nil 945 } 946 947 func (v *DestinationCloudSpanContext) MarshalFastJSON(w *fastjson.Writer) error { 948 w.RawByte('{') 949 if v.Region != "" { 950 w.RawString("\"region\":") 951 w.String(v.Region) 952 } 953 w.RawByte('}') 954 return nil 955 } 956 957 func (v *MessageSpanContext) MarshalFastJSON(w *fastjson.Writer) error { 958 var firstErr error 959 w.RawByte('{') 960 if v.Queue != nil { 961 w.RawString("\"queue\":") 962 if err := v.Queue.MarshalFastJSON(w); err != nil && firstErr == nil { 963 firstErr = err 964 } 965 } 966 w.RawByte('}') 967 return firstErr 968 } 969 970 func (v *MessageQueueSpanContext) MarshalFastJSON(w *fastjson.Writer) error { 971 w.RawByte('{') 972 if v.Name != "" { 973 w.RawString("\"name\":") 974 w.String(v.Name) 975 } 976 w.RawByte('}') 977 return nil 978 } 979 980 func (v *DatabaseSpanContext) MarshalFastJSON(w *fastjson.Writer) error { 981 w.RawByte('{') 982 first := true 983 if v.Instance != "" { 984 const prefix = ",\"instance\":" 985 if first { 986 first = false 987 w.RawString(prefix[1:]) 988 } else { 989 w.RawString(prefix) 990 } 991 w.String(v.Instance) 992 } 993 if v.RowsAffected != nil { 994 const prefix = ",\"rows_affected\":" 995 if first { 996 first = false 997 w.RawString(prefix[1:]) 998 } else { 999 w.RawString(prefix) 1000 } 1001 w.Int64(*v.RowsAffected) 1002 } 1003 if v.Statement != "" { 1004 const prefix = ",\"statement\":" 1005 if first { 1006 first = false 1007 w.RawString(prefix[1:]) 1008 } else { 1009 w.RawString(prefix) 1010 } 1011 w.String(v.Statement) 1012 } 1013 if v.Type != "" { 1014 const prefix = ",\"type\":" 1015 if first { 1016 first = false 1017 w.RawString(prefix[1:]) 1018 } else { 1019 w.RawString(prefix) 1020 } 1021 w.String(v.Type) 1022 } 1023 if v.User != "" { 1024 const prefix = ",\"user\":" 1025 if first { 1026 first = false 1027 w.RawString(prefix[1:]) 1028 } else { 1029 w.RawString(prefix) 1030 } 1031 w.String(v.User) 1032 } 1033 w.RawByte('}') 1034 return nil 1035 } 1036 1037 func (v *CompositeSpan) MarshalFastJSON(w *fastjson.Writer) error { 1038 w.RawByte('{') 1039 w.RawString("\"compression_strategy\":") 1040 w.String(v.CompressionStrategy) 1041 w.RawString(",\"count\":") 1042 w.Int64(int64(v.Count)) 1043 w.RawString(",\"sum\":") 1044 w.Float64(v.Sum) 1045 w.RawByte('}') 1046 return nil 1047 } 1048 1049 func (v *Context) MarshalFastJSON(w *fastjson.Writer) error { 1050 var firstErr error 1051 w.RawByte('{') 1052 first := true 1053 if !v.Custom.isZero() { 1054 const prefix = ",\"custom\":" 1055 if first { 1056 first = false 1057 w.RawString(prefix[1:]) 1058 } else { 1059 w.RawString(prefix) 1060 } 1061 if err := v.Custom.MarshalFastJSON(w); err != nil && firstErr == nil { 1062 firstErr = err 1063 } 1064 } 1065 if v.Request != nil { 1066 const prefix = ",\"request\":" 1067 if first { 1068 first = false 1069 w.RawString(prefix[1:]) 1070 } else { 1071 w.RawString(prefix) 1072 } 1073 if err := v.Request.MarshalFastJSON(w); err != nil && firstErr == nil { 1074 firstErr = err 1075 } 1076 } 1077 if v.Response != nil { 1078 const prefix = ",\"response\":" 1079 if first { 1080 first = false 1081 w.RawString(prefix[1:]) 1082 } else { 1083 w.RawString(prefix) 1084 } 1085 if err := v.Response.MarshalFastJSON(w); err != nil && firstErr == nil { 1086 firstErr = err 1087 } 1088 } 1089 if v.Service != nil { 1090 const prefix = ",\"service\":" 1091 if first { 1092 first = false 1093 w.RawString(prefix[1:]) 1094 } else { 1095 w.RawString(prefix) 1096 } 1097 if err := v.Service.MarshalFastJSON(w); err != nil && firstErr == nil { 1098 firstErr = err 1099 } 1100 } 1101 if !v.Tags.isZero() { 1102 const prefix = ",\"tags\":" 1103 if first { 1104 first = false 1105 w.RawString(prefix[1:]) 1106 } else { 1107 w.RawString(prefix) 1108 } 1109 if err := v.Tags.MarshalFastJSON(w); err != nil && firstErr == nil { 1110 firstErr = err 1111 } 1112 } 1113 if v.User != nil { 1114 const prefix = ",\"user\":" 1115 if first { 1116 first = false 1117 w.RawString(prefix[1:]) 1118 } else { 1119 w.RawString(prefix) 1120 } 1121 if err := v.User.MarshalFastJSON(w); err != nil && firstErr == nil { 1122 firstErr = err 1123 } 1124 } 1125 w.RawByte('}') 1126 return firstErr 1127 } 1128 1129 func (v *User) MarshalFastJSON(w *fastjson.Writer) error { 1130 w.RawByte('{') 1131 first := true 1132 if v.Email != "" { 1133 const prefix = ",\"email\":" 1134 if first { 1135 first = false 1136 w.RawString(prefix[1:]) 1137 } else { 1138 w.RawString(prefix) 1139 } 1140 w.String(v.Email) 1141 } 1142 if v.ID != "" { 1143 const prefix = ",\"id\":" 1144 if first { 1145 first = false 1146 w.RawString(prefix[1:]) 1147 } else { 1148 w.RawString(prefix) 1149 } 1150 w.String(v.ID) 1151 } 1152 if v.Username != "" { 1153 const prefix = ",\"username\":" 1154 if first { 1155 first = false 1156 w.RawString(prefix[1:]) 1157 } else { 1158 w.RawString(prefix) 1159 } 1160 w.String(v.Username) 1161 } 1162 w.RawByte('}') 1163 return nil 1164 } 1165 1166 func (v *Error) MarshalFastJSON(w *fastjson.Writer) error { 1167 var firstErr error 1168 w.RawByte('{') 1169 w.RawString("\"id\":") 1170 if err := v.ID.MarshalFastJSON(w); err != nil && firstErr == nil { 1171 firstErr = err 1172 } 1173 w.RawString(",\"timestamp\":") 1174 if err := v.Timestamp.MarshalFastJSON(w); err != nil && firstErr == nil { 1175 firstErr = err 1176 } 1177 if v.Context != nil { 1178 w.RawString(",\"context\":") 1179 if err := v.Context.MarshalFastJSON(w); err != nil && firstErr == nil { 1180 firstErr = err 1181 } 1182 } 1183 if v.Culprit != "" { 1184 w.RawString(",\"culprit\":") 1185 w.String(v.Culprit) 1186 } 1187 if !v.Exception.isZero() { 1188 w.RawString(",\"exception\":") 1189 if err := v.Exception.MarshalFastJSON(w); err != nil && firstErr == nil { 1190 firstErr = err 1191 } 1192 } 1193 if !v.Log.isZero() { 1194 w.RawString(",\"log\":") 1195 if err := v.Log.MarshalFastJSON(w); err != nil && firstErr == nil { 1196 firstErr = err 1197 } 1198 } 1199 if !v.ParentID.isZero() { 1200 w.RawString(",\"parent_id\":") 1201 if err := v.ParentID.MarshalFastJSON(w); err != nil && firstErr == nil { 1202 firstErr = err 1203 } 1204 } 1205 if !v.TraceID.isZero() { 1206 w.RawString(",\"trace_id\":") 1207 if err := v.TraceID.MarshalFastJSON(w); err != nil && firstErr == nil { 1208 firstErr = err 1209 } 1210 } 1211 if !v.Transaction.isZero() { 1212 w.RawString(",\"transaction\":") 1213 if err := v.Transaction.MarshalFastJSON(w); err != nil && firstErr == nil { 1214 firstErr = err 1215 } 1216 } 1217 if !v.TransactionID.isZero() { 1218 w.RawString(",\"transaction_id\":") 1219 if err := v.TransactionID.MarshalFastJSON(w); err != nil && firstErr == nil { 1220 firstErr = err 1221 } 1222 } 1223 w.RawByte('}') 1224 return firstErr 1225 } 1226 1227 func (v *ErrorTransaction) MarshalFastJSON(w *fastjson.Writer) error { 1228 w.RawByte('{') 1229 first := true 1230 if v.Name != "" { 1231 const prefix = ",\"name\":" 1232 if first { 1233 first = false 1234 w.RawString(prefix[1:]) 1235 } else { 1236 w.RawString(prefix) 1237 } 1238 w.String(v.Name) 1239 } 1240 if v.Sampled != nil { 1241 const prefix = ",\"sampled\":" 1242 if first { 1243 first = false 1244 w.RawString(prefix[1:]) 1245 } else { 1246 w.RawString(prefix) 1247 } 1248 w.Bool(*v.Sampled) 1249 } 1250 if v.Type != "" { 1251 const prefix = ",\"type\":" 1252 if first { 1253 first = false 1254 w.RawString(prefix[1:]) 1255 } else { 1256 w.RawString(prefix) 1257 } 1258 w.String(v.Type) 1259 } 1260 w.RawByte('}') 1261 return nil 1262 } 1263 1264 func (v *Exception) MarshalFastJSON(w *fastjson.Writer) error { 1265 var firstErr error 1266 w.RawByte('{') 1267 w.RawString("\"handled\":") 1268 w.Bool(v.Handled) 1269 w.RawString(",\"message\":") 1270 w.String(v.Message) 1271 if v.Attributes != nil { 1272 w.RawString(",\"attributes\":") 1273 w.RawByte('{') 1274 { 1275 first := true 1276 for k, v := range v.Attributes { 1277 if first { 1278 first = false 1279 } else { 1280 w.RawByte(',') 1281 } 1282 w.String(k) 1283 w.RawByte(':') 1284 if err := fastjson.Marshal(w, v); err != nil && firstErr == nil { 1285 firstErr = err 1286 } 1287 } 1288 } 1289 w.RawByte('}') 1290 } 1291 if v.Cause != nil { 1292 w.RawString(",\"cause\":") 1293 w.RawByte('[') 1294 for i, v := range v.Cause { 1295 if i != 0 { 1296 w.RawByte(',') 1297 } 1298 if err := v.MarshalFastJSON(w); err != nil && firstErr == nil { 1299 firstErr = err 1300 } 1301 } 1302 w.RawByte(']') 1303 } 1304 if !v.Code.isZero() { 1305 w.RawString(",\"code\":") 1306 if err := v.Code.MarshalFastJSON(w); err != nil && firstErr == nil { 1307 firstErr = err 1308 } 1309 } 1310 if v.Module != "" { 1311 w.RawString(",\"module\":") 1312 w.String(v.Module) 1313 } 1314 if v.Stacktrace != nil { 1315 w.RawString(",\"stacktrace\":") 1316 w.RawByte('[') 1317 for i, v := range v.Stacktrace { 1318 if i != 0 { 1319 w.RawByte(',') 1320 } 1321 if err := v.MarshalFastJSON(w); err != nil && firstErr == nil { 1322 firstErr = err 1323 } 1324 } 1325 w.RawByte(']') 1326 } 1327 if v.Type != "" { 1328 w.RawString(",\"type\":") 1329 w.String(v.Type) 1330 } 1331 w.RawByte('}') 1332 return firstErr 1333 } 1334 1335 func (v *StacktraceFrame) MarshalFastJSON(w *fastjson.Writer) error { 1336 var firstErr error 1337 w.RawByte('{') 1338 w.RawString("\"filename\":") 1339 w.String(v.File) 1340 w.RawString(",\"lineno\":") 1341 w.Int64(int64(v.Line)) 1342 if v.AbsolutePath != "" { 1343 w.RawString(",\"abs_path\":") 1344 w.String(v.AbsolutePath) 1345 } 1346 if v.Classname != "" { 1347 w.RawString(",\"classname\":") 1348 w.String(v.Classname) 1349 } 1350 if v.Column != nil { 1351 w.RawString(",\"colno\":") 1352 w.Int64(int64(*v.Column)) 1353 } 1354 if v.ContextLine != "" { 1355 w.RawString(",\"context_line\":") 1356 w.String(v.ContextLine) 1357 } 1358 if v.Function != "" { 1359 w.RawString(",\"function\":") 1360 w.String(v.Function) 1361 } 1362 if v.LibraryFrame != false { 1363 w.RawString(",\"library_frame\":") 1364 w.Bool(v.LibraryFrame) 1365 } 1366 if v.Module != "" { 1367 w.RawString(",\"module\":") 1368 w.String(v.Module) 1369 } 1370 if v.PostContext != nil { 1371 w.RawString(",\"post_context\":") 1372 w.RawByte('[') 1373 for i, v := range v.PostContext { 1374 if i != 0 { 1375 w.RawByte(',') 1376 } 1377 w.String(v) 1378 } 1379 w.RawByte(']') 1380 } 1381 if v.PreContext != nil { 1382 w.RawString(",\"pre_context\":") 1383 w.RawByte('[') 1384 for i, v := range v.PreContext { 1385 if i != 0 { 1386 w.RawByte(',') 1387 } 1388 w.String(v) 1389 } 1390 w.RawByte(']') 1391 } 1392 if v.Vars != nil { 1393 w.RawString(",\"vars\":") 1394 w.RawByte('{') 1395 { 1396 first := true 1397 for k, v := range v.Vars { 1398 if first { 1399 first = false 1400 } else { 1401 w.RawByte(',') 1402 } 1403 w.String(k) 1404 w.RawByte(':') 1405 if err := fastjson.Marshal(w, v); err != nil && firstErr == nil { 1406 firstErr = err 1407 } 1408 } 1409 } 1410 w.RawByte('}') 1411 } 1412 w.RawByte('}') 1413 return firstErr 1414 } 1415 1416 func (v *Log) MarshalFastJSON(w *fastjson.Writer) error { 1417 var firstErr error 1418 w.RawByte('{') 1419 w.RawString("\"message\":") 1420 w.String(v.Message) 1421 if v.Level != "" { 1422 w.RawString(",\"level\":") 1423 w.String(v.Level) 1424 } 1425 if v.LoggerName != "" { 1426 w.RawString(",\"logger_name\":") 1427 w.String(v.LoggerName) 1428 } 1429 if v.ParamMessage != "" { 1430 w.RawString(",\"param_message\":") 1431 w.String(v.ParamMessage) 1432 } 1433 if v.Stacktrace != nil { 1434 w.RawString(",\"stacktrace\":") 1435 w.RawByte('[') 1436 for i, v := range v.Stacktrace { 1437 if i != 0 { 1438 w.RawByte(',') 1439 } 1440 if err := v.MarshalFastJSON(w); err != nil && firstErr == nil { 1441 firstErr = err 1442 } 1443 } 1444 w.RawByte(']') 1445 } 1446 w.RawByte('}') 1447 return firstErr 1448 } 1449 1450 func (v *Request) MarshalFastJSON(w *fastjson.Writer) error { 1451 var firstErr error 1452 w.RawByte('{') 1453 w.RawString("\"method\":") 1454 w.String(v.Method) 1455 w.RawString(",\"url\":") 1456 if err := v.URL.MarshalFastJSON(w); err != nil && firstErr == nil { 1457 firstErr = err 1458 } 1459 if v.Body != nil { 1460 w.RawString(",\"body\":") 1461 if err := v.Body.MarshalFastJSON(w); err != nil && firstErr == nil { 1462 firstErr = err 1463 } 1464 } 1465 if !v.Cookies.isZero() { 1466 w.RawString(",\"cookies\":") 1467 if err := v.Cookies.MarshalFastJSON(w); err != nil && firstErr == nil { 1468 firstErr = err 1469 } 1470 } 1471 if v.Env != nil { 1472 w.RawString(",\"env\":") 1473 w.RawByte('{') 1474 { 1475 first := true 1476 for k, v := range v.Env { 1477 if first { 1478 first = false 1479 } else { 1480 w.RawByte(',') 1481 } 1482 w.String(k) 1483 w.RawByte(':') 1484 w.String(v) 1485 } 1486 } 1487 w.RawByte('}') 1488 } 1489 if !v.Headers.isZero() { 1490 w.RawString(",\"headers\":") 1491 if err := v.Headers.MarshalFastJSON(w); err != nil && firstErr == nil { 1492 firstErr = err 1493 } 1494 } 1495 if v.HTTPVersion != "" { 1496 w.RawString(",\"http_version\":") 1497 w.String(v.HTTPVersion) 1498 } 1499 if v.Socket != nil { 1500 w.RawString(",\"socket\":") 1501 if err := v.Socket.MarshalFastJSON(w); err != nil && firstErr == nil { 1502 firstErr = err 1503 } 1504 } 1505 w.RawByte('}') 1506 return firstErr 1507 } 1508 1509 func (v *RequestSocket) MarshalFastJSON(w *fastjson.Writer) error { 1510 w.RawByte('{') 1511 first := true 1512 if v.Encrypted != false { 1513 const prefix = ",\"encrypted\":" 1514 if first { 1515 first = false 1516 w.RawString(prefix[1:]) 1517 } else { 1518 w.RawString(prefix) 1519 } 1520 w.Bool(v.Encrypted) 1521 } 1522 if v.RemoteAddress != "" { 1523 const prefix = ",\"remote_address\":" 1524 if first { 1525 first = false 1526 w.RawString(prefix[1:]) 1527 } else { 1528 w.RawString(prefix) 1529 } 1530 w.String(v.RemoteAddress) 1531 } 1532 w.RawByte('}') 1533 return nil 1534 } 1535 1536 func (v *Response) MarshalFastJSON(w *fastjson.Writer) error { 1537 var firstErr error 1538 w.RawByte('{') 1539 first := true 1540 if v.Finished != nil { 1541 const prefix = ",\"finished\":" 1542 if first { 1543 first = false 1544 w.RawString(prefix[1:]) 1545 } else { 1546 w.RawString(prefix) 1547 } 1548 w.Bool(*v.Finished) 1549 } 1550 if !v.Headers.isZero() { 1551 const prefix = ",\"headers\":" 1552 if first { 1553 first = false 1554 w.RawString(prefix[1:]) 1555 } else { 1556 w.RawString(prefix) 1557 } 1558 if err := v.Headers.MarshalFastJSON(w); err != nil && firstErr == nil { 1559 firstErr = err 1560 } 1561 } 1562 if v.HeadersSent != nil { 1563 const prefix = ",\"headers_sent\":" 1564 if first { 1565 first = false 1566 w.RawString(prefix[1:]) 1567 } else { 1568 w.RawString(prefix) 1569 } 1570 w.Bool(*v.HeadersSent) 1571 } 1572 if v.StatusCode != 0 { 1573 const prefix = ",\"status_code\":" 1574 if first { 1575 first = false 1576 w.RawString(prefix[1:]) 1577 } else { 1578 w.RawString(prefix) 1579 } 1580 w.Int64(int64(v.StatusCode)) 1581 } 1582 w.RawByte('}') 1583 return firstErr 1584 } 1585 1586 func (v *Metrics) MarshalFastJSON(w *fastjson.Writer) error { 1587 var firstErr error 1588 w.RawByte('{') 1589 w.RawString("\"samples\":") 1590 if v.Samples == nil { 1591 w.RawString("null") 1592 } else { 1593 w.RawByte('{') 1594 { 1595 first := true 1596 for k, v := range v.Samples { 1597 if first { 1598 first = false 1599 } else { 1600 w.RawByte(',') 1601 } 1602 w.String(k) 1603 w.RawByte(':') 1604 if err := v.MarshalFastJSON(w); err != nil && firstErr == nil { 1605 firstErr = err 1606 } 1607 } 1608 } 1609 w.RawByte('}') 1610 } 1611 w.RawString(",\"timestamp\":") 1612 if err := v.Timestamp.MarshalFastJSON(w); err != nil && firstErr == nil { 1613 firstErr = err 1614 } 1615 if v.FAAS != nil { 1616 w.RawString(",\"faas\":") 1617 if err := v.FAAS.MarshalFastJSON(w); err != nil && firstErr == nil { 1618 firstErr = err 1619 } 1620 } 1621 if !v.Span.isZero() { 1622 w.RawString(",\"span\":") 1623 if err := v.Span.MarshalFastJSON(w); err != nil && firstErr == nil { 1624 firstErr = err 1625 } 1626 } 1627 if !v.Labels.isZero() { 1628 w.RawString(",\"tags\":") 1629 if err := v.Labels.MarshalFastJSON(w); err != nil && firstErr == nil { 1630 firstErr = err 1631 } 1632 } 1633 if !v.Transaction.isZero() { 1634 w.RawString(",\"transaction\":") 1635 if err := v.Transaction.MarshalFastJSON(w); err != nil && firstErr == nil { 1636 firstErr = err 1637 } 1638 } 1639 w.RawByte('}') 1640 return firstErr 1641 } 1642 1643 func (v *MetricsTransaction) MarshalFastJSON(w *fastjson.Writer) error { 1644 w.RawByte('{') 1645 first := true 1646 if v.Name != "" { 1647 const prefix = ",\"name\":" 1648 if first { 1649 first = false 1650 w.RawString(prefix[1:]) 1651 } else { 1652 w.RawString(prefix) 1653 } 1654 w.String(v.Name) 1655 } 1656 if v.Type != "" { 1657 const prefix = ",\"type\":" 1658 if first { 1659 first = false 1660 w.RawString(prefix[1:]) 1661 } else { 1662 w.RawString(prefix) 1663 } 1664 w.String(v.Type) 1665 } 1666 w.RawByte('}') 1667 return nil 1668 } 1669 1670 func (v *MetricsSpan) MarshalFastJSON(w *fastjson.Writer) error { 1671 w.RawByte('{') 1672 first := true 1673 if v.Subtype != "" { 1674 const prefix = ",\"subtype\":" 1675 if first { 1676 first = false 1677 w.RawString(prefix[1:]) 1678 } else { 1679 w.RawString(prefix) 1680 } 1681 w.String(v.Subtype) 1682 } 1683 if v.Type != "" { 1684 const prefix = ",\"type\":" 1685 if first { 1686 first = false 1687 w.RawString(prefix[1:]) 1688 } else { 1689 w.RawString(prefix) 1690 } 1691 w.String(v.Type) 1692 } 1693 w.RawByte('}') 1694 return nil 1695 } 1696 1697 func (v *FAAS) MarshalFastJSON(w *fastjson.Writer) error { 1698 var firstErr error 1699 w.RawByte('{') 1700 w.RawString("\"coldstart\":") 1701 w.Bool(v.Coldstart) 1702 if v.Execution != "" { 1703 w.RawString(",\"execution\":") 1704 w.String(v.Execution) 1705 } 1706 if v.ID != "" { 1707 w.RawString(",\"id\":") 1708 w.String(v.ID) 1709 } 1710 if v.Name != "" { 1711 w.RawString(",\"name\":") 1712 w.String(v.Name) 1713 } 1714 if v.Trigger != nil { 1715 w.RawString(",\"trigger\":") 1716 if err := v.Trigger.MarshalFastJSON(w); err != nil && firstErr == nil { 1717 firstErr = err 1718 } 1719 } 1720 if v.Version != "" { 1721 w.RawString(",\"version\":") 1722 w.String(v.Version) 1723 } 1724 w.RawByte('}') 1725 return firstErr 1726 } 1727 1728 func (v *FAASTrigger) MarshalFastJSON(w *fastjson.Writer) error { 1729 w.RawByte('{') 1730 first := true 1731 if v.RequestID != "" { 1732 const prefix = ",\"request_id\":" 1733 if first { 1734 first = false 1735 w.RawString(prefix[1:]) 1736 } else { 1737 w.RawString(prefix) 1738 } 1739 w.String(v.RequestID) 1740 } 1741 if v.Type != "" { 1742 const prefix = ",\"type\":" 1743 if first { 1744 first = false 1745 w.RawString(prefix[1:]) 1746 } else { 1747 w.RawString(prefix) 1748 } 1749 w.String(v.Type) 1750 } 1751 w.RawByte('}') 1752 return nil 1753 }