mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
This is a huge PR that does not touch any of the critical logic "marshaling/unmarshaling" of the pdata. We have e2e tests with the go official generated protobufs to ensure nothing breaks. The easy way to review this is to only look at what change publicly in "pdata/pcommon", "pdata/plog", "pdata/ptrace", "pdata/pmetric", "pdata/pprofile", "pdata/xpdata". This PR also switches the xpada request to use the same generating mechanism as pdatagen. **Binary size before:** ``` 42246018 bin/otelcorecol_darwin_arm64 ``` **Binary size after:** ``` 40709202 bin/otelcorecol_darwin_arm64 ``` Signed-off-by: Bogdan Drutu <[email protected]>
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package plogotlp // import "go.opentelemetry.io/collector/pdata/plog/plogotlp"
|
|
|
|
import (
|
|
"slices"
|
|
|
|
"go.opentelemetry.io/collector/pdata/internal/json"
|
|
)
|
|
|
|
// MarshalProto marshals ExportResponse into proto bytes.
|
|
func (ms ExportResponse) MarshalProto() ([]byte, error) {
|
|
size := ms.orig.SizeProto()
|
|
buf := make([]byte, size)
|
|
_ = ms.orig.MarshalProto(buf)
|
|
return buf, nil
|
|
}
|
|
|
|
// UnmarshalProto unmarshalls ExportResponse from proto bytes.
|
|
func (ms ExportResponse) UnmarshalProto(data []byte) error {
|
|
return ms.orig.UnmarshalProto(data)
|
|
}
|
|
|
|
// MarshalJSON marshals ExportResponse into JSON bytes.
|
|
func (ms ExportResponse) MarshalJSON() ([]byte, error) {
|
|
dest := json.BorrowStream(nil)
|
|
defer json.ReturnStream(dest)
|
|
ms.orig.MarshalJSON(dest)
|
|
return slices.Clone(dest.Buffer()), dest.Error()
|
|
}
|
|
|
|
// UnmarshalJSON unmarshalls ExportResponse from JSON bytes.
|
|
func (ms ExportResponse) UnmarshalJSON(data []byte) error {
|
|
iter := json.BorrowIterator(data)
|
|
defer json.ReturnIterator(iter)
|
|
ms.orig.UnmarshalJSON(iter)
|
|
return iter.Error()
|
|
}
|