Debian Codegraph @

pdata/pmetric/generated_sum.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 // Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT.
5 // To regenerate this file run "make genpdata".
6
7 package pmetric
8
9 import (
10 "go.opentelemetry.io/collector/pdata/internal"
11 )
12
13 // Sum represents the type of a numeric metric that is calculated as a sum of all reported measurements over a time interval.
14 //
15 // This is a reference type, if passed by value and callee modifies it the
16 // caller will see the modification.
17 //
18 // Must use NewSum function to create new instances.
19 // Important: zero-initialized instance is not valid for use.
20 type Sum struct {
21 orig *internal.Sum
22 state *internal.State
23 }
24
25 func newSum(orig *internal.Sum, state *internal.State) Sum {
26 return Sum{orig: orig, state: state}
27 }
28
29 // NewSum creates a new empty Sum.
30 //
31 // This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice,
32 // OR directly access the member if this is embedded in another struct.
33 func NewSum() Sum {
34 return newSum(internal.NewSum(), internal.NewState())
35 }
36
37 // MoveTo moves all properties from the current struct overriding the destination and
38 // resetting the current instance to its zero value
39 func (ms Sum) MoveTo(dest Sum) {
40 ms.state.AssertMutable()
41 dest.state.AssertMutable()
42 // If they point to the same data, they are the same, nothing to do.
43 if ms.orig == dest.orig {
44 return
45 }
46 internal.DeleteSum(dest.orig, false)
47 *dest.orig, *ms.orig = *ms.orig, *dest.orig
48 }
49
50 // DataPoints returns the DataPoints associated with this Sum.
51 func (ms Sum) DataPoints() NumberDataPointSlice {
52 return newNumberDataPointSlice(&ms.orig.DataPoints, ms.state)
53 }
54
55 // AggregationTemporality returns the aggregationtemporality associated with this Sum.
56 func (ms Sum) AggregationTemporality() AggregationTemporality {
57 return AggregationTemporality(ms.orig.AggregationTemporality)
58 }
59
60 // SetAggregationTemporality replaces the aggregationtemporality associated with this Sum.
61 func (ms Sum) SetAggregationTemporality(v AggregationTemporality) {
62 ms.state.AssertMutable()
63 ms.orig.AggregationTemporality = internal.AggregationTemporality(v)
64 }
65
66 // IsMonotonic returns the ismonotonic associated with this Sum.
67 func (ms Sum) IsMonotonic() bool {
68 return ms.orig.IsMonotonic
69 }
70
71 // SetIsMonotonic replaces the ismonotonic associated with this Sum.
72 func (ms Sum) SetIsMonotonic(v bool) {
73 ms.state.AssertMutable()
74 ms.orig.IsMonotonic = v
75 }
76
77 // CopyTo copies all properties from the current struct overriding the destination.
78 func (ms Sum) CopyTo(dest Sum) {
79 dest.state.AssertMutable()
80 internal.CopySum(dest.orig, ms.orig)
81 }