| 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 |
// Metrics is the top-level struct that is propagated through the metrics pipeline. |
| 14 |
// Use NewMetrics to create new instance, zero-initialized instance is not valid for use. |
| 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 NewMetrics function to create new instances. |
| 20 |
// Important: zero-initialized instance is not valid for use. |
| 21 |
type Metrics internal.MetricsWrapper |
| 22 |
|
| 23 |
func newMetrics(orig *internal.ExportMetricsServiceRequest, state *internal.State) Metrics { |
| 24 |
return Metrics(internal.NewMetricsWrapper(orig, state)) |
| 25 |
} |
| 26 |
|
| 27 |
// NewMetrics creates a new empty Metrics. |
| 28 |
// |
| 29 |
// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, |
| 30 |
// OR directly access the member if this is embedded in another struct. |
| 31 |
func NewMetrics() Metrics { |
| 32 |
return newMetrics(internal.NewExportMetricsServiceRequest(), internal.NewState()) |
| 33 |
} |
| 34 |
|
| 35 |
// MoveTo moves all properties from the current struct overriding the destination and |
| 36 |
// resetting the current instance to its zero value |
| 37 |
func (ms Metrics) MoveTo(dest Metrics) { |
| 38 |
ms.getState().AssertMutable() |
| 39 |
dest.getState().AssertMutable() |
| 40 |
// If they point to the same data, they are the same, nothing to do. |
| 41 |
if ms.getOrig() == dest.getOrig() { |
| 42 |
return |
| 43 |
} |
| 44 |
internal.DeleteExportMetricsServiceRequest(dest.getOrig(), false) |
| 45 |
*dest.getOrig(), *ms.getOrig() = *ms.getOrig(), *dest.getOrig() |
| 46 |
} |
| 47 |
|
| 48 |
// ResourceMetrics returns the ResourceMetrics associated with this Metrics. |
| 49 |
func (ms Metrics) ResourceMetrics() ResourceMetricsSlice { |
| 50 |
return newResourceMetricsSlice(&ms.getOrig().ResourceMetrics, ms.getState()) |
| 51 |
} |
| 52 |
|
| 53 |
// CopyTo copies all properties from the current struct overriding the destination. |
| 54 |
func (ms Metrics) CopyTo(dest Metrics) { |
| 55 |
dest.getState().AssertMutable() |
| 56 |
internal.CopyExportMetricsServiceRequest(dest.getOrig(), ms.getOrig()) |
| 57 |
} |
| 58 |
|
| 59 |
func (ms Metrics) getOrig() *internal.ExportMetricsServiceRequest { |
| 60 |
return internal.GetMetricsOrig(internal.MetricsWrapper(ms)) |
| 61 |
} |
| 62 |
|
| 63 |
func (ms Metrics) getState() *internal.State { |
| 64 |
return internal.GetMetricsState(internal.MetricsWrapper(ms)) |
| 65 |
} |