| 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 |
"go.opentelemetry.io/collector/pdata/pcommon" |
| 12 |
) |
| 13 |
|
| 14 |
// NumberDataPoint is a single data point in a timeseries that describes the time-varying value of a number metric. |
| 15 |
// |
| 16 |
// This is a reference type, if passed by value and callee modifies it the |
| 17 |
// caller will see the modification. |
| 18 |
// |
| 19 |
// Must use NewNumberDataPoint function to create new instances. |
| 20 |
// Important: zero-initialized instance is not valid for use. |
| 21 |
type NumberDataPoint struct { |
| 22 |
orig *internal.NumberDataPoint |
| 23 |
state *internal.State |
| 24 |
} |
| 25 |
|
| 26 |
func newNumberDataPoint(orig *internal.NumberDataPoint, state *internal.State) NumberDataPoint { |
| 27 |
return NumberDataPoint{orig: orig, state: state} |
| 28 |
} |
| 29 |
|
| 30 |
// NewNumberDataPoint creates a new empty NumberDataPoint. |
| 31 |
// |
| 32 |
// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, |
| 33 |
// OR directly access the member if this is embedded in another struct. |
| 34 |
func NewNumberDataPoint() NumberDataPoint { |
| 35 |
return newNumberDataPoint(internal.NewNumberDataPoint(), internal.NewState()) |
| 36 |
} |
| 37 |
|
| 38 |
// MoveTo moves all properties from the current struct overriding the destination and |
| 39 |
// resetting the current instance to its zero value |
| 40 |
func (ms NumberDataPoint) MoveTo(dest NumberDataPoint) { |
| 41 |
ms.state.AssertMutable() |
| 42 |
dest.state.AssertMutable() |
| 43 |
// If they point to the same data, they are the same, nothing to do. |
| 44 |
if ms.orig == dest.orig { |
| 45 |
return |
| 46 |
} |
| 47 |
internal.DeleteNumberDataPoint(dest.orig, false) |
| 48 |
*dest.orig, *ms.orig = *ms.orig, *dest.orig |
| 49 |
} |
| 50 |
|
| 51 |
// Attributes returns the Attributes associated with this NumberDataPoint. |
| 52 |
func (ms NumberDataPoint) Attributes() pcommon.Map { |
| 53 |
return pcommon.Map(internal.NewMapWrapper(&ms.orig.Attributes, ms.state)) |
| 54 |
} |
| 55 |
|
| 56 |
// StartTimestamp returns the starttimestamp associated with this NumberDataPoint. |
| 57 |
func (ms NumberDataPoint) StartTimestamp() pcommon.Timestamp { |
| 58 |
return pcommon.Timestamp(ms.orig.StartTimeUnixNano) |
| 59 |
} |
| 60 |
|
| 61 |
// SetStartTimestamp replaces the starttimestamp associated with this NumberDataPoint. |
| 62 |
func (ms NumberDataPoint) SetStartTimestamp(v pcommon.Timestamp) { |
| 63 |
ms.state.AssertMutable() |
| 64 |
ms.orig.StartTimeUnixNano = uint64(v) |
| 65 |
} |
| 66 |
|
| 67 |
// Timestamp returns the timestamp associated with this NumberDataPoint. |
| 68 |
func (ms NumberDataPoint) Timestamp() pcommon.Timestamp { |
| 69 |
return pcommon.Timestamp(ms.orig.TimeUnixNano) |
| 70 |
} |
| 71 |
|
| 72 |
// SetTimestamp replaces the timestamp associated with this NumberDataPoint. |
| 73 |
func (ms NumberDataPoint) SetTimestamp(v pcommon.Timestamp) { |
| 74 |
ms.state.AssertMutable() |
| 75 |
ms.orig.TimeUnixNano = uint64(v) |
| 76 |
} |
| 77 |
|
| 78 |
// ValueType returns the type of the value for this NumberDataPoint. |
| 79 |
// Calling this function on zero-initialized NumberDataPoint will cause a panic. |
| 80 |
func (ms NumberDataPoint) ValueType() NumberDataPointValueType { |
| 81 |
switch ms.orig.Value.(type) { |
| 82 |
case *internal.NumberDataPoint_AsDouble: |
| 83 |
return NumberDataPointValueTypeDouble |
| 84 |
case *internal.NumberDataPoint_AsInt: |
| 85 |
return NumberDataPointValueTypeInt |
| 86 |
} |
| 87 |
return NumberDataPointValueTypeEmpty |
| 88 |
} |
| 89 |
|
| 90 |
// DoubleValue returns the double associated with this NumberDataPoint. |
| 91 |
func (ms NumberDataPoint) DoubleValue() float64 { |
| 92 |
return ms.orig.GetAsDouble() |
| 93 |
} |
| 94 |
|
| 95 |
// SetDoubleValue replaces the double associated with this NumberDataPoint. |
| 96 |
func (ms NumberDataPoint) SetDoubleValue(v float64) { |
| 97 |
ms.state.AssertMutable() |
| 98 |
var ov *internal.NumberDataPoint_AsDouble |
| 99 |
if !internal.UseProtoPooling.IsEnabled() { |
| 100 |
ov = &internal.NumberDataPoint_AsDouble{} |
| 101 |
} else { |
| 102 |
ov = internal.ProtoPoolNumberDataPoint_AsDouble.Get().(*internal.NumberDataPoint_AsDouble) |
| 103 |
} |
| 104 |
ov.AsDouble = v |
| 105 |
ms.orig.Value = ov |
| 106 |
} |
| 107 |
|
| 108 |
// IntValue returns the int associated with this NumberDataPoint. |
| 109 |
func (ms NumberDataPoint) IntValue() int64 { |
| 110 |
return ms.orig.GetAsInt() |
| 111 |
} |
| 112 |
|
| 113 |
// SetIntValue replaces the int associated with this NumberDataPoint. |
| 114 |
func (ms NumberDataPoint) SetIntValue(v int64) { |
| 115 |
ms.state.AssertMutable() |
| 116 |
var ov *internal.NumberDataPoint_AsInt |
| 117 |
if !internal.UseProtoPooling.IsEnabled() { |
| 118 |
ov = &internal.NumberDataPoint_AsInt{} |
| 119 |
} else { |
| 120 |
ov = internal.ProtoPoolNumberDataPoint_AsInt.Get().(*internal.NumberDataPoint_AsInt) |
| 121 |
} |
| 122 |
ov.AsInt = v |
| 123 |
ms.orig.Value = ov |
| 124 |
} |
| 125 |
|
| 126 |
// Exemplars returns the Exemplars associated with this NumberDataPoint. |
| 127 |
func (ms NumberDataPoint) Exemplars() ExemplarSlice { |
| 128 |
return newExemplarSlice(&ms.orig.Exemplars, ms.state) |
| 129 |
} |
| 130 |
|
| 131 |
// Flags returns the flags associated with this NumberDataPoint. |
| 132 |
func (ms NumberDataPoint) Flags() DataPointFlags { |
| 133 |
return DataPointFlags(ms.orig.Flags) |
| 134 |
} |
| 135 |
|
| 136 |
// SetFlags replaces the flags associated with this NumberDataPoint. |
| 137 |
func (ms NumberDataPoint) SetFlags(v DataPointFlags) { |
| 138 |
ms.state.AssertMutable() |
| 139 |
ms.orig.Flags = uint32(v) |
| 140 |
} |
| 141 |
|
| 142 |
// CopyTo copies all properties from the current struct overriding the destination. |
| 143 |
func (ms NumberDataPoint) CopyTo(dest NumberDataPoint) { |
| 144 |
dest.state.AssertMutable() |
| 145 |
internal.CopyNumberDataPoint(dest.orig, ms.orig) |
| 146 |
} |