/
generated_metrics.go
2491 lines (2198 loc) · 85.5 KB
/
generated_metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by "cmd/pdatagen/main.go". DO NOT EDIT.
// To regenerate this file run "go run cmd/pdatagen/main.go".
package pdata
import (
otlpmetrics "go.opentelemetry.io/collector/internal/data/protogen/metrics/v1"
)
// ResourceMetricsSlice logically represents a slice of ResourceMetrics.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewResourceMetricsSlice function to create new instances.
// Important: zero-initialized instance is not valid for use.
type ResourceMetricsSlice struct {
// orig points to the slice otlpmetrics.ResourceMetrics field contained somewhere else.
// We use pointer-to-slice to be able to modify it in functions like Resize.
orig *[]*otlpmetrics.ResourceMetrics
}
func newResourceMetricsSlice(orig *[]*otlpmetrics.ResourceMetrics) ResourceMetricsSlice {
return ResourceMetricsSlice{orig}
}
// NewResourceMetricsSlice creates a ResourceMetricsSlice with 0 elements.
// Can use "Resize" to initialize with a given length.
func NewResourceMetricsSlice() ResourceMetricsSlice {
orig := []*otlpmetrics.ResourceMetrics(nil)
return ResourceMetricsSlice{&orig}
}
// Len returns the number of elements in the slice.
//
// Returns "0" for a newly instance created with "NewResourceMetricsSlice()".
func (es ResourceMetricsSlice) Len() int {
return len(*es.orig)
}
// At returns the element at the given index.
//
// This function is used mostly for iterating over all the values in the slice:
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// ... // Do something with the element
// }
func (es ResourceMetricsSlice) At(ix int) ResourceMetrics {
return newResourceMetrics((*es.orig)[ix])
}
// MoveAndAppendTo moves all elements from the current slice and appends them to the dest.
// The current slice will be cleared.
func (es ResourceMetricsSlice) MoveAndAppendTo(dest ResourceMetricsSlice) {
if *dest.orig == nil {
// We can simply move the entire vector and avoid any allocations.
*dest.orig = *es.orig
} else {
*dest.orig = append(*dest.orig, *es.orig...)
}
*es.orig = nil
}
// CopyTo copies all elements from the current slice to the dest.
func (es ResourceMetricsSlice) CopyTo(dest ResourceMetricsSlice) {
srcLen := es.Len()
destCap := cap(*dest.orig)
if srcLen <= destCap {
(*dest.orig) = (*dest.orig)[:srcLen:destCap]
for i := range *es.orig {
newResourceMetrics((*es.orig)[i]).CopyTo(newResourceMetrics((*dest.orig)[i]))
}
return
}
origs := make([]otlpmetrics.ResourceMetrics, srcLen)
wrappers := make([]*otlpmetrics.ResourceMetrics, srcLen)
for i := range *es.orig {
wrappers[i] = &origs[i]
newResourceMetrics((*es.orig)[i]).CopyTo(newResourceMetrics(wrappers[i]))
}
*dest.orig = wrappers
}
// Resize is an operation that resizes the slice:
// 1. If the newLen <= len then equivalent with slice[0:newLen:cap].
// 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice.
//
// Here is how a new ResourceMetricsSlice can be initialized:
// es := NewResourceMetricsSlice()
// es.Resize(4)
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// // Here should set all the values for e.
// }
func (es ResourceMetricsSlice) Resize(newLen int) {
oldLen := len(*es.orig)
oldCap := cap(*es.orig)
if newLen <= oldLen {
*es.orig = (*es.orig)[:newLen:oldCap]
return
}
if newLen > oldCap {
newOrig := make([]*otlpmetrics.ResourceMetrics, oldLen, newLen)
copy(newOrig, *es.orig)
*es.orig = newOrig
}
// Add extra empty elements to the array.
extraOrigs := make([]otlpmetrics.ResourceMetrics, newLen-oldLen)
for i := range extraOrigs {
*es.orig = append(*es.orig, &extraOrigs[i])
}
}
// Append will increase the length of the ResourceMetricsSlice by one and set the
// given ResourceMetrics at that new position. The original ResourceMetrics
// could still be referenced so do not reuse it after passing it to this
// method.
func (es ResourceMetricsSlice) Append(e ResourceMetrics) {
*es.orig = append(*es.orig, e.orig)
}
// InstrumentationLibraryMetrics is a collection of metrics from a LibraryInstrumentation.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewResourceMetrics function to create new instances.
// Important: zero-initialized instance is not valid for use.
type ResourceMetrics struct {
orig *otlpmetrics.ResourceMetrics
}
func newResourceMetrics(orig *otlpmetrics.ResourceMetrics) ResourceMetrics {
return ResourceMetrics{orig: orig}
}
// NewResourceMetrics creates a new empty ResourceMetrics.
//
// This must be used only in testing code since no "Set" method available.
func NewResourceMetrics() ResourceMetrics {
return newResourceMetrics(&otlpmetrics.ResourceMetrics{})
}
// Resource returns the resource associated with this ResourceMetrics.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms ResourceMetrics) Resource() Resource {
return newResource(&(*ms.orig).Resource)
}
// InstrumentationLibraryMetrics returns the InstrumentationLibraryMetrics associated with this ResourceMetrics.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms ResourceMetrics) InstrumentationLibraryMetrics() InstrumentationLibraryMetricsSlice {
return newInstrumentationLibraryMetricsSlice(&(*ms.orig).InstrumentationLibraryMetrics)
}
// CopyTo copies all properties from the current struct to the dest.
func (ms ResourceMetrics) CopyTo(dest ResourceMetrics) {
ms.Resource().CopyTo(dest.Resource())
ms.InstrumentationLibraryMetrics().CopyTo(dest.InstrumentationLibraryMetrics())
}
// InstrumentationLibraryMetricsSlice logically represents a slice of InstrumentationLibraryMetrics.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewInstrumentationLibraryMetricsSlice function to create new instances.
// Important: zero-initialized instance is not valid for use.
type InstrumentationLibraryMetricsSlice struct {
// orig points to the slice otlpmetrics.InstrumentationLibraryMetrics field contained somewhere else.
// We use pointer-to-slice to be able to modify it in functions like Resize.
orig *[]*otlpmetrics.InstrumentationLibraryMetrics
}
func newInstrumentationLibraryMetricsSlice(orig *[]*otlpmetrics.InstrumentationLibraryMetrics) InstrumentationLibraryMetricsSlice {
return InstrumentationLibraryMetricsSlice{orig}
}
// NewInstrumentationLibraryMetricsSlice creates a InstrumentationLibraryMetricsSlice with 0 elements.
// Can use "Resize" to initialize with a given length.
func NewInstrumentationLibraryMetricsSlice() InstrumentationLibraryMetricsSlice {
orig := []*otlpmetrics.InstrumentationLibraryMetrics(nil)
return InstrumentationLibraryMetricsSlice{&orig}
}
// Len returns the number of elements in the slice.
//
// Returns "0" for a newly instance created with "NewInstrumentationLibraryMetricsSlice()".
func (es InstrumentationLibraryMetricsSlice) Len() int {
return len(*es.orig)
}
// At returns the element at the given index.
//
// This function is used mostly for iterating over all the values in the slice:
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// ... // Do something with the element
// }
func (es InstrumentationLibraryMetricsSlice) At(ix int) InstrumentationLibraryMetrics {
return newInstrumentationLibraryMetrics((*es.orig)[ix])
}
// MoveAndAppendTo moves all elements from the current slice and appends them to the dest.
// The current slice will be cleared.
func (es InstrumentationLibraryMetricsSlice) MoveAndAppendTo(dest InstrumentationLibraryMetricsSlice) {
if *dest.orig == nil {
// We can simply move the entire vector and avoid any allocations.
*dest.orig = *es.orig
} else {
*dest.orig = append(*dest.orig, *es.orig...)
}
*es.orig = nil
}
// CopyTo copies all elements from the current slice to the dest.
func (es InstrumentationLibraryMetricsSlice) CopyTo(dest InstrumentationLibraryMetricsSlice) {
srcLen := es.Len()
destCap := cap(*dest.orig)
if srcLen <= destCap {
(*dest.orig) = (*dest.orig)[:srcLen:destCap]
for i := range *es.orig {
newInstrumentationLibraryMetrics((*es.orig)[i]).CopyTo(newInstrumentationLibraryMetrics((*dest.orig)[i]))
}
return
}
origs := make([]otlpmetrics.InstrumentationLibraryMetrics, srcLen)
wrappers := make([]*otlpmetrics.InstrumentationLibraryMetrics, srcLen)
for i := range *es.orig {
wrappers[i] = &origs[i]
newInstrumentationLibraryMetrics((*es.orig)[i]).CopyTo(newInstrumentationLibraryMetrics(wrappers[i]))
}
*dest.orig = wrappers
}
// Resize is an operation that resizes the slice:
// 1. If the newLen <= len then equivalent with slice[0:newLen:cap].
// 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice.
//
// Here is how a new InstrumentationLibraryMetricsSlice can be initialized:
// es := NewInstrumentationLibraryMetricsSlice()
// es.Resize(4)
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// // Here should set all the values for e.
// }
func (es InstrumentationLibraryMetricsSlice) Resize(newLen int) {
oldLen := len(*es.orig)
oldCap := cap(*es.orig)
if newLen <= oldLen {
*es.orig = (*es.orig)[:newLen:oldCap]
return
}
if newLen > oldCap {
newOrig := make([]*otlpmetrics.InstrumentationLibraryMetrics, oldLen, newLen)
copy(newOrig, *es.orig)
*es.orig = newOrig
}
// Add extra empty elements to the array.
extraOrigs := make([]otlpmetrics.InstrumentationLibraryMetrics, newLen-oldLen)
for i := range extraOrigs {
*es.orig = append(*es.orig, &extraOrigs[i])
}
}
// Append will increase the length of the InstrumentationLibraryMetricsSlice by one and set the
// given InstrumentationLibraryMetrics at that new position. The original InstrumentationLibraryMetrics
// could still be referenced so do not reuse it after passing it to this
// method.
func (es InstrumentationLibraryMetricsSlice) Append(e InstrumentationLibraryMetrics) {
*es.orig = append(*es.orig, e.orig)
}
// InstrumentationLibraryMetrics is a collection of metrics from a LibraryInstrumentation.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewInstrumentationLibraryMetrics function to create new instances.
// Important: zero-initialized instance is not valid for use.
type InstrumentationLibraryMetrics struct {
orig *otlpmetrics.InstrumentationLibraryMetrics
}
func newInstrumentationLibraryMetrics(orig *otlpmetrics.InstrumentationLibraryMetrics) InstrumentationLibraryMetrics {
return InstrumentationLibraryMetrics{orig: orig}
}
// NewInstrumentationLibraryMetrics creates a new empty InstrumentationLibraryMetrics.
//
// This must be used only in testing code since no "Set" method available.
func NewInstrumentationLibraryMetrics() InstrumentationLibraryMetrics {
return newInstrumentationLibraryMetrics(&otlpmetrics.InstrumentationLibraryMetrics{})
}
// InstrumentationLibrary returns the instrumentationlibrary associated with this InstrumentationLibraryMetrics.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms InstrumentationLibraryMetrics) InstrumentationLibrary() InstrumentationLibrary {
return newInstrumentationLibrary(&(*ms.orig).InstrumentationLibrary)
}
// Metrics returns the Metrics associated with this InstrumentationLibraryMetrics.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms InstrumentationLibraryMetrics) Metrics() MetricSlice {
return newMetricSlice(&(*ms.orig).Metrics)
}
// CopyTo copies all properties from the current struct to the dest.
func (ms InstrumentationLibraryMetrics) CopyTo(dest InstrumentationLibraryMetrics) {
ms.InstrumentationLibrary().CopyTo(dest.InstrumentationLibrary())
ms.Metrics().CopyTo(dest.Metrics())
}
// MetricSlice logically represents a slice of Metric.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewMetricSlice function to create new instances.
// Important: zero-initialized instance is not valid for use.
type MetricSlice struct {
// orig points to the slice otlpmetrics.Metric field contained somewhere else.
// We use pointer-to-slice to be able to modify it in functions like Resize.
orig *[]*otlpmetrics.Metric
}
func newMetricSlice(orig *[]*otlpmetrics.Metric) MetricSlice {
return MetricSlice{orig}
}
// NewMetricSlice creates a MetricSlice with 0 elements.
// Can use "Resize" to initialize with a given length.
func NewMetricSlice() MetricSlice {
orig := []*otlpmetrics.Metric(nil)
return MetricSlice{&orig}
}
// Len returns the number of elements in the slice.
//
// Returns "0" for a newly instance created with "NewMetricSlice()".
func (es MetricSlice) Len() int {
return len(*es.orig)
}
// At returns the element at the given index.
//
// This function is used mostly for iterating over all the values in the slice:
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// ... // Do something with the element
// }
func (es MetricSlice) At(ix int) Metric {
return newMetric((*es.orig)[ix])
}
// MoveAndAppendTo moves all elements from the current slice and appends them to the dest.
// The current slice will be cleared.
func (es MetricSlice) MoveAndAppendTo(dest MetricSlice) {
if *dest.orig == nil {
// We can simply move the entire vector and avoid any allocations.
*dest.orig = *es.orig
} else {
*dest.orig = append(*dest.orig, *es.orig...)
}
*es.orig = nil
}
// CopyTo copies all elements from the current slice to the dest.
func (es MetricSlice) CopyTo(dest MetricSlice) {
srcLen := es.Len()
destCap := cap(*dest.orig)
if srcLen <= destCap {
(*dest.orig) = (*dest.orig)[:srcLen:destCap]
for i := range *es.orig {
newMetric((*es.orig)[i]).CopyTo(newMetric((*dest.orig)[i]))
}
return
}
origs := make([]otlpmetrics.Metric, srcLen)
wrappers := make([]*otlpmetrics.Metric, srcLen)
for i := range *es.orig {
wrappers[i] = &origs[i]
newMetric((*es.orig)[i]).CopyTo(newMetric(wrappers[i]))
}
*dest.orig = wrappers
}
// Resize is an operation that resizes the slice:
// 1. If the newLen <= len then equivalent with slice[0:newLen:cap].
// 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice.
//
// Here is how a new MetricSlice can be initialized:
// es := NewMetricSlice()
// es.Resize(4)
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// // Here should set all the values for e.
// }
func (es MetricSlice) Resize(newLen int) {
oldLen := len(*es.orig)
oldCap := cap(*es.orig)
if newLen <= oldLen {
*es.orig = (*es.orig)[:newLen:oldCap]
return
}
if newLen > oldCap {
newOrig := make([]*otlpmetrics.Metric, oldLen, newLen)
copy(newOrig, *es.orig)
*es.orig = newOrig
}
// Add extra empty elements to the array.
extraOrigs := make([]otlpmetrics.Metric, newLen-oldLen)
for i := range extraOrigs {
*es.orig = append(*es.orig, &extraOrigs[i])
}
}
// Append will increase the length of the MetricSlice by one and set the
// given Metric at that new position. The original Metric
// could still be referenced so do not reuse it after passing it to this
// method.
func (es MetricSlice) Append(e Metric) {
*es.orig = append(*es.orig, e.orig)
}
// Metric represents one metric as a collection of datapoints.
// See Metric definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/master/opentelemetry/proto/metrics/v1/metrics.proto
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewMetric function to create new instances.
// Important: zero-initialized instance is not valid for use.
type Metric struct {
orig *otlpmetrics.Metric
}
func newMetric(orig *otlpmetrics.Metric) Metric {
return Metric{orig: orig}
}
// NewMetric creates a new empty Metric.
//
// This must be used only in testing code since no "Set" method available.
func NewMetric() Metric {
return newMetric(&otlpmetrics.Metric{})
}
// Name returns the name associated with this Metric.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms Metric) Name() string {
return (*ms.orig).Name
}
// SetName replaces the name associated with this Metric.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms Metric) SetName(v string) {
(*ms.orig).Name = v
}
// Description returns the description associated with this Metric.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms Metric) Description() string {
return (*ms.orig).Description
}
// SetDescription replaces the description associated with this Metric.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms Metric) SetDescription(v string) {
(*ms.orig).Description = v
}
// Unit returns the unit associated with this Metric.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms Metric) Unit() string {
return (*ms.orig).Unit
}
// SetUnit replaces the unit associated with this Metric.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms Metric) SetUnit(v string) {
(*ms.orig).Unit = v
}
// CopyTo copies all properties from the current struct to the dest.
func (ms Metric) CopyTo(dest Metric) {
dest.SetName(ms.Name())
dest.SetDescription(ms.Description())
dest.SetUnit(ms.Unit())
copyData(ms.orig, dest.orig)
}
// IntGauge represents the type of a int scalar metric that always exports the "current value" for every data point.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewIntGauge function to create new instances.
// Important: zero-initialized instance is not valid for use.
type IntGauge struct {
orig *otlpmetrics.IntGauge
}
func newIntGauge(orig *otlpmetrics.IntGauge) IntGauge {
return IntGauge{orig: orig}
}
// NewIntGauge creates a new empty IntGauge.
//
// This must be used only in testing code since no "Set" method available.
func NewIntGauge() IntGauge {
return newIntGauge(&otlpmetrics.IntGauge{})
}
// DataPoints returns the DataPoints associated with this IntGauge.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntGauge) DataPoints() IntDataPointSlice {
return newIntDataPointSlice(&(*ms.orig).DataPoints)
}
// CopyTo copies all properties from the current struct to the dest.
func (ms IntGauge) CopyTo(dest IntGauge) {
ms.DataPoints().CopyTo(dest.DataPoints())
}
// DoubleGauge represents the type of a double scalar metric that always exports the "current value" for every data point.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewDoubleGauge function to create new instances.
// Important: zero-initialized instance is not valid for use.
type DoubleGauge struct {
orig *otlpmetrics.DoubleGauge
}
func newDoubleGauge(orig *otlpmetrics.DoubleGauge) DoubleGauge {
return DoubleGauge{orig: orig}
}
// NewDoubleGauge creates a new empty DoubleGauge.
//
// This must be used only in testing code since no "Set" method available.
func NewDoubleGauge() DoubleGauge {
return newDoubleGauge(&otlpmetrics.DoubleGauge{})
}
// DataPoints returns the DataPoints associated with this DoubleGauge.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleGauge) DataPoints() DoubleDataPointSlice {
return newDoubleDataPointSlice(&(*ms.orig).DataPoints)
}
// CopyTo copies all properties from the current struct to the dest.
func (ms DoubleGauge) CopyTo(dest DoubleGauge) {
ms.DataPoints().CopyTo(dest.DataPoints())
}
// IntSum represents the type of a numeric int scalar metric that is calculated as a sum of all reported measurements over a time interval.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewIntSum function to create new instances.
// Important: zero-initialized instance is not valid for use.
type IntSum struct {
orig *otlpmetrics.IntSum
}
func newIntSum(orig *otlpmetrics.IntSum) IntSum {
return IntSum{orig: orig}
}
// NewIntSum creates a new empty IntSum.
//
// This must be used only in testing code since no "Set" method available.
func NewIntSum() IntSum {
return newIntSum(&otlpmetrics.IntSum{})
}
// AggregationTemporality returns the aggregationtemporality associated with this IntSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntSum) AggregationTemporality() AggregationTemporality {
return AggregationTemporality((*ms.orig).AggregationTemporality)
}
// SetAggregationTemporality replaces the aggregationtemporality associated with this IntSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntSum) SetAggregationTemporality(v AggregationTemporality) {
(*ms.orig).AggregationTemporality = otlpmetrics.AggregationTemporality(v)
}
// IsMonotonic returns the ismonotonic associated with this IntSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntSum) IsMonotonic() bool {
return (*ms.orig).IsMonotonic
}
// SetIsMonotonic replaces the ismonotonic associated with this IntSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntSum) SetIsMonotonic(v bool) {
(*ms.orig).IsMonotonic = v
}
// DataPoints returns the DataPoints associated with this IntSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntSum) DataPoints() IntDataPointSlice {
return newIntDataPointSlice(&(*ms.orig).DataPoints)
}
// CopyTo copies all properties from the current struct to the dest.
func (ms IntSum) CopyTo(dest IntSum) {
dest.SetAggregationTemporality(ms.AggregationTemporality())
dest.SetIsMonotonic(ms.IsMonotonic())
ms.DataPoints().CopyTo(dest.DataPoints())
}
// DoubleSum represents the type of a numeric double scalar metric that is calculated as a sum of all reported measurements over a time interval.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewDoubleSum function to create new instances.
// Important: zero-initialized instance is not valid for use.
type DoubleSum struct {
orig *otlpmetrics.DoubleSum
}
func newDoubleSum(orig *otlpmetrics.DoubleSum) DoubleSum {
return DoubleSum{orig: orig}
}
// NewDoubleSum creates a new empty DoubleSum.
//
// This must be used only in testing code since no "Set" method available.
func NewDoubleSum() DoubleSum {
return newDoubleSum(&otlpmetrics.DoubleSum{})
}
// AggregationTemporality returns the aggregationtemporality associated with this DoubleSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleSum) AggregationTemporality() AggregationTemporality {
return AggregationTemporality((*ms.orig).AggregationTemporality)
}
// SetAggregationTemporality replaces the aggregationtemporality associated with this DoubleSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleSum) SetAggregationTemporality(v AggregationTemporality) {
(*ms.orig).AggregationTemporality = otlpmetrics.AggregationTemporality(v)
}
// IsMonotonic returns the ismonotonic associated with this DoubleSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleSum) IsMonotonic() bool {
return (*ms.orig).IsMonotonic
}
// SetIsMonotonic replaces the ismonotonic associated with this DoubleSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleSum) SetIsMonotonic(v bool) {
(*ms.orig).IsMonotonic = v
}
// DataPoints returns the DataPoints associated with this DoubleSum.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleSum) DataPoints() DoubleDataPointSlice {
return newDoubleDataPointSlice(&(*ms.orig).DataPoints)
}
// CopyTo copies all properties from the current struct to the dest.
func (ms DoubleSum) CopyTo(dest DoubleSum) {
dest.SetAggregationTemporality(ms.AggregationTemporality())
dest.SetIsMonotonic(ms.IsMonotonic())
ms.DataPoints().CopyTo(dest.DataPoints())
}
// IntHistogram represents the type of a metric that is calculated by aggregating as a Histogram of all reported double measurements over a time interval.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewIntHistogram function to create new instances.
// Important: zero-initialized instance is not valid for use.
type IntHistogram struct {
orig *otlpmetrics.IntHistogram
}
func newIntHistogram(orig *otlpmetrics.IntHistogram) IntHistogram {
return IntHistogram{orig: orig}
}
// NewIntHistogram creates a new empty IntHistogram.
//
// This must be used only in testing code since no "Set" method available.
func NewIntHistogram() IntHistogram {
return newIntHistogram(&otlpmetrics.IntHistogram{})
}
// AggregationTemporality returns the aggregationtemporality associated with this IntHistogram.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntHistogram) AggregationTemporality() AggregationTemporality {
return AggregationTemporality((*ms.orig).AggregationTemporality)
}
// SetAggregationTemporality replaces the aggregationtemporality associated with this IntHistogram.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntHistogram) SetAggregationTemporality(v AggregationTemporality) {
(*ms.orig).AggregationTemporality = otlpmetrics.AggregationTemporality(v)
}
// DataPoints returns the DataPoints associated with this IntHistogram.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntHistogram) DataPoints() IntHistogramDataPointSlice {
return newIntHistogramDataPointSlice(&(*ms.orig).DataPoints)
}
// CopyTo copies all properties from the current struct to the dest.
func (ms IntHistogram) CopyTo(dest IntHistogram) {
dest.SetAggregationTemporality(ms.AggregationTemporality())
ms.DataPoints().CopyTo(dest.DataPoints())
}
// DoubleHistogram represents the type of a metric that is calculated by aggregating as a Histogram of all reported double measurements over a time interval.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewDoubleHistogram function to create new instances.
// Important: zero-initialized instance is not valid for use.
type DoubleHistogram struct {
orig *otlpmetrics.DoubleHistogram
}
func newDoubleHistogram(orig *otlpmetrics.DoubleHistogram) DoubleHistogram {
return DoubleHistogram{orig: orig}
}
// NewDoubleHistogram creates a new empty DoubleHistogram.
//
// This must be used only in testing code since no "Set" method available.
func NewDoubleHistogram() DoubleHistogram {
return newDoubleHistogram(&otlpmetrics.DoubleHistogram{})
}
// AggregationTemporality returns the aggregationtemporality associated with this DoubleHistogram.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleHistogram) AggregationTemporality() AggregationTemporality {
return AggregationTemporality((*ms.orig).AggregationTemporality)
}
// SetAggregationTemporality replaces the aggregationtemporality associated with this DoubleHistogram.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleHistogram) SetAggregationTemporality(v AggregationTemporality) {
(*ms.orig).AggregationTemporality = otlpmetrics.AggregationTemporality(v)
}
// DataPoints returns the DataPoints associated with this DoubleHistogram.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleHistogram) DataPoints() DoubleHistogramDataPointSlice {
return newDoubleHistogramDataPointSlice(&(*ms.orig).DataPoints)
}
// CopyTo copies all properties from the current struct to the dest.
func (ms DoubleHistogram) CopyTo(dest DoubleHistogram) {
dest.SetAggregationTemporality(ms.AggregationTemporality())
ms.DataPoints().CopyTo(dest.DataPoints())
}
// DoubleSummary represents the type of a metric that is calculated by aggregating as a Summary of all reported double measurements over a time interval.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewDoubleSummary function to create new instances.
// Important: zero-initialized instance is not valid for use.
type DoubleSummary struct {
orig *otlpmetrics.DoubleSummary
}
func newDoubleSummary(orig *otlpmetrics.DoubleSummary) DoubleSummary {
return DoubleSummary{orig: orig}
}
// NewDoubleSummary creates a new empty DoubleSummary.
//
// This must be used only in testing code since no "Set" method available.
func NewDoubleSummary() DoubleSummary {
return newDoubleSummary(&otlpmetrics.DoubleSummary{})
}
// DataPoints returns the DataPoints associated with this DoubleSummary.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms DoubleSummary) DataPoints() DoubleSummaryDataPointSlice {
return newDoubleSummaryDataPointSlice(&(*ms.orig).DataPoints)
}
// CopyTo copies all properties from the current struct to the dest.
func (ms DoubleSummary) CopyTo(dest DoubleSummary) {
ms.DataPoints().CopyTo(dest.DataPoints())
}
// IntDataPointSlice logically represents a slice of IntDataPoint.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewIntDataPointSlice function to create new instances.
// Important: zero-initialized instance is not valid for use.
type IntDataPointSlice struct {
// orig points to the slice otlpmetrics.IntDataPoint field contained somewhere else.
// We use pointer-to-slice to be able to modify it in functions like Resize.
orig *[]*otlpmetrics.IntDataPoint
}
func newIntDataPointSlice(orig *[]*otlpmetrics.IntDataPoint) IntDataPointSlice {
return IntDataPointSlice{orig}
}
// NewIntDataPointSlice creates a IntDataPointSlice with 0 elements.
// Can use "Resize" to initialize with a given length.
func NewIntDataPointSlice() IntDataPointSlice {
orig := []*otlpmetrics.IntDataPoint(nil)
return IntDataPointSlice{&orig}
}
// Len returns the number of elements in the slice.
//
// Returns "0" for a newly instance created with "NewIntDataPointSlice()".
func (es IntDataPointSlice) Len() int {
return len(*es.orig)
}
// At returns the element at the given index.
//
// This function is used mostly for iterating over all the values in the slice:
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// ... // Do something with the element
// }
func (es IntDataPointSlice) At(ix int) IntDataPoint {
return newIntDataPoint((*es.orig)[ix])
}
// MoveAndAppendTo moves all elements from the current slice and appends them to the dest.
// The current slice will be cleared.
func (es IntDataPointSlice) MoveAndAppendTo(dest IntDataPointSlice) {
if *dest.orig == nil {
// We can simply move the entire vector and avoid any allocations.
*dest.orig = *es.orig
} else {
*dest.orig = append(*dest.orig, *es.orig...)
}
*es.orig = nil
}
// CopyTo copies all elements from the current slice to the dest.
func (es IntDataPointSlice) CopyTo(dest IntDataPointSlice) {
srcLen := es.Len()
destCap := cap(*dest.orig)
if srcLen <= destCap {
(*dest.orig) = (*dest.orig)[:srcLen:destCap]
for i := range *es.orig {
newIntDataPoint((*es.orig)[i]).CopyTo(newIntDataPoint((*dest.orig)[i]))
}
return
}
origs := make([]otlpmetrics.IntDataPoint, srcLen)
wrappers := make([]*otlpmetrics.IntDataPoint, srcLen)
for i := range *es.orig {
wrappers[i] = &origs[i]
newIntDataPoint((*es.orig)[i]).CopyTo(newIntDataPoint(wrappers[i]))
}
*dest.orig = wrappers
}
// Resize is an operation that resizes the slice:
// 1. If the newLen <= len then equivalent with slice[0:newLen:cap].
// 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice.
//
// Here is how a new IntDataPointSlice can be initialized:
// es := NewIntDataPointSlice()
// es.Resize(4)
// for i := 0; i < es.Len(); i++ {
// e := es.At(i)
// // Here should set all the values for e.
// }
func (es IntDataPointSlice) Resize(newLen int) {
oldLen := len(*es.orig)
oldCap := cap(*es.orig)
if newLen <= oldLen {
*es.orig = (*es.orig)[:newLen:oldCap]
return
}
if newLen > oldCap {
newOrig := make([]*otlpmetrics.IntDataPoint, oldLen, newLen)
copy(newOrig, *es.orig)
*es.orig = newOrig
}
// Add extra empty elements to the array.
extraOrigs := make([]otlpmetrics.IntDataPoint, newLen-oldLen)
for i := range extraOrigs {
*es.orig = append(*es.orig, &extraOrigs[i])
}
}
// Append will increase the length of the IntDataPointSlice by one and set the
// given IntDataPoint at that new position. The original IntDataPoint
// could still be referenced so do not reuse it after passing it to this
// method.
func (es IntDataPointSlice) Append(e IntDataPoint) {
*es.orig = append(*es.orig, e.orig)
}
// IntDataPoint is a single data point in a timeseries that describes the time-varying values of a scalar int metric.
//
// This is a reference type, if passed by value and callee modifies it the
// caller will see the modification.
//
// Must use NewIntDataPoint function to create new instances.
// Important: zero-initialized instance is not valid for use.
type IntDataPoint struct {
orig *otlpmetrics.IntDataPoint
}
func newIntDataPoint(orig *otlpmetrics.IntDataPoint) IntDataPoint {
return IntDataPoint{orig: orig}
}
// NewIntDataPoint creates a new empty IntDataPoint.
//
// This must be used only in testing code since no "Set" method available.
func NewIntDataPoint() IntDataPoint {
return newIntDataPoint(&otlpmetrics.IntDataPoint{})
}
// LabelsMap returns the Labels associated with this IntDataPoint.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntDataPoint) LabelsMap() StringMap {
return newStringMap(&(*ms.orig).Labels)
}
// StartTime returns the starttime associated with this IntDataPoint.
//
// Important: This causes a runtime error if IsNil() returns "true".
func (ms IntDataPoint) StartTime() TimestampUnixNano {
return TimestampUnixNano((*ms.orig).StartTimeUnixNano)
}