Debian Codegraph @

pdata/internal/otlp/metrics.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package otlp // import "go.opentelemetry.io/collector/pdata/internal/otlp"
5
6 import (
7 "go.opentelemetry.io/collector/pdata/internal"
8 )
9
10 // MigrateMetrics implements any translation needed due to deprecation in OTLP metrics protocol.
11 // Any pmetric.Unmarshaler implementation from OTLP (proto/json) MUST call this, and the gRPC Server implementation.
12 func MigrateMetrics(rms []*internal.ResourceMetrics) {
13 for _, rm := range rms {
14 if len(rm.ScopeMetrics) == 0 {
15 rm.ScopeMetrics = rm.DeprecatedScopeMetrics
16 }
17 rm.DeprecatedScopeMetrics = nil
18 }
19 }