diff --git a/model/internal/data/optional.go b/model/internal/data/optional.go index 0d1b6042f98..b921ed15427 100644 --- a/model/internal/data/optional.go +++ b/model/internal/data/optional.go @@ -52,13 +52,20 @@ func (o *OptionalDouble) MarshalTo(dAtA []byte) (n int, err error) { return o.marshalToSizedBuffer(dAtA[:size]) } -// TODO: implement Unmarshal, MarshalJSON, UnmarshalJSON +// TODO: implement MarshalJSON, UnmarshalJSON func (o *OptionalDouble) marshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) i -= 8 encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(o.DoubleValue)))) i-- - dAtA[i] = 0x21 return len(dAtA) - i, nil } + +func (o *OptionalDouble) Unmarshal(dAtA []byte) error { + v := uint64(encoding_binary.LittleEndian.Uint64(dAtA)) + v2 := float64(math.Float64frombits(v)) + o.DoubleValue = v2 + o.isSet = true + return nil +} diff --git a/model/internal/data/protogen/metrics/v1/metrics.pb.go b/model/internal/data/protogen/metrics/v1/metrics.pb.go index a1d4ebcd405..15c0ad34f57 100644 --- a/model/internal/data/protogen/metrics/v1/metrics.pb.go +++ b/model/internal/data/protogen/metrics/v1/metrics.pb.go @@ -3180,21 +3180,19 @@ func (m *HistogramDataPoint) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if !m.Min.IsEmpty() { - size, err := m.Min.MarshalTo(dAtA[:i]) - if err != nil { + if !m.Max.IsEmpty() { + i -= m.Max.Size() + if _, err := m.Max.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size - dAtA[i] = 0x5E + dAtA[i] = 0x61 } - if !m.Max.IsEmpty() { - size, err := m.Max.MarshalTo(dAtA[:i]) - if err != nil { + if !m.Min.IsEmpty() { + i -= m.Min.Size() + if _, err := m.Min.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size - dAtA[i] = 0x56 + dAtA[i] = 0x59 } if m.Flags != 0 { i = encodeVarintMetrics(dAtA, i, uint64(m.Flags)) @@ -6573,15 +6571,29 @@ func (m *HistogramDataPoint) Unmarshal(dAtA []byte) error { } } case 11: - // TODO: unmarshal here - if wireType != 0 { + if wireType != 1 { return fmt.Errorf("proto: wrong wireType = %d for field Min", wireType) } + postIndex := iNdEx + 8 + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Min.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 12: - // TODO: unmarshal here - if wireType != 0 { + if wireType != 1 { return fmt.Errorf("proto: wrong wireType = %d for field Max", wireType) } + postIndex := iNdEx + 8 + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Max.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMetrics(dAtA[iNdEx:]) diff --git a/model/otlp/pb_test.go b/model/otlp/pb_test.go index 51fe65049fd..a25cb8e8acb 100644 --- a/model/otlp/pb_test.go +++ b/model/otlp/pb_test.go @@ -95,7 +95,7 @@ func TestProtobufMetricsSizerWithOptional(t *testing.T) { p := NewProtobufMetricsUnmarshaler() unmarshalled, err := p.UnmarshalMetrics(bytes) - assert.Error(t, err) + assert.NoError(t, err) assert.Equal(t, metric, unmarshalled.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0)) }