github.com/blend/go-sdk@v1.20220411.3/datadog/traceserver/span_msgp.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 // Unless explicitly stated otherwise all files in this repository are licensed 9 // under the Apache License Version 2.0. 10 // This product includes software developed at Datadog (https://www.datadoghq.com/). 11 // Copyright 2016-2020 Datadog, Inc. 12 13 package traceserver 14 15 // NOTE: THIS FILE WAS PRODUCED BY THE 16 // MSGP CODE GENERATION TOOL (github.com/tinylib/msgp) 17 // DO NOT EDIT 18 19 import ( 20 "github.com/tinylib/msgp/msgp" 21 ) 22 23 // DecodeMsg implements msgp.Decodable 24 func (z *Span) DecodeMsg(dc *msgp.Reader) (err error) { 25 var field []byte 26 _ = field 27 var zb0001 uint32 28 zb0001, err = dc.ReadMapHeader() 29 if err != nil { 30 return 31 } 32 for zb0001 > 0 { 33 zb0001-- 34 field, err = dc.ReadMapKeyPtr() 35 if err != nil { 36 return 37 } 38 switch msgp.UnsafeString(field) { 39 case "name": 40 z.Name, err = dc.ReadString() 41 if err != nil { 42 return 43 } 44 case "service": 45 z.Service, err = dc.ReadString() 46 if err != nil { 47 return 48 } 49 case "resource": 50 z.Resource, err = dc.ReadString() 51 if err != nil { 52 return 53 } 54 case "type": 55 z.Type, err = dc.ReadString() 56 if err != nil { 57 return 58 } 59 case "start": 60 z.Start, err = dc.ReadInt64() 61 if err != nil { 62 return 63 } 64 case "duration": 65 z.Duration, err = dc.ReadInt64() 66 if err != nil { 67 return 68 } 69 case "meta": 70 var zb0002 uint32 71 zb0002, err = dc.ReadMapHeader() 72 if err != nil { 73 return 74 } 75 if z.Meta == nil && zb0002 > 0 { 76 z.Meta = make(map[string]string, zb0002) 77 } else if len(z.Meta) > 0 { 78 for key := range z.Meta { 79 delete(z.Meta, key) 80 } 81 } 82 for zb0002 > 0 { 83 zb0002-- 84 var za0001 string 85 var za0002 string 86 za0001, err = dc.ReadString() 87 if err != nil { 88 return 89 } 90 za0002, err = dc.ReadString() 91 if err != nil { 92 return 93 } 94 z.Meta[za0001] = za0002 95 } 96 case "metrics": 97 var zb0003 uint32 98 zb0003, err = dc.ReadMapHeader() 99 if err != nil { 100 return 101 } 102 if z.Metrics == nil && zb0003 > 0 { 103 z.Metrics = make(map[string]float64, zb0003) 104 } else if len(z.Metrics) > 0 { 105 for key := range z.Metrics { 106 delete(z.Metrics, key) 107 } 108 } 109 for zb0003 > 0 { 110 zb0003-- 111 var za0003 string 112 var za0004 float64 113 za0003, err = dc.ReadString() 114 if err != nil { 115 return 116 } 117 za0004, err = dc.ReadFloat64() 118 if err != nil { 119 return 120 } 121 z.Metrics[za0003] = za0004 122 } 123 case "span_id": 124 z.SpanID, err = dc.ReadUint64() 125 if err != nil { 126 return 127 } 128 case "trace_id": 129 z.TraceID, err = dc.ReadUint64() 130 if err != nil { 131 return 132 } 133 case "parent_id": 134 z.ParentID, err = dc.ReadUint64() 135 if err != nil { 136 return 137 } 138 case "error": 139 z.Error, err = dc.ReadInt32() 140 if err != nil { 141 return 142 } 143 default: 144 err = dc.Skip() 145 if err != nil { 146 return 147 } 148 } 149 } 150 return 151 } 152 153 // EncodeMsg implements msgp.Encodable 154 func (z *Span) EncodeMsg(en *msgp.Writer) (err error) { 155 // map header, size 12 156 // write "name" 157 err = en.Append(0x8c, 0xa4, 0x6e, 0x61, 0x6d, 0x65) 158 if err != nil { 159 return 160 } 161 err = en.WriteString(z.Name) 162 if err != nil { 163 return 164 } 165 // write "service" 166 err = en.Append(0xa7, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65) 167 if err != nil { 168 return 169 } 170 err = en.WriteString(z.Service) 171 if err != nil { 172 return 173 } 174 // write "resource" 175 err = en.Append(0xa8, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65) 176 if err != nil { 177 return 178 } 179 err = en.WriteString(z.Resource) 180 if err != nil { 181 return 182 } 183 // write "type" 184 err = en.Append(0xa4, 0x74, 0x79, 0x70, 0x65) 185 if err != nil { 186 return 187 } 188 err = en.WriteString(z.Type) 189 if err != nil { 190 return 191 } 192 // write "start" 193 err = en.Append(0xa5, 0x73, 0x74, 0x61, 0x72, 0x74) 194 if err != nil { 195 return 196 } 197 err = en.WriteInt64(z.Start) 198 if err != nil { 199 return 200 } 201 // write "duration" 202 err = en.Append(0xa8, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e) 203 if err != nil { 204 return 205 } 206 err = en.WriteInt64(z.Duration) 207 if err != nil { 208 return 209 } 210 // write "meta" 211 err = en.Append(0xa4, 0x6d, 0x65, 0x74, 0x61) 212 if err != nil { 213 return 214 } 215 err = en.WriteMapHeader(uint32(len(z.Meta))) 216 if err != nil { 217 return 218 } 219 for za0001, za0002 := range z.Meta { 220 err = en.WriteString(za0001) 221 if err != nil { 222 return 223 } 224 err = en.WriteString(za0002) 225 if err != nil { 226 return 227 } 228 } 229 // write "metrics" 230 err = en.Append(0xa7, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73) 231 if err != nil { 232 return 233 } 234 err = en.WriteMapHeader(uint32(len(z.Metrics))) 235 if err != nil { 236 return 237 } 238 for za0003, za0004 := range z.Metrics { 239 err = en.WriteString(za0003) 240 if err != nil { 241 return 242 } 243 err = en.WriteFloat64(za0004) 244 if err != nil { 245 return 246 } 247 } 248 // write "span_id" 249 err = en.Append(0xa7, 0x73, 0x70, 0x61, 0x6e, 0x5f, 0x69, 0x64) 250 if err != nil { 251 return 252 } 253 err = en.WriteUint64(z.SpanID) 254 if err != nil { 255 return 256 } 257 // write "trace_id" 258 err = en.Append(0xa8, 0x74, 0x72, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64) 259 if err != nil { 260 return 261 } 262 err = en.WriteUint64(z.TraceID) 263 if err != nil { 264 return 265 } 266 // write "parent_id" 267 err = en.Append(0xa9, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64) 268 if err != nil { 269 return 270 } 271 err = en.WriteUint64(z.ParentID) 272 if err != nil { 273 return 274 } 275 // write "error" 276 err = en.Append(0xa5, 0x65, 0x72, 0x72, 0x6f, 0x72) 277 if err != nil { 278 return 279 } 280 err = en.WriteInt32(z.Error) 281 if err != nil { 282 return 283 } 284 return 285 } 286 287 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 288 func (z *Span) Msgsize() (s int) { 289 s = 1 + 5 + msgp.StringPrefixSize + len(z.Name) + 8 + msgp.StringPrefixSize + len(z.Service) + 9 + msgp.StringPrefixSize + len(z.Resource) + 5 + msgp.StringPrefixSize + len(z.Type) + 6 + msgp.Int64Size + 9 + msgp.Int64Size + 5 + msgp.MapHeaderSize 290 if z.Meta != nil { 291 for za0001, za0002 := range z.Meta { 292 _ = za0002 293 s += msgp.StringPrefixSize + len(za0001) + msgp.StringPrefixSize + len(za0002) 294 } 295 } 296 s += 8 + msgp.MapHeaderSize 297 if z.Metrics != nil { 298 for za0003, za0004 := range z.Metrics { 299 _ = za0004 300 s += msgp.StringPrefixSize + len(za0003) + msgp.Float64Size 301 } 302 } 303 s += 8 + msgp.Uint64Size + 9 + msgp.Uint64Size + 10 + msgp.Uint64Size + 6 + msgp.Int32Size 304 return 305 } 306 307 // DecodeMsg implements msgp.Decodable 308 func (z *SpanList) DecodeMsg(dc *msgp.Reader) (err error) { 309 var zb0002 uint32 310 zb0002, err = dc.ReadArrayHeader() 311 if err != nil { 312 return 313 } 314 if cap((*z)) >= int(zb0002) { 315 (*z) = (*z)[:zb0002] 316 } else { 317 (*z) = make(SpanList, zb0002) 318 } 319 for zb0001 := range *z { 320 if dc.IsNil() { 321 err = dc.ReadNil() 322 if err != nil { 323 return 324 } 325 (*z)[zb0001] = nil 326 } else { 327 if (*z)[zb0001] == nil { 328 (*z)[zb0001] = new(Span) 329 } 330 err = (*z)[zb0001].DecodeMsg(dc) 331 if err != nil { 332 return 333 } 334 } 335 } 336 return 337 } 338 339 // EncodeMsg implements msgp.Encodable 340 func (z SpanList) EncodeMsg(en *msgp.Writer) (err error) { 341 err = en.WriteArrayHeader(uint32(len(z))) 342 if err != nil { 343 return 344 } 345 for zb0003 := range z { 346 if z[zb0003] == nil { 347 err = en.WriteNil() 348 if err != nil { 349 return 350 } 351 } else { 352 err = z[zb0003].EncodeMsg(en) 353 if err != nil { 354 return 355 } 356 } 357 } 358 return 359 } 360 361 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 362 func (z SpanList) Msgsize() (s int) { 363 s = msgp.ArrayHeaderSize 364 for zb0003 := range z { 365 if z[zb0003] == nil { 366 s += msgp.NilSize 367 } else { 368 s += z[zb0003].Msgsize() 369 } 370 } 371 return 372 } 373 374 // DecodeMsg implements msgp.Decodable 375 func (z *SpanLists) DecodeMsg(dc *msgp.Reader) (err error) { 376 var zb0003 uint32 377 zb0003, err = dc.ReadArrayHeader() 378 if err != nil { 379 return 380 } 381 if cap((*z)) >= int(zb0003) { 382 (*z) = (*z)[:zb0003] 383 } else { 384 (*z) = make(SpanLists, zb0003) 385 } 386 for zb0001 := range *z { 387 var zb0004 uint32 388 zb0004, err = dc.ReadArrayHeader() 389 if err != nil { 390 return 391 } 392 if cap((*z)[zb0001]) >= int(zb0004) { 393 (*z)[zb0001] = ((*z)[zb0001])[:zb0004] 394 } else { 395 (*z)[zb0001] = make(SpanList, zb0004) 396 } 397 for zb0002 := range (*z)[zb0001] { 398 if dc.IsNil() { 399 err = dc.ReadNil() 400 if err != nil { 401 return 402 } 403 (*z)[zb0001][zb0002] = nil 404 } else { 405 if (*z)[zb0001][zb0002] == nil { 406 (*z)[zb0001][zb0002] = new(Span) 407 } 408 err = (*z)[zb0001][zb0002].DecodeMsg(dc) 409 if err != nil { 410 return 411 } 412 } 413 } 414 } 415 return 416 } 417 418 // EncodeMsg implements msgp.Encodable 419 func (z SpanLists) EncodeMsg(en *msgp.Writer) (err error) { 420 err = en.WriteArrayHeader(uint32(len(z))) 421 if err != nil { 422 return 423 } 424 for zb0005 := range z { 425 err = en.WriteArrayHeader(uint32(len(z[zb0005]))) 426 if err != nil { 427 return 428 } 429 for zb0006 := range z[zb0005] { 430 if z[zb0005][zb0006] == nil { 431 err = en.WriteNil() 432 if err != nil { 433 return 434 } 435 } else { 436 err = z[zb0005][zb0006].EncodeMsg(en) 437 if err != nil { 438 return 439 } 440 } 441 } 442 } 443 return 444 } 445 446 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 447 func (z SpanLists) Msgsize() (s int) { 448 s = msgp.ArrayHeaderSize 449 for zb0005 := range z { 450 s += msgp.ArrayHeaderSize 451 for zb0006 := range z[zb0005] { 452 if z[zb0005][zb0006] == nil { 453 s += msgp.NilSize 454 } else { 455 s += z[zb0005][zb0006].Msgsize() 456 } 457 } 458 } 459 return 460 }