| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package pprofileotlp // import "go.opentelemetry.io/collector/pdata/pprofile/pprofileotlp" |
| 5 |
|
| 6 |
import ( |
| 7 |
"slices" |
| 8 |
|
| 9 |
"go.opentelemetry.io/collector/pdata/internal/json" |
| 10 |
) |
| 11 |
|
| 12 |
// MarshalProto marshals ExportResponse into proto bytes. |
| 13 |
func (ms ExportResponse) MarshalProto() ([]byte, error) { |
| 14 |
size := ms.orig.SizeProto() |
| 15 |
buf := make([]byte, size) |
| 16 |
_ = ms.orig.MarshalProto(buf) |
| 17 |
return buf, nil |
| 18 |
} |
| 19 |
|
| 20 |
// UnmarshalProto unmarshalls ExportResponse from proto bytes. |
| 21 |
func (ms ExportResponse) UnmarshalProto(data []byte) error { |
| 22 |
return ms.orig.UnmarshalProto(data) |
| 23 |
} |
| 24 |
|
| 25 |
// MarshalJSON marshals ExportResponse into JSON bytes. |
| 26 |
func (ms ExportResponse) MarshalJSON() ([]byte, error) { |
| 27 |
dest := json.BorrowStream(nil) |
| 28 |
defer json.ReturnStream(dest) |
| 29 |
ms.orig.MarshalJSON(dest) |
| 30 |
return slices.Clone(dest.Buffer()), dest.Error() |
| 31 |
} |
| 32 |
|
| 33 |
// UnmarshalJSON unmarshalls ExportResponse from JSON bytes. |
| 34 |
func (ms ExportResponse) UnmarshalJSON(data []byte) error { |
| 35 |
iter := json.BorrowIterator(data) |
| 36 |
defer json.ReturnIterator(iter) |
| 37 |
ms.orig.UnmarshalJSON(iter) |
| 38 |
return iter.Error() |
| 39 |
} |