Debian Codegraph @

pdata/internal/generated_proto_exporttracepartialsuccess.go

raw
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 internal
8
9 import (
10 "fmt"
11 "sync"
12
13 "go.opentelemetry.io/collector/pdata/internal/json"
14 "go.opentelemetry.io/collector/pdata/internal/proto"
15 )
16
17 // ExportPartialSuccess represents the details of a partially successful export request.
18 type ExportTracePartialSuccess struct {
19 RejectedSpans int64
20 ErrorMessage string
21 }
22
23 var (
24 protoPoolExportTracePartialSuccess = sync.Pool{
25 New: func() any {
26 return &ExportTracePartialSuccess{}
27 },
28 }
29 )
30
31 func NewExportTracePartialSuccess() *ExportTracePartialSuccess {
32 if !UseProtoPooling.IsEnabled() {
33 return &ExportTracePartialSuccess{}
34 }
35 return protoPoolExportTracePartialSuccess.Get().(*ExportTracePartialSuccess)
36 }
37
38 func DeleteExportTracePartialSuccess(orig *ExportTracePartialSuccess, nullable bool) {
39 if orig == nil {
40 return
41 }
42
43 if !UseProtoPooling.IsEnabled() {
44 orig.Reset()
45 return
46 }
47
48 orig.Reset()
49 if nullable {
50 protoPoolExportTracePartialSuccess.Put(orig)
51 }
52 }
53
54 func CopyExportTracePartialSuccess(dest, src *ExportTracePartialSuccess) *ExportTracePartialSuccess {
55 // If copying to same object, just return.
56 if src == dest {
57 return dest
58 }
59
60 if src == nil {
61 return nil
62 }
63
64 if dest == nil {
65 dest = NewExportTracePartialSuccess()
66 }
67 dest.RejectedSpans = src.RejectedSpans
68
69 dest.ErrorMessage = src.ErrorMessage
70
71 return dest
72 }
73
74 func CopyExportTracePartialSuccessSlice(dest, src []ExportTracePartialSuccess) []ExportTracePartialSuccess {
75 var newDest []ExportTracePartialSuccess
76 if cap(dest) < len(src) {
77 newDest = make([]ExportTracePartialSuccess, len(src))
78 } else {
79 newDest = dest[:len(src)]
80 // Cleanup the rest of the elements so GC can free the memory.
81 // This can happen when len(src) < len(dest) < cap(dest).
82 for i := len(src); i < len(dest); i++ {
83 DeleteExportTracePartialSuccess(&dest[i], false)
84 }
85 }
86 for i := range src {
87 CopyExportTracePartialSuccess(&newDest[i], &src[i])
88 }
89 return newDest
90 }
91
92 func CopyExportTracePartialSuccessPtrSlice(dest, src []*ExportTracePartialSuccess) []*ExportTracePartialSuccess {
93 var newDest []*ExportTracePartialSuccess
94 if cap(dest) < len(src) {
95 newDest = make([]*ExportTracePartialSuccess, len(src))
96 // Copy old pointers to re-use.
97 copy(newDest, dest)
98 // Add new pointers for missing elements from len(dest) to len(srt).
99 for i := len(dest); i < len(src); i++ {
100 newDest[i] = NewExportTracePartialSuccess()
101 }
102 } else {
103 newDest = dest[:len(src)]
104 // Cleanup the rest of the elements so GC can free the memory.
105 // This can happen when len(src) < len(dest) < cap(dest).
106 for i := len(src); i < len(dest); i++ {
107 DeleteExportTracePartialSuccess(dest[i], true)
108 dest[i] = nil
109 }
110 // Add new pointers for missing elements.
111 // This can happen when len(dest) < len(src) < cap(dest).
112 for i := len(dest); i < len(src); i++ {
113 newDest[i] = NewExportTracePartialSuccess()
114 }
115 }
116 for i := range src {
117 CopyExportTracePartialSuccess(newDest[i], src[i])
118 }
119 return newDest
120 }
121
122 func (orig *ExportTracePartialSuccess) Reset() {
123 *orig = ExportTracePartialSuccess{}
124 }
125
126 // MarshalJSON marshals all properties from the current struct to the destination stream.
127 func (orig *ExportTracePartialSuccess) MarshalJSON(dest *json.Stream) {
128 dest.WriteObjectStart()
129 if orig.RejectedSpans != int64(0) {
130 dest.WriteObjectField("rejectedSpans")
131 dest.WriteInt64(orig.RejectedSpans)
132 }
133 if orig.ErrorMessage != "" {
134 dest.WriteObjectField("errorMessage")
135 dest.WriteString(orig.ErrorMessage)
136 }
137 dest.WriteObjectEnd()
138 }
139
140 // UnmarshalJSON unmarshals all properties from the current struct from the source iterator.
141 func (orig *ExportTracePartialSuccess) UnmarshalJSON(iter *json.Iterator) {
142 for f := iter.ReadObject(); f != ""; f = iter.ReadObject() {
143 switch f {
144 case "rejectedSpans", "rejected_spans":
145 orig.RejectedSpans = iter.ReadInt64()
146 case "errorMessage", "error_message":
147 orig.ErrorMessage = iter.ReadString()
148 default:
149 iter.Skip()
150 }
151 }
152 }
153
154 func (orig *ExportTracePartialSuccess) SizeProto() int {
155 var n int
156 var l int
157 _ = l
158 if orig.RejectedSpans != 0 {
159 n += 1 + proto.Sov(uint64(orig.RejectedSpans))
160 }
161 l = len(orig.ErrorMessage)
162 if l > 0 {
163 n += 1 + proto.Sov(uint64(l)) + l
164 }
165 return n
166 }
167
168 func (orig *ExportTracePartialSuccess) MarshalProto(buf []byte) int {
169 pos := len(buf)
170 var l int
171 _ = l
172 if orig.RejectedSpans != 0 {
173 pos = proto.EncodeVarint(buf, pos, uint64(orig.RejectedSpans))
174 pos--
175 buf[pos] = 0x8
176 }
177 l = len(orig.ErrorMessage)
178 if l > 0 {
179 pos -= l
180 copy(buf[pos:], orig.ErrorMessage)
181 pos = proto.EncodeVarint(buf, pos, uint64(l))
182 pos--
183 buf[pos] = 0x12
184 }
185 return len(buf) - pos
186 }
187
188 func (orig *ExportTracePartialSuccess) UnmarshalProto(buf []byte) error {
189 var err error
190 var fieldNum int32
191 var wireType proto.WireType
192
193 l := len(buf)
194 pos := 0
195 for pos < l {
196 // If in a group parsing, move to the next tag.
197 fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos)
198 if err != nil {
199 return err
200 }
201 switch fieldNum {
202
203 case 1:
204 if wireType != proto.WireTypeVarint {
205 return fmt.Errorf("proto: wrong wireType = %d for field RejectedSpans", wireType)
206 }
207 var num uint64
208 num, pos, err = proto.ConsumeVarint(buf, pos)
209 if err != nil {
210 return err
211 }
212
213 orig.RejectedSpans = int64(num)
214
215 case 2:
216 if wireType != proto.WireTypeLen {
217 return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType)
218 }
219 var length int
220 length, pos, err = proto.ConsumeLen(buf, pos)
221 if err != nil {
222 return err
223 }
224 startPos := pos - length
225 orig.ErrorMessage = string(buf[startPos:pos])
226 default:
227 pos, err = proto.ConsumeUnknown(buf, pos, wireType)
228 if err != nil {
229 return err
230 }
231 }
232 }
233 return nil
234 }
235
236 func GenTestExportTracePartialSuccess() *ExportTracePartialSuccess {
237 orig := NewExportTracePartialSuccess()
238 orig.RejectedSpans = int64(13)
239 orig.ErrorMessage = "test_errormessage"
240 return orig
241 }
242
243 func GenTestExportTracePartialSuccessPtrSlice() []*ExportTracePartialSuccess {
244 orig := make([]*ExportTracePartialSuccess, 5)
245 orig[0] = NewExportTracePartialSuccess()
246 orig[1] = GenTestExportTracePartialSuccess()
247 orig[2] = NewExportTracePartialSuccess()
248 orig[3] = GenTestExportTracePartialSuccess()
249 orig[4] = NewExportTracePartialSuccess()
250 return orig
251 }
252
253 func GenTestExportTracePartialSuccessSlice() []ExportTracePartialSuccess {
254 orig := make([]ExportTracePartialSuccess, 5)
255 orig[1] = *GenTestExportTracePartialSuccess()
256 orig[3] = *GenTestExportTracePartialSuccess()
257 return orig
258 }