diff --git a/pdata/internal/cmd/pdatagen/internal/files.go b/pdata/internal/cmd/pdatagen/internal/files.go index 3b7c83d578e..eee78010762 100644 --- a/pdata/internal/cmd/pdatagen/internal/files.go +++ b/pdata/internal/cmd/pdatagen/internal/files.go @@ -41,14 +41,18 @@ const header = `// Copyright The OpenTelemetry Authors var AllFiles = []*File{ commonFile, metricsFile, + metricsOtlpFile, resourceFile, primitiveSliceFile, traceFile, + traceOtlpFile, logFile, + logOtlpFile, } // File represents the struct for one generated file. type File struct { + Path string Name string PackageName string imports []string @@ -82,7 +86,7 @@ func (f *File) GenerateFile() error { // ignore gosec complain about permissions being `0644`. //nolint:gosec - return os.WriteFile(filepath.Join("pdata", f.PackageName, generateFileName(f.Name)), sb.Bytes(), 0644) + return os.WriteFile(filepath.Join(f.Path, f.PackageName, generateFileName(f.Name)), sb.Bytes(), 0644) } // GenerateTestFile generates tests for the configured data structures for this File. @@ -109,7 +113,7 @@ func (f *File) GenerateTestFile() error { // ignore gosec complain about permissions being `0644`. //nolint:gosec - return os.WriteFile(filepath.Join("pdata", f.PackageName, generateTestFileName(f.Name)), sb.Bytes(), 0644) + return os.WriteFile(filepath.Join(f.Path, f.PackageName, generateTestFileName(f.Name)), sb.Bytes(), 0644) } // GenerateInternalFile generates the internal pdata structures for this File. diff --git a/pdata/internal/cmd/pdatagen/internal/common_structs.go b/pdata/internal/cmd/pdatagen/internal/pcommon_structs.go similarity index 99% rename from pdata/internal/cmd/pdatagen/internal/common_structs.go rename to pdata/internal/cmd/pdatagen/internal/pcommon_structs.go index 94ea09bee2b..0ce9cc7686f 100644 --- a/pdata/internal/cmd/pdatagen/internal/common_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/pcommon_structs.go @@ -15,6 +15,7 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var commonFile = &File{ + Path: "pdata", Name: "common", PackageName: "pcommon", imports: []string{ diff --git a/pdata/internal/cmd/pdatagen/internal/log_structs.go b/pdata/internal/cmd/pdatagen/internal/plog_structs.go similarity index 97% rename from pdata/internal/cmd/pdatagen/internal/log_structs.go rename to pdata/internal/cmd/pdatagen/internal/plog_structs.go index 6a638e2eac1..feea89f3996 100644 --- a/pdata/internal/cmd/pdatagen/internal/log_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/plog_structs.go @@ -15,11 +15,13 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var logFile = &File{ + Path: "pdata", Name: "logs", PackageName: "plog", imports: []string{ `"sort"`, ``, + `"go.opentelemetry.io/collector/pdata/internal"`, `otlplogs "go.opentelemetry.io/collector/pdata/internal/data/protogen/logs/v1"`, }, testImports: []string{ diff --git a/pdata/internal/cmd/pdatagen/internal/plogotlp_structs.go b/pdata/internal/cmd/pdatagen/internal/plogotlp_structs.go new file mode 100644 index 00000000000..b42c3486f54 --- /dev/null +++ b/pdata/internal/cmd/pdatagen/internal/plogotlp_structs.go @@ -0,0 +1,61 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" +import ( + "path/filepath" +) + +var logOtlpFile = &File{ + Path: filepath.Join("pdata", "plog"), + Name: "logs_otlp", + PackageName: "plogotlp", + imports: []string{ + `"sort"`, + ``, + `"go.opentelemetry.io/collector/pdata/internal"`, + `otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1"`, + }, + testImports: []string{ + `"testing"`, + ``, + `"github.com/stretchr/testify/assert"`, + ``, + `"go.opentelemetry.io/collector/pdata/internal"`, + `otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1"`, + }, + structs: []baseStruct{ + exportLogsPartialSuccess, + }, +} + +var exportLogsPartialSuccess = &messageValueStruct{ + structName: "ExportLogsPartialSuccess", + description: "// ExportLogsPartialSuccess represents the details of a partially successful export request.", + originFullName: "otlpcollectorlog.ExportLogsPartialSuccess", + fields: []baseField{ + &primitiveField{ + fieldName: "RejectedLogRecords", + returnType: "int64", + defaultVal: `int64(0)`, + testVal: `int64(13)`, + }, + &primitiveField{ + fieldName: "ErrorMessage", + returnType: "string", + defaultVal: `""`, + testVal: `"error message"`, + }, + }, +} diff --git a/pdata/internal/cmd/pdatagen/internal/metrics_structs.go b/pdata/internal/cmd/pdatagen/internal/pmetric_structs.go similarity index 99% rename from pdata/internal/cmd/pdatagen/internal/metrics_structs.go rename to pdata/internal/cmd/pdatagen/internal/pmetric_structs.go index 10b60a6f091..16ee48a682d 100644 --- a/pdata/internal/cmd/pdatagen/internal/metrics_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/pmetric_structs.go @@ -15,11 +15,13 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var metricsFile = &File{ + Path: "pdata", Name: "metrics", PackageName: "pmetric", imports: []string{ `"sort"`, ``, + `"go.opentelemetry.io/collector/pdata/internal"`, `otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"`, }, testImports: []string{ @@ -28,7 +30,6 @@ var metricsFile = &File{ `"github.com/stretchr/testify/assert"`, ``, `"go.opentelemetry.io/collector/pdata/internal"`, - `"go.opentelemetry.io/collector/pdata/internal/data"`, `otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"`, `"go.opentelemetry.io/collector/pdata/pcommon"`, }, diff --git a/pdata/internal/cmd/pdatagen/internal/pmetricotlp_structs.go b/pdata/internal/cmd/pdatagen/internal/pmetricotlp_structs.go new file mode 100644 index 00000000000..d2c5ec15abb --- /dev/null +++ b/pdata/internal/cmd/pdatagen/internal/pmetricotlp_structs.go @@ -0,0 +1,62 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" + +import ( + "path/filepath" +) + +var metricsOtlpFile = &File{ + Path: filepath.Join("pdata", "pmetric"), + Name: "metrics_otlp", + PackageName: "pmetricotlp", + imports: []string{ + `"sort"`, + ``, + `"go.opentelemetry.io/collector/pdata/internal"`, + `otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1"`, + }, + testImports: []string{ + `"testing"`, + ``, + `"github.com/stretchr/testify/assert"`, + ``, + `"go.opentelemetry.io/collector/pdata/internal"`, + `otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1"`, + }, + structs: []baseStruct{ + exportMetricsPartialSuccess, + }, +} + +var exportMetricsPartialSuccess = &messageValueStruct{ + structName: "ExportMetricsPartialSuccess", + description: "// ExportMetricsPartialSuccess represents the details of a partially successful export request.", + originFullName: "otlpcollectormetrics.ExportMetricsPartialSuccess", + fields: []baseField{ + &primitiveField{ + fieldName: "RejectedDataPoints", + returnType: "int64", + defaultVal: `int64(0)`, + testVal: `int64(13)`, + }, + &primitiveField{ + fieldName: "ErrorMessage", + returnType: "string", + defaultVal: `""`, + testVal: `"error message"`, + }, + }, +} diff --git a/pdata/internal/cmd/pdatagen/internal/primitive_slice_structs.go b/pdata/internal/cmd/pdatagen/internal/primitive_slice_structs.go index 15827d2839c..ca814a046d5 100644 --- a/pdata/internal/cmd/pdatagen/internal/primitive_slice_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/primitive_slice_structs.go @@ -223,6 +223,7 @@ func (iss *primitiveSliceStruct) generateInternal(sb *bytes.Buffer) { } var primitiveSliceFile = &File{ + Path: "pdata", Name: "primitive_slice", PackageName: "pcommon", testImports: []string{ diff --git a/pdata/internal/cmd/pdatagen/internal/trace_structs.go b/pdata/internal/cmd/pdatagen/internal/ptrace_structs.go similarity index 99% rename from pdata/internal/cmd/pdatagen/internal/trace_structs.go rename to pdata/internal/cmd/pdatagen/internal/ptrace_structs.go index 4c5c66719a8..b9a6a4ee1c0 100644 --- a/pdata/internal/cmd/pdatagen/internal/trace_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/ptrace_structs.go @@ -15,6 +15,7 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var traceFile = &File{ + Path: "pdata", Name: "traces", PackageName: "ptrace", imports: []string{ diff --git a/pdata/internal/cmd/pdatagen/internal/ptraceotlp_structs.go b/pdata/internal/cmd/pdatagen/internal/ptraceotlp_structs.go new file mode 100644 index 00000000000..ec298c2d5a4 --- /dev/null +++ b/pdata/internal/cmd/pdatagen/internal/ptraceotlp_structs.go @@ -0,0 +1,62 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" + +import ( + "path/filepath" +) + +var traceOtlpFile = &File{ + Path: filepath.Join("pdata", "ptrace"), + Name: "traces_otlp", + PackageName: "ptraceotlp", + imports: []string{ + `"sort"`, + ``, + `"go.opentelemetry.io/collector/pdata/internal"`, + `otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1"`, + }, + testImports: []string{ + `"testing"`, + ``, + `"github.com/stretchr/testify/assert"`, + ``, + `"go.opentelemetry.io/collector/pdata/internal"`, + `otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1"`, + }, + structs: []baseStruct{ + exportTracePartialSuccess, + }, +} + +var exportTracePartialSuccess = &messageValueStruct{ + structName: "ExportTracePartialSuccess", + description: "// ExportTracePartialSuccess represents the details of a partially successful export request.", + originFullName: "otlpcollectortrace.ExportTracePartialSuccess", + fields: []baseField{ + &primitiveField{ + fieldName: "RejectedSpans", + returnType: "int64", + defaultVal: `int64(0)`, + testVal: `int64(13)`, + }, + &primitiveField{ + fieldName: "ErrorMessage", + returnType: "string", + defaultVal: `""`, + testVal: `"error message"`, + }, + }, +} diff --git a/pdata/internal/cmd/pdatagen/internal/resource_structs.go b/pdata/internal/cmd/pdatagen/internal/resource_structs.go index 249a07faf74..d1850eeb6be 100644 --- a/pdata/internal/cmd/pdatagen/internal/resource_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/resource_structs.go @@ -15,6 +15,7 @@ package internal // import "go.opentelemetry.io/collector/pdata/internal/cmd/pdatagen/internal" var resourceFile = &File{ + Path: "pdata", Name: "resource", PackageName: "pcommon", imports: []string{ diff --git a/pdata/internal/generated_wrapper_logs_otlp.go b/pdata/internal/generated_wrapper_logs_otlp.go new file mode 100644 index 00000000000..e005f6c2d70 --- /dev/null +++ b/pdata/internal/generated_wrapper_logs_otlp.go @@ -0,0 +1,46 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package internal + +import ( + otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" +) + +type ExportLogsPartialSuccess struct { + orig *otlpcollectorlog.ExportLogsPartialSuccess +} + +func GetOrigExportLogsPartialSuccess(ms ExportLogsPartialSuccess) *otlpcollectorlog.ExportLogsPartialSuccess { + return ms.orig +} + +func NewExportLogsPartialSuccess(orig *otlpcollectorlog.ExportLogsPartialSuccess) ExportLogsPartialSuccess { + return ExportLogsPartialSuccess{orig: orig} +} + +func GenerateTestExportLogsPartialSuccess() ExportLogsPartialSuccess { + orig := otlpcollectorlog.ExportLogsPartialSuccess{} + tv := NewExportLogsPartialSuccess(&orig) + FillTestExportLogsPartialSuccess(tv) + return tv +} + +func FillTestExportLogsPartialSuccess(tv ExportLogsPartialSuccess) { + tv.orig.RejectedLogRecords = int64(13) + tv.orig.ErrorMessage = "error message" +} diff --git a/pdata/internal/generated_wrapper_metrics_otlp.go b/pdata/internal/generated_wrapper_metrics_otlp.go new file mode 100644 index 00000000000..64571523ee5 --- /dev/null +++ b/pdata/internal/generated_wrapper_metrics_otlp.go @@ -0,0 +1,46 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package internal + +import ( + otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" +) + +type ExportMetricsPartialSuccess struct { + orig *otlpcollectormetrics.ExportMetricsPartialSuccess +} + +func GetOrigExportMetricsPartialSuccess(ms ExportMetricsPartialSuccess) *otlpcollectormetrics.ExportMetricsPartialSuccess { + return ms.orig +} + +func NewExportMetricsPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSuccess) ExportMetricsPartialSuccess { + return ExportMetricsPartialSuccess{orig: orig} +} + +func GenerateTestExportMetricsPartialSuccess() ExportMetricsPartialSuccess { + orig := otlpcollectormetrics.ExportMetricsPartialSuccess{} + tv := NewExportMetricsPartialSuccess(&orig) + FillTestExportMetricsPartialSuccess(tv) + return tv +} + +func FillTestExportMetricsPartialSuccess(tv ExportMetricsPartialSuccess) { + tv.orig.RejectedDataPoints = int64(13) + tv.orig.ErrorMessage = "error message" +} diff --git a/pdata/internal/generated_wrapper_traces_otlp.go b/pdata/internal/generated_wrapper_traces_otlp.go new file mode 100644 index 00000000000..5754ae5e050 --- /dev/null +++ b/pdata/internal/generated_wrapper_traces_otlp.go @@ -0,0 +1,46 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package internal + +import ( + otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" +) + +type ExportTracePartialSuccess struct { + orig *otlpcollectortrace.ExportTracePartialSuccess +} + +func GetOrigExportTracePartialSuccess(ms ExportTracePartialSuccess) *otlpcollectortrace.ExportTracePartialSuccess { + return ms.orig +} + +func NewExportTracePartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess) ExportTracePartialSuccess { + return ExportTracePartialSuccess{orig: orig} +} + +func GenerateTestExportTracePartialSuccess() ExportTracePartialSuccess { + orig := otlpcollectortrace.ExportTracePartialSuccess{} + tv := NewExportTracePartialSuccess(&orig) + FillTestExportTracePartialSuccess(tv) + return tv +} + +func FillTestExportTracePartialSuccess(tv ExportTracePartialSuccess) { + tv.orig.RejectedSpans = int64(13) + tv.orig.ErrorMessage = "error message" +} diff --git a/pdata/plog/plogotlp/generated_logs_otlp.go b/pdata/plog/plogotlp/generated_logs_otlp.go new file mode 100644 index 00000000000..e5ee22fce94 --- /dev/null +++ b/pdata/plog/plogotlp/generated_logs_otlp.go @@ -0,0 +1,82 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package plogotlp + +import ( + "go.opentelemetry.io/collector/pdata/internal" + otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" +) + +// ExportLogsPartialSuccess represents the details of a partially successful export request. +// +// This is a reference type, if passed by value and callee modifies it the +// caller will see the modification. +// +// Must use NewExportLogsPartialSuccess function to create new instances. +// Important: zero-initialized instance is not valid for use. + +type ExportLogsPartialSuccess internal.ExportLogsPartialSuccess + +func newExportLogsPartialSuccess(orig *otlpcollectorlog.ExportLogsPartialSuccess) ExportLogsPartialSuccess { + return ExportLogsPartialSuccess(internal.NewExportLogsPartialSuccess(orig)) +} + +func (ms ExportLogsPartialSuccess) getOrig() *otlpcollectorlog.ExportLogsPartialSuccess { + return internal.GetOrigExportLogsPartialSuccess(internal.ExportLogsPartialSuccess(ms)) +} + +// NewExportLogsPartialSuccess creates a new empty ExportLogsPartialSuccess. +// +// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, +// OR directly access the member if this is embedded in another struct. +func NewExportLogsPartialSuccess() ExportLogsPartialSuccess { + return newExportLogsPartialSuccess(&otlpcollectorlog.ExportLogsPartialSuccess{}) +} + +// MoveTo moves all properties from the current struct overriding the destination and +// resetting the current instance to its zero value +func (ms ExportLogsPartialSuccess) MoveTo(dest ExportLogsPartialSuccess) { + *dest.getOrig() = *ms.getOrig() + *ms.getOrig() = otlpcollectorlog.ExportLogsPartialSuccess{} +} + +// RejectedLogRecords returns the rejectedlogrecords associated with this ExportLogsPartialSuccess. +func (ms ExportLogsPartialSuccess) RejectedLogRecords() int64 { + return ms.getOrig().RejectedLogRecords +} + +// SetRejectedLogRecords replaces the rejectedlogrecords associated with this ExportLogsPartialSuccess. +func (ms ExportLogsPartialSuccess) SetRejectedLogRecords(v int64) { + ms.getOrig().RejectedLogRecords = v +} + +// ErrorMessage returns the errormessage associated with this ExportLogsPartialSuccess. +func (ms ExportLogsPartialSuccess) ErrorMessage() string { + return ms.getOrig().ErrorMessage +} + +// SetErrorMessage replaces the errormessage associated with this ExportLogsPartialSuccess. +func (ms ExportLogsPartialSuccess) SetErrorMessage(v string) { + ms.getOrig().ErrorMessage = v +} + +// CopyTo copies all properties from the current struct overriding the destination. +func (ms ExportLogsPartialSuccess) CopyTo(dest ExportLogsPartialSuccess) { + dest.SetRejectedLogRecords(ms.RejectedLogRecords()) + dest.SetErrorMessage(ms.ErrorMessage()) +} diff --git a/pdata/plog/plogotlp/generated_logs_otlp_test.go b/pdata/plog/plogotlp/generated_logs_otlp_test.go new file mode 100644 index 00000000000..ae1024d4f59 --- /dev/null +++ b/pdata/plog/plogotlp/generated_logs_otlp_test.go @@ -0,0 +1,58 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package plogotlp + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "go.opentelemetry.io/collector/pdata/internal" +) + +func TestExportLogsPartialSuccess_MoveTo(t *testing.T) { + ms := ExportLogsPartialSuccess(internal.GenerateTestExportLogsPartialSuccess()) + dest := NewExportLogsPartialSuccess() + ms.MoveTo(dest) + assert.Equal(t, NewExportLogsPartialSuccess(), ms) + assert.Equal(t, ExportLogsPartialSuccess(internal.GenerateTestExportLogsPartialSuccess()), dest) +} + +func TestExportLogsPartialSuccess_CopyTo(t *testing.T) { + ms := NewExportLogsPartialSuccess() + orig := NewExportLogsPartialSuccess() + orig.CopyTo(ms) + assert.Equal(t, orig, ms) + orig = ExportLogsPartialSuccess(internal.GenerateTestExportLogsPartialSuccess()) + orig.CopyTo(ms) + assert.Equal(t, orig, ms) +} + +func TestExportLogsPartialSuccess_RejectedLogRecords(t *testing.T) { + ms := NewExportLogsPartialSuccess() + assert.Equal(t, int64(0), ms.RejectedLogRecords()) + ms.SetRejectedLogRecords(int64(13)) + assert.Equal(t, int64(13), ms.RejectedLogRecords()) +} + +func TestExportLogsPartialSuccess_ErrorMessage(t *testing.T) { + ms := NewExportLogsPartialSuccess() + assert.Equal(t, "", ms.ErrorMessage()) + ms.SetErrorMessage("error message") + assert.Equal(t, "error message", ms.ErrorMessage()) +} diff --git a/pdata/plog/plogotlp/response.go b/pdata/plog/plogotlp/response.go index e91b2b0fb5b..4cd1a64e686 100644 --- a/pdata/plog/plogotlp/response.go +++ b/pdata/plog/plogotlp/response.go @@ -16,6 +16,7 @@ package plogotlp // import "go.opentelemetry.io/collector/pdata/plog/plogotlp" import ( "bytes" + "go.opentelemetry.io/collector/pdata/internal" otlpcollectorlog "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/logs/v1" "go.opentelemetry.io/collector/pdata/plog/internal/plogjson" ) @@ -53,3 +54,8 @@ func (lr Response) MarshalJSON() ([]byte, error) { func (lr Response) UnmarshalJSON(data []byte) error { return plogjson.UnmarshalExportLogsServiceResponse(data, lr.orig) } + +// PartialSuccess returns the ExportLogsPartialSuccess associated with this Response. +func (lr Response) PartialSuccess() ExportLogsPartialSuccess { + return ExportLogsPartialSuccess(internal.NewExportLogsPartialSuccess(&lr.orig.PartialSuccess)) +} diff --git a/pdata/pmetric/pmetricotlp/generated_metrics_otlp.go b/pdata/pmetric/pmetricotlp/generated_metrics_otlp.go new file mode 100644 index 00000000000..072d82fb3ce --- /dev/null +++ b/pdata/pmetric/pmetricotlp/generated_metrics_otlp.go @@ -0,0 +1,82 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package pmetricotlp + +import ( + "go.opentelemetry.io/collector/pdata/internal" + otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" +) + +// ExportMetricsPartialSuccess represents the details of a partially successful export request. +// +// This is a reference type, if passed by value and callee modifies it the +// caller will see the modification. +// +// Must use NewExportMetricsPartialSuccess function to create new instances. +// Important: zero-initialized instance is not valid for use. + +type ExportMetricsPartialSuccess internal.ExportMetricsPartialSuccess + +func newExportMetricsPartialSuccess(orig *otlpcollectormetrics.ExportMetricsPartialSuccess) ExportMetricsPartialSuccess { + return ExportMetricsPartialSuccess(internal.NewExportMetricsPartialSuccess(orig)) +} + +func (ms ExportMetricsPartialSuccess) getOrig() *otlpcollectormetrics.ExportMetricsPartialSuccess { + return internal.GetOrigExportMetricsPartialSuccess(internal.ExportMetricsPartialSuccess(ms)) +} + +// NewExportMetricsPartialSuccess creates a new empty ExportMetricsPartialSuccess. +// +// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, +// OR directly access the member if this is embedded in another struct. +func NewExportMetricsPartialSuccess() ExportMetricsPartialSuccess { + return newExportMetricsPartialSuccess(&otlpcollectormetrics.ExportMetricsPartialSuccess{}) +} + +// MoveTo moves all properties from the current struct overriding the destination and +// resetting the current instance to its zero value +func (ms ExportMetricsPartialSuccess) MoveTo(dest ExportMetricsPartialSuccess) { + *dest.getOrig() = *ms.getOrig() + *ms.getOrig() = otlpcollectormetrics.ExportMetricsPartialSuccess{} +} + +// RejectedDataPoints returns the rejecteddatapoints associated with this ExportMetricsPartialSuccess. +func (ms ExportMetricsPartialSuccess) RejectedDataPoints() int64 { + return ms.getOrig().RejectedDataPoints +} + +// SetRejectedDataPoints replaces the rejecteddatapoints associated with this ExportMetricsPartialSuccess. +func (ms ExportMetricsPartialSuccess) SetRejectedDataPoints(v int64) { + ms.getOrig().RejectedDataPoints = v +} + +// ErrorMessage returns the errormessage associated with this ExportMetricsPartialSuccess. +func (ms ExportMetricsPartialSuccess) ErrorMessage() string { + return ms.getOrig().ErrorMessage +} + +// SetErrorMessage replaces the errormessage associated with this ExportMetricsPartialSuccess. +func (ms ExportMetricsPartialSuccess) SetErrorMessage(v string) { + ms.getOrig().ErrorMessage = v +} + +// CopyTo copies all properties from the current struct overriding the destination. +func (ms ExportMetricsPartialSuccess) CopyTo(dest ExportMetricsPartialSuccess) { + dest.SetRejectedDataPoints(ms.RejectedDataPoints()) + dest.SetErrorMessage(ms.ErrorMessage()) +} diff --git a/pdata/pmetric/pmetricotlp/generated_metrics_otlp_test.go b/pdata/pmetric/pmetricotlp/generated_metrics_otlp_test.go new file mode 100644 index 00000000000..5b0d958aba3 --- /dev/null +++ b/pdata/pmetric/pmetricotlp/generated_metrics_otlp_test.go @@ -0,0 +1,58 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package pmetricotlp + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "go.opentelemetry.io/collector/pdata/internal" +) + +func TestExportMetricsPartialSuccess_MoveTo(t *testing.T) { + ms := ExportMetricsPartialSuccess(internal.GenerateTestExportMetricsPartialSuccess()) + dest := NewExportMetricsPartialSuccess() + ms.MoveTo(dest) + assert.Equal(t, NewExportMetricsPartialSuccess(), ms) + assert.Equal(t, ExportMetricsPartialSuccess(internal.GenerateTestExportMetricsPartialSuccess()), dest) +} + +func TestExportMetricsPartialSuccess_CopyTo(t *testing.T) { + ms := NewExportMetricsPartialSuccess() + orig := NewExportMetricsPartialSuccess() + orig.CopyTo(ms) + assert.Equal(t, orig, ms) + orig = ExportMetricsPartialSuccess(internal.GenerateTestExportMetricsPartialSuccess()) + orig.CopyTo(ms) + assert.Equal(t, orig, ms) +} + +func TestExportMetricsPartialSuccess_RejectedDataPoints(t *testing.T) { + ms := NewExportMetricsPartialSuccess() + assert.Equal(t, int64(0), ms.RejectedDataPoints()) + ms.SetRejectedDataPoints(int64(13)) + assert.Equal(t, int64(13), ms.RejectedDataPoints()) +} + +func TestExportMetricsPartialSuccess_ErrorMessage(t *testing.T) { + ms := NewExportMetricsPartialSuccess() + assert.Equal(t, "", ms.ErrorMessage()) + ms.SetErrorMessage("error message") + assert.Equal(t, "error message", ms.ErrorMessage()) +} diff --git a/pdata/pmetric/pmetricotlp/response.go b/pdata/pmetric/pmetricotlp/response.go index be071789d5f..bc840abb9f4 100644 --- a/pdata/pmetric/pmetricotlp/response.go +++ b/pdata/pmetric/pmetricotlp/response.go @@ -16,6 +16,7 @@ package pmetricotlp // import "go.opentelemetry.io/collector/pdata/pmetric/pmetr import ( "bytes" + "go.opentelemetry.io/collector/pdata/internal" otlpcollectormetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/metrics/v1" "go.opentelemetry.io/collector/pdata/pmetric/internal/pmetricjson" ) @@ -53,3 +54,8 @@ func (mr Response) MarshalJSON() ([]byte, error) { func (mr Response) UnmarshalJSON(data []byte) error { return pmetricjson.UnmarshalExportMetricsServiceResponse(data, mr.orig) } + +// PartialSuccess returns the ExportLogsPartialSuccess associated with this Response. +func (mr Response) PartialSuccess() ExportMetricsPartialSuccess { + return ExportMetricsPartialSuccess(internal.NewExportMetricsPartialSuccess(&mr.orig.PartialSuccess)) +} diff --git a/pdata/ptrace/ptraceotlp/generated_traces_otlp.go b/pdata/ptrace/ptraceotlp/generated_traces_otlp.go new file mode 100644 index 00000000000..e2ec9c8b6cd --- /dev/null +++ b/pdata/ptrace/ptraceotlp/generated_traces_otlp.go @@ -0,0 +1,82 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package ptraceotlp + +import ( + "go.opentelemetry.io/collector/pdata/internal" + otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" +) + +// ExportTracePartialSuccess represents the details of a partially successful export request. +// +// This is a reference type, if passed by value and callee modifies it the +// caller will see the modification. +// +// Must use NewExportTracePartialSuccess function to create new instances. +// Important: zero-initialized instance is not valid for use. + +type ExportTracePartialSuccess internal.ExportTracePartialSuccess + +func newExportTracePartialSuccess(orig *otlpcollectortrace.ExportTracePartialSuccess) ExportTracePartialSuccess { + return ExportTracePartialSuccess(internal.NewExportTracePartialSuccess(orig)) +} + +func (ms ExportTracePartialSuccess) getOrig() *otlpcollectortrace.ExportTracePartialSuccess { + return internal.GetOrigExportTracePartialSuccess(internal.ExportTracePartialSuccess(ms)) +} + +// NewExportTracePartialSuccess creates a new empty ExportTracePartialSuccess. +// +// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, +// OR directly access the member if this is embedded in another struct. +func NewExportTracePartialSuccess() ExportTracePartialSuccess { + return newExportTracePartialSuccess(&otlpcollectortrace.ExportTracePartialSuccess{}) +} + +// MoveTo moves all properties from the current struct overriding the destination and +// resetting the current instance to its zero value +func (ms ExportTracePartialSuccess) MoveTo(dest ExportTracePartialSuccess) { + *dest.getOrig() = *ms.getOrig() + *ms.getOrig() = otlpcollectortrace.ExportTracePartialSuccess{} +} + +// RejectedSpans returns the rejectedspans associated with this ExportTracePartialSuccess. +func (ms ExportTracePartialSuccess) RejectedSpans() int64 { + return ms.getOrig().RejectedSpans +} + +// SetRejectedSpans replaces the rejectedspans associated with this ExportTracePartialSuccess. +func (ms ExportTracePartialSuccess) SetRejectedSpans(v int64) { + ms.getOrig().RejectedSpans = v +} + +// ErrorMessage returns the errormessage associated with this ExportTracePartialSuccess. +func (ms ExportTracePartialSuccess) ErrorMessage() string { + return ms.getOrig().ErrorMessage +} + +// SetErrorMessage replaces the errormessage associated with this ExportTracePartialSuccess. +func (ms ExportTracePartialSuccess) SetErrorMessage(v string) { + ms.getOrig().ErrorMessage = v +} + +// CopyTo copies all properties from the current struct overriding the destination. +func (ms ExportTracePartialSuccess) CopyTo(dest ExportTracePartialSuccess) { + dest.SetRejectedSpans(ms.RejectedSpans()) + dest.SetErrorMessage(ms.ErrorMessage()) +} diff --git a/pdata/ptrace/ptraceotlp/generated_traces_otlp_test.go b/pdata/ptrace/ptraceotlp/generated_traces_otlp_test.go new file mode 100644 index 00000000000..281a8ebd98f --- /dev/null +++ b/pdata/ptrace/ptraceotlp/generated_traces_otlp_test.go @@ -0,0 +1,58 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by "model/internal/cmd/pdatagen/main.go". DO NOT EDIT. +// To regenerate this file run "go run model/internal/cmd/pdatagen/main.go". + +package ptraceotlp + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "go.opentelemetry.io/collector/pdata/internal" +) + +func TestExportTracePartialSuccess_MoveTo(t *testing.T) { + ms := ExportTracePartialSuccess(internal.GenerateTestExportTracePartialSuccess()) + dest := NewExportTracePartialSuccess() + ms.MoveTo(dest) + assert.Equal(t, NewExportTracePartialSuccess(), ms) + assert.Equal(t, ExportTracePartialSuccess(internal.GenerateTestExportTracePartialSuccess()), dest) +} + +func TestExportTracePartialSuccess_CopyTo(t *testing.T) { + ms := NewExportTracePartialSuccess() + orig := NewExportTracePartialSuccess() + orig.CopyTo(ms) + assert.Equal(t, orig, ms) + orig = ExportTracePartialSuccess(internal.GenerateTestExportTracePartialSuccess()) + orig.CopyTo(ms) + assert.Equal(t, orig, ms) +} + +func TestExportTracePartialSuccess_RejectedSpans(t *testing.T) { + ms := NewExportTracePartialSuccess() + assert.Equal(t, int64(0), ms.RejectedSpans()) + ms.SetRejectedSpans(int64(13)) + assert.Equal(t, int64(13), ms.RejectedSpans()) +} + +func TestExportTracePartialSuccess_ErrorMessage(t *testing.T) { + ms := NewExportTracePartialSuccess() + assert.Equal(t, "", ms.ErrorMessage()) + ms.SetErrorMessage("error message") + assert.Equal(t, "error message", ms.ErrorMessage()) +} diff --git a/pdata/ptrace/ptraceotlp/response.go b/pdata/ptrace/ptraceotlp/response.go index ab6505d053f..746ce9a41d6 100644 --- a/pdata/ptrace/ptraceotlp/response.go +++ b/pdata/ptrace/ptraceotlp/response.go @@ -16,6 +16,7 @@ package ptraceotlp // import "go.opentelemetry.io/collector/pdata/ptrace/ptraceo import ( "bytes" + "go.opentelemetry.io/collector/pdata/internal" otlpcollectortrace "go.opentelemetry.io/collector/pdata/internal/data/protogen/collector/trace/v1" "go.opentelemetry.io/collector/pdata/ptrace/internal/ptracejson" ) @@ -53,3 +54,8 @@ func (tr Response) MarshalJSON() ([]byte, error) { func (tr Response) UnmarshalJSON(data []byte) error { return ptracejson.UnmarshalExportTraceServiceResponse(data, tr.orig) } + +// PartialSuccess returns the ExportLogsPartialSuccess associated with this Response. +func (tr Response) PartialSuccess() ExportTracePartialSuccess { + return ExportTracePartialSuccess(internal.NewExportTracePartialSuccess(&tr.orig.PartialSuccess)) +}