mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-20 23:46:23 +01:00
32 lines
868 B
Go
32 lines
868 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package pmetric // import "go.opentelemetry.io/collector/pdata/pmetric"
|
|
|
|
import (
|
|
"go.opentelemetry.io/collector/pdata/internal"
|
|
otlpmetrics "go.opentelemetry.io/collector/pdata/internal/data/protogen/metrics/v1"
|
|
)
|
|
|
|
var _ MarshalSizer = (*ProtoMarshaler)(nil)
|
|
|
|
type ProtoMarshaler struct{}
|
|
|
|
func (e *ProtoMarshaler) MarshalMetrics(md Metrics) ([]byte, error) {
|
|
pb := internal.MetricsToProto(internal.Metrics(md))
|
|
return pb.Marshal()
|
|
}
|
|
|
|
func (e *ProtoMarshaler) MetricsSize(md Metrics) int {
|
|
pb := internal.MetricsToProto(internal.Metrics(md))
|
|
return pb.Size()
|
|
}
|
|
|
|
type ProtoUnmarshaler struct{}
|
|
|
|
func (d *ProtoUnmarshaler) UnmarshalMetrics(buf []byte) (Metrics, error) {
|
|
pb := otlpmetrics.MetricsData{}
|
|
err := pb.Unmarshal(buf)
|
|
return Metrics(internal.MetricsFromProto(pb)), err
|
|
}
|