Debian Codegraph @

pdata/pmetric/encoding.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric"
5
6 // MarshalSizer is the interface that groups the basic Marshal and Size methods
7 type MarshalSizer interface {
8 Marshaler
9 Sizer
10 }
11
12 // Marshaler marshals pmetric.Metrics into bytes.
13 type Marshaler interface {
14 // MarshalMetrics the given pmetric.Metrics into bytes.
15 // If the error is not nil, the returned bytes slice cannot be used.
16 MarshalMetrics(md Metrics) ([]byte, error)
17 }
18
19 // Unmarshaler unmarshalls bytes into pmetric.Metrics.
20 type Unmarshaler interface {
21 // UnmarshalMetrics the given bytes into pmetric.Metrics.
22 // If the error is not nil, the returned pmetric.Metrics cannot be used.
23 UnmarshalMetrics(buf []byte) (Metrics, error)
24 }
25
26 // Sizer is an optional interface implemented by the Marshaler, that calculates the size of a marshaled Metrics.
27 type Sizer interface {
28 // MetricsSize returns the size in bytes of a marshaled Metrics.
29 MetricsSize(md Metrics) int
30 }