From aab6d5ad6965f0302acb1fc82044c3e7b2267365 Mon Sep 17 00:00:00 2001 From: Mansur Marvanov Date: Sat, 23 Jul 2022 17:48:51 +0900 Subject: [PATCH] Add helper functions to get serializable telemetry objects --- .../cmd/pdatagen/internal/base_structs.go | 4 ++ pdata/internal/generated_common.go | 4 ++ pdata/internal/generated_plog.go | 12 ++++ pdata/internal/generated_pmetric.go | 60 +++++++++++++++++++ pdata/internal/generated_ptrace.go | 24 ++++++++ pdata/internal/generated_resource.go | 4 ++ 6 files changed, 108 insertions(+) diff --git a/pdata/internal/cmd/pdatagen/internal/base_structs.go b/pdata/internal/cmd/pdatagen/internal/base_structs.go index 060a9dbebe8..b19f38541e3 100644 --- a/pdata/internal/cmd/pdatagen/internal/base_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/base_structs.go @@ -42,6 +42,10 @@ func New${structName}() ${structName} { return new${structName}(&${originName}{}) } +func ${structName}ToProto(ms ${structName}) *${originName} { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ${structName}) MoveTo(dest ${structName}) { diff --git a/pdata/internal/generated_common.go b/pdata/internal/generated_common.go index f1155285ace..e84851ff8b0 100644 --- a/pdata/internal/generated_common.go +++ b/pdata/internal/generated_common.go @@ -44,6 +44,10 @@ func NewInstrumentationScope() InstrumentationScope { return newInstrumentationScope(&otlpcommon.InstrumentationScope{}) } +func InstrumentationScopeToProto(ms InstrumentationScope) *otlpcommon.InstrumentationScope { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms InstrumentationScope) MoveTo(dest InstrumentationScope) { diff --git a/pdata/internal/generated_plog.go b/pdata/internal/generated_plog.go index 2fd319d6556..ca0c248b4f3 100644 --- a/pdata/internal/generated_plog.go +++ b/pdata/internal/generated_plog.go @@ -183,6 +183,10 @@ func NewResourceLogs() ResourceLogs { return newResourceLogs(&otlplogs.ResourceLogs{}) } +func ResourceLogsToProto(ms ResourceLogs) *otlplogs.ResourceLogs { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ResourceLogs) MoveTo(dest ResourceLogs) { @@ -377,6 +381,10 @@ func NewScopeLogs() ScopeLogs { return newScopeLogs(&otlplogs.ScopeLogs{}) } +func ScopeLogsToProto(ms ScopeLogs) *otlplogs.ScopeLogs { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ScopeLogs) MoveTo(dest ScopeLogs) { @@ -572,6 +580,10 @@ func NewLogRecord() LogRecord { return newLogRecord(&otlplogs.LogRecord{}) } +func LogRecordToProto(ms LogRecord) *otlplogs.LogRecord { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms LogRecord) MoveTo(dest LogRecord) { diff --git a/pdata/internal/generated_pmetric.go b/pdata/internal/generated_pmetric.go index 86956a1abb5..582dc0e27a4 100644 --- a/pdata/internal/generated_pmetric.go +++ b/pdata/internal/generated_pmetric.go @@ -183,6 +183,10 @@ func NewResourceMetrics() ResourceMetrics { return newResourceMetrics(&otlpmetrics.ResourceMetrics{}) } +func ResourceMetricsToProto(ms ResourceMetrics) *otlpmetrics.ResourceMetrics { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ResourceMetrics) MoveTo(dest ResourceMetrics) { @@ -377,6 +381,10 @@ func NewScopeMetrics() ScopeMetrics { return newScopeMetrics(&otlpmetrics.ScopeMetrics{}) } +func ScopeMetricsToProto(ms ScopeMetrics) *otlpmetrics.ScopeMetrics { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ScopeMetrics) MoveTo(dest ScopeMetrics) { @@ -572,6 +580,10 @@ func NewMetric() Metric { return newMetric(&otlpmetrics.Metric{}) } +func MetricToProto(ms Metric) *otlpmetrics.Metric { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms Metric) MoveTo(dest Metric) { @@ -745,6 +757,10 @@ func NewGauge() Gauge { return newGauge(&otlpmetrics.Gauge{}) } +func GaugeToProto(ms Gauge) *otlpmetrics.Gauge { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms Gauge) MoveTo(dest Gauge) { @@ -785,6 +801,10 @@ func NewSum() Sum { return newSum(&otlpmetrics.Sum{}) } +func SumToProto(ms Sum) *otlpmetrics.Sum { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms Sum) MoveTo(dest Sum) { @@ -847,6 +867,10 @@ func NewHistogram() Histogram { return newHistogram(&otlpmetrics.Histogram{}) } +func HistogramToProto(ms Histogram) *otlpmetrics.Histogram { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms Histogram) MoveTo(dest Histogram) { @@ -899,6 +923,10 @@ func NewExponentialHistogram() ExponentialHistogram { return newExponentialHistogram(&otlpmetrics.ExponentialHistogram{}) } +func ExponentialHistogramToProto(ms ExponentialHistogram) *otlpmetrics.ExponentialHistogram { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ExponentialHistogram) MoveTo(dest ExponentialHistogram) { @@ -950,6 +978,10 @@ func NewSummary() Summary { return newSummary(&otlpmetrics.Summary{}) } +func SummaryToProto(ms Summary) *otlpmetrics.Summary { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms Summary) MoveTo(dest Summary) { @@ -1127,6 +1159,10 @@ func NewNumberDataPoint() NumberDataPoint { return newNumberDataPoint(&otlpmetrics.NumberDataPoint{}) } +func NumberDataPointToProto(ms NumberDataPoint) *otlpmetrics.NumberDataPoint { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms NumberDataPoint) MoveTo(dest NumberDataPoint) { @@ -1386,6 +1422,10 @@ func NewHistogramDataPoint() HistogramDataPoint { return newHistogramDataPoint(&otlpmetrics.HistogramDataPoint{}) } +func HistogramDataPointToProto(ms HistogramDataPoint) *otlpmetrics.HistogramDataPoint { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms HistogramDataPoint) MoveTo(dest HistogramDataPoint) { @@ -1710,6 +1750,10 @@ func NewExponentialHistogramDataPoint() ExponentialHistogramDataPoint { return newExponentialHistogramDataPoint(&otlpmetrics.ExponentialHistogramDataPoint{}) } +func ExponentialHistogramDataPointToProto(ms ExponentialHistogramDataPoint) *otlpmetrics.ExponentialHistogramDataPoint { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ExponentialHistogramDataPoint) MoveTo(dest ExponentialHistogramDataPoint) { @@ -1894,6 +1938,10 @@ func NewBuckets() Buckets { return newBuckets(&otlpmetrics.ExponentialHistogramDataPoint_Buckets{}) } +func BucketsToProto(ms Buckets) *otlpmetrics.ExponentialHistogramDataPoint_Buckets { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms Buckets) MoveTo(dest Buckets) { @@ -2093,6 +2141,10 @@ func NewSummaryDataPoint() SummaryDataPoint { return newSummaryDataPoint(&otlpmetrics.SummaryDataPoint{}) } +func SummaryDataPointToProto(ms SummaryDataPoint) *otlpmetrics.SummaryDataPoint { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms SummaryDataPoint) MoveTo(dest SummaryDataPoint) { @@ -2331,6 +2383,10 @@ func NewValueAtQuantile() ValueAtQuantile { return newValueAtQuantile(&otlpmetrics.SummaryDataPoint_ValueAtQuantile{}) } +func ValueAtQuantileToProto(ms ValueAtQuantile) *otlpmetrics.SummaryDataPoint_ValueAtQuantile { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ValueAtQuantile) MoveTo(dest ValueAtQuantile) { @@ -2508,6 +2564,10 @@ func NewExemplar() Exemplar { return newExemplar(&otlpmetrics.Exemplar{}) } +func ExemplarToProto(ms Exemplar) *otlpmetrics.Exemplar { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms Exemplar) MoveTo(dest Exemplar) { diff --git a/pdata/internal/generated_ptrace.go b/pdata/internal/generated_ptrace.go index dc40b5e131a..e5cf481f94b 100644 --- a/pdata/internal/generated_ptrace.go +++ b/pdata/internal/generated_ptrace.go @@ -183,6 +183,10 @@ func NewResourceSpans() ResourceSpans { return newResourceSpans(&otlptrace.ResourceSpans{}) } +func ResourceSpansToProto(ms ResourceSpans) *otlptrace.ResourceSpans { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ResourceSpans) MoveTo(dest ResourceSpans) { @@ -377,6 +381,10 @@ func NewScopeSpans() ScopeSpans { return newScopeSpans(&otlptrace.ScopeSpans{}) } +func ScopeSpansToProto(ms ScopeSpans) *otlptrace.ScopeSpans { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms ScopeSpans) MoveTo(dest ScopeSpans) { @@ -572,6 +580,10 @@ func NewSpan() Span { return newSpan(&otlptrace.Span{}) } +func SpanToProto(ms Span) *otlptrace.Span { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms Span) MoveTo(dest Span) { @@ -889,6 +901,10 @@ func NewSpanEvent() SpanEvent { return newSpanEvent(&otlptrace.Span_Event{}) } +func SpanEventToProto(ms SpanEvent) *otlptrace.Span_Event { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms SpanEvent) MoveTo(dest SpanEvent) { @@ -1101,6 +1117,10 @@ func NewSpanLink() SpanLink { return newSpanLink(&otlptrace.Span_Link{}) } +func SpanLinkToProto(ms SpanLink) *otlptrace.Span_Link { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms SpanLink) MoveTo(dest SpanLink) { @@ -1186,6 +1206,10 @@ func NewSpanStatus() SpanStatus { return newSpanStatus(&otlptrace.Status{}) } +func SpanStatusToProto(ms SpanStatus) *otlptrace.Status { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms SpanStatus) MoveTo(dest SpanStatus) { diff --git a/pdata/internal/generated_resource.go b/pdata/internal/generated_resource.go index cc4bb64f058..a49b71d97be 100644 --- a/pdata/internal/generated_resource.go +++ b/pdata/internal/generated_resource.go @@ -44,6 +44,10 @@ func NewResource() Resource { return newResource(&otlpresource.Resource{}) } +func ResourceToProto(ms Resource) *otlpresource.Resource { + return ms.orig +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value func (ms Resource) MoveTo(dest Resource) {