Debian Codegraph @

pdata/pmetric/pb.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 var _ MarshalSizer = (*ProtoMarshaler)(nil)
7
8 type ProtoMarshaler struct{}
9
10 func (e *ProtoMarshaler) MarshalMetrics(md Metrics) ([]byte, error) {
11 size := md.getOrig().SizeProto()
12 buf := make([]byte, size)
13 _ = md.getOrig().MarshalProto(buf)
14 return buf, nil
15 }
16
17 func (e *ProtoMarshaler) MetricsSize(md Metrics) int {
18 return md.getOrig().SizeProto()
19 }
20
21 func (e *ProtoMarshaler) ResourceMetricsSize(md ResourceMetrics) int {
22 return md.orig.SizeProto()
23 }
24
25 func (e *ProtoMarshaler) ScopeMetricsSize(md ScopeMetrics) int {
26 return md.orig.SizeProto()
27 }
28
29 func (e *ProtoMarshaler) MetricSize(md Metric) int {
30 return md.orig.SizeProto()
31 }
32
33 func (e *ProtoMarshaler) NumberDataPointSize(md NumberDataPoint) int {
34 return md.orig.SizeProto()
35 }
36
37 func (e *ProtoMarshaler) SummaryDataPointSize(md SummaryDataPoint) int {
38 return md.orig.SizeProto()
39 }
40
41 func (e *ProtoMarshaler) HistogramDataPointSize(md HistogramDataPoint) int {
42 return md.orig.SizeProto()
43 }
44
45 func (e *ProtoMarshaler) ExponentialHistogramDataPointSize(md ExponentialHistogramDataPoint) int {
46 return md.orig.SizeProto()
47 }
48
49 type ProtoUnmarshaler struct{}
50
51 func (d *ProtoUnmarshaler) UnmarshalMetrics(buf []byte) (Metrics, error) {
52 md := NewMetrics()
53 err := md.getOrig().UnmarshalProto(buf)
54 if err != nil {
55 return Metrics{}, err
56 }
57 return md, nil
58 }