// Code generated by github.com/tinylib/msgp DO NOT EDIT.

package trace

import (
	"github.com/tinylib/msgp/msgp"
)

// MarshalMsg implements msgp.Marshaler
func (z *AgentPayload) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	// map header, size 8
	// string "HostName"
	o = append(o, 0x88, 0xa8, 0x48, 0x6f, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65)
	o = msgp.AppendString(o, z.HostName)
	// string "Env"
	o = append(o, 0xa3, 0x45, 0x6e, 0x76)
	o = msgp.AppendString(o, z.Env)
	// string "TracerPayloads"
	o = append(o, 0xae, 0x54, 0x72, 0x61, 0x63, 0x65, 0x72, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x73)
	o = msgp.AppendArrayHeader(o, uint32(len(z.TracerPayloads)))
	for za0001 := range z.TracerPayloads {
		if z.TracerPayloads[za0001] == nil {
			o = msgp.AppendNil(o)
		} else {
			o, err = z.TracerPayloads[za0001].MarshalMsg(o)
			if err != nil {
				err = msgp.WrapError(err, "TracerPayloads", za0001)
				return
			}
		}
	}
	// string "Tags"
	o = append(o, 0xa4, 0x54, 0x61, 0x67, 0x73)
	o = msgp.AppendMapHeader(o, uint32(len(z.Tags)))
	for za0002, za0003 := range z.Tags {
		o = msgp.AppendString(o, za0002)
		o = msgp.AppendString(o, za0003)
	}
	// string "AgentVersion"
	o = append(o, 0xac, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e)
	o = msgp.AppendString(o, z.AgentVersion)
	// string "TargetTPS"
	o = append(o, 0xa9, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x50, 0x53)
	o = msgp.AppendFloat64(o, z.TargetTPS)
	// string "ErrorTPS"
	o = append(o, 0xa8, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x54, 0x50, 0x53)
	o = msgp.AppendFloat64(o, z.ErrorTPS)
	// string "RareSamplerEnabled"
	o = append(o, 0xb2, 0x52, 0x61, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64)
	o = msgp.AppendBool(o, z.RareSamplerEnabled)
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *AgentPayload) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var zb0001 uint32
	zb0001, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		err = msgp.WrapError(err)
		return
	}
	for zb0001 > 0 {
		zb0001--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			err = msgp.WrapError(err)
			return
		}
		switch msgp.UnsafeString(field) {
		case "HostName":
			z.HostName, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "HostName")
				return
			}
		case "Env":
			z.Env, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Env")
				return
			}
		case "TracerPayloads":
			var zb0002 uint32
			zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "TracerPayloads")
				return
			}
			if cap(z.TracerPayloads) >= int(zb0002) {
				z.TracerPayloads = (z.TracerPayloads)[:zb0002]
			} else {
				z.TracerPayloads = make([]*TracerPayload, zb0002)
			}
			for za0001 := range z.TracerPayloads {
				if msgp.IsNil(bts) {
					bts, err = msgp.ReadNilBytes(bts)
					if err != nil {
						return
					}
					z.TracerPayloads[za0001] = nil
				} else {
					if z.TracerPayloads[za0001] == nil {
						z.TracerPayloads[za0001] = new(TracerPayload)
					}
					bts, err = z.TracerPayloads[za0001].UnmarshalMsg(bts)
					if err != nil {
						err = msgp.WrapError(err, "TracerPayloads", za0001)
						return
					}
				}
			}
		case "Tags":
			var zb0003 uint32
			zb0003, bts, err = msgp.ReadMapHeaderBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Tags")
				return
			}
			if z.Tags == nil {
				z.Tags = make(map[string]string, zb0003)
			} else if len(z.Tags) > 0 {
				clear(z.Tags)
			}
			for zb0003 > 0 {
				var za0003 string
				zb0003--
				var za0002 string
				za0002, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "Tags")
					return
				}
				za0003, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "Tags", za0002)
					return
				}
				z.Tags[za0002] = za0003
			}
		case "AgentVersion":
			z.AgentVersion, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "AgentVersion")
				return
			}
		case "TargetTPS":
			z.TargetTPS, bts, err = msgp.ReadFloat64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "TargetTPS")
				return
			}
		case "ErrorTPS":
			z.ErrorTPS, bts, err = msgp.ReadFloat64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "ErrorTPS")
				return
			}
		case "RareSamplerEnabled":
			z.RareSamplerEnabled, bts, err = msgp.ReadBoolBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "RareSamplerEnabled")
				return
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				err = msgp.WrapError(err)
				return
			}
		}
	}
	o = bts
	return
}

// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *AgentPayload) Msgsize() (s int) {
	s = 1 + 9 + msgp.StringPrefixSize + len(z.HostName) + 4 + msgp.StringPrefixSize + len(z.Env) + 15 + msgp.ArrayHeaderSize
	for za0001 := range z.TracerPayloads {
		if z.TracerPayloads[za0001] == nil {
			s += msgp.NilSize
		} else {
			s += z.TracerPayloads[za0001].Msgsize()
		}
	}
	s += 5 + msgp.MapHeaderSize
	if z.Tags != nil {
		for za0002, za0003 := range z.Tags {
			_ = za0003
			s += msgp.StringPrefixSize + len(za0002) + msgp.StringPrefixSize + len(za0003)
		}
	}
	s += 13 + msgp.StringPrefixSize + len(z.AgentVersion) + 10 + msgp.Float64Size + 9 + msgp.Float64Size + 19 + msgp.BoolSize
	return
}
