| 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 |
// Exemplar is a sample input double measurement. |
| 15 |
// |
| 16 |
// Exemplars also hold information about the environment when the measurement was recorded, |
| 17 |
// for example the span and trace ID of the active span when the exemplar was recorded. |
| 18 |
// |
| 19 |
// This is a reference type, if passed by value and callee modifies it the |
| 20 |
// caller will see the modification. |
| 21 |
// |
| 22 |
// Must use NewExemplar function to create new instances. |
| 23 |
// Important: zero-initialized instance is not valid for use. |
| 24 |
type Exemplar struct { |
| 25 |
orig *internal.Exemplar |
| 26 |
state *internal.State |
| 27 |
} |
| 28 |
|
| 29 |
func newExemplar(orig *internal.Exemplar, state *internal.State) Exemplar { |
| 30 |
return Exemplar{orig: orig, state: state} |
| 31 |
} |
| 32 |
|
| 33 |
// NewExemplar creates a new empty Exemplar. |
| 34 |
// |
| 35 |
// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, |
| 36 |
// OR directly access the member if this is embedded in another struct. |
| 37 |
func NewExemplar() Exemplar { |
| 38 |
return newExemplar(internal.NewExemplar(), internal.NewState()) |
| 39 |
} |
| 40 |
|
| 41 |
// MoveTo moves all properties from the current struct overriding the destination and |
| 42 |
// resetting the current instance to its zero value |
| 43 |
func (ms Exemplar) MoveTo(dest Exemplar) { |
| 44 |
ms.state.AssertMutable() |
| 45 |
dest.state.AssertMutable() |
| 46 |
// If they point to the same data, they are the same, nothing to do. |
| 47 |
if ms.orig == dest.orig { |
| 48 |
return |
| 49 |
} |
| 50 |
internal.DeleteExemplar(dest.orig, false) |
| 51 |
*dest.orig, *ms.orig = *ms.orig, *dest.orig |
| 52 |
} |
| 53 |
|
| 54 |
// FilteredAttributes returns the FilteredAttributes associated with this Exemplar. |
| 55 |
func (ms Exemplar) FilteredAttributes() pcommon.Map { |
| 56 |
return pcommon.Map(internal.NewMapWrapper(&ms.orig.FilteredAttributes, ms.state)) |
| 57 |
} |
| 58 |
|
| 59 |
// Timestamp returns the timestamp associated with this Exemplar. |
| 60 |
func (ms Exemplar) Timestamp() pcommon.Timestamp { |
| 61 |
return pcommon.Timestamp(ms.orig.TimeUnixNano) |
| 62 |
} |
| 63 |
|
| 64 |
// SetTimestamp replaces the timestamp associated with this Exemplar. |
| 65 |
func (ms Exemplar) SetTimestamp(v pcommon.Timestamp) { |
| 66 |
ms.state.AssertMutable() |
| 67 |
ms.orig.TimeUnixNano = uint64(v) |
| 68 |
} |
| 69 |
|
| 70 |
// ValueType returns the type of the value for this Exemplar. |
| 71 |
// Calling this function on zero-initialized Exemplar will cause a panic. |
| 72 |
func (ms Exemplar) ValueType() ExemplarValueType { |
| 73 |
switch ms.orig.Value.(type) { |
| 74 |
case *internal.Exemplar_AsDouble: |
| 75 |
return ExemplarValueTypeDouble |
| 76 |
case *internal.Exemplar_AsInt: |
| 77 |
return ExemplarValueTypeInt |
| 78 |
} |
| 79 |
return ExemplarValueTypeEmpty |
| 80 |
} |
| 81 |
|
| 82 |
// DoubleValue returns the double associated with this Exemplar. |
| 83 |
func (ms Exemplar) DoubleValue() float64 { |
| 84 |
return ms.orig.GetAsDouble() |
| 85 |
} |
| 86 |
|
| 87 |
// SetDoubleValue replaces the double associated with this Exemplar. |
| 88 |
func (ms Exemplar) SetDoubleValue(v float64) { |
| 89 |
ms.state.AssertMutable() |
| 90 |
var ov *internal.Exemplar_AsDouble |
| 91 |
if !internal.UseProtoPooling.IsEnabled() { |
| 92 |
ov = &internal.Exemplar_AsDouble{} |
| 93 |
} else { |
| 94 |
ov = internal.ProtoPoolExemplar_AsDouble.Get().(*internal.Exemplar_AsDouble) |
| 95 |
} |
| 96 |
ov.AsDouble = v |
| 97 |
ms.orig.Value = ov |
| 98 |
} |
| 99 |
|
| 100 |
// IntValue returns the int associated with this Exemplar. |
| 101 |
func (ms Exemplar) IntValue() int64 { |
| 102 |
return ms.orig.GetAsInt() |
| 103 |
} |
| 104 |
|
| 105 |
// SetIntValue replaces the int associated with this Exemplar. |
| 106 |
func (ms Exemplar) SetIntValue(v int64) { |
| 107 |
ms.state.AssertMutable() |
| 108 |
var ov *internal.Exemplar_AsInt |
| 109 |
if !internal.UseProtoPooling.IsEnabled() { |
| 110 |
ov = &internal.Exemplar_AsInt{} |
| 111 |
} else { |
| 112 |
ov = internal.ProtoPoolExemplar_AsInt.Get().(*internal.Exemplar_AsInt) |
| 113 |
} |
| 114 |
ov.AsInt = v |
| 115 |
ms.orig.Value = ov |
| 116 |
} |
| 117 |
|
| 118 |
// TraceID returns the traceid associated with this Exemplar. |
| 119 |
func (ms Exemplar) TraceID() pcommon.TraceID { |
| 120 |
return pcommon.TraceID(ms.orig.TraceId) |
| 121 |
} |
| 122 |
|
| 123 |
// SetTraceID replaces the traceid associated with this Exemplar. |
| 124 |
func (ms Exemplar) SetTraceID(v pcommon.TraceID) { |
| 125 |
ms.state.AssertMutable() |
| 126 |
ms.orig.TraceId = internal.TraceID(v) |
| 127 |
} |
| 128 |
|
| 129 |
// SpanID returns the spanid associated with this Exemplar. |
| 130 |
func (ms Exemplar) SpanID() pcommon.SpanID { |
| 131 |
return pcommon.SpanID(ms.orig.SpanId) |
| 132 |
} |
| 133 |
|
| 134 |
// SetSpanID replaces the spanid associated with this Exemplar. |
| 135 |
func (ms Exemplar) SetSpanID(v pcommon.SpanID) { |
| 136 |
ms.state.AssertMutable() |
| 137 |
ms.orig.SpanId = internal.SpanID(v) |
| 138 |
} |
| 139 |
|
| 140 |
// CopyTo copies all properties from the current struct overriding the destination. |
| 141 |
func (ms Exemplar) CopyTo(dest Exemplar) { |
| 142 |
dest.state.AssertMutable() |
| 143 |
internal.CopyExemplar(dest.orig, ms.orig) |
| 144 |
} |