Debian Codegraph @

storage/remote/otlptranslator/prometheusremotewrite/timeseries.go

raw
1 // Copyright 2024 The Prometheus Authors
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 // Provenance-includes-location:
14 // https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/95e8f8fdc2a9dc87230406c9a3cf02be4fd68bea/pkg/translator/prometheusremotewrite/metrics_to_prw.go
15 // Provenance-includes-license: Apache-2.0
16 // Provenance-includes-copyright: Copyright The OpenTelemetry Authors.
17
18 package prometheusremotewrite
19
20 import (
21 "github.com/prometheus/prometheus/prompb"
22 )
23
24 // TimeSeries returns a slice of the prompb.TimeSeries that were converted from OTel format.
25 func (c *PrometheusConverter) TimeSeries() []prompb.TimeSeries {
26 conflicts := 0
27 for _, ts := range c.conflicts {
28 conflicts += len(ts)
29 }
30 allTS := make([]prompb.TimeSeries, 0, len(c.unique)+conflicts)
31 for _, ts := range c.unique {
32 allTS = append(allTS, *ts)
33 }
34 for _, cTS := range c.conflicts {
35 for _, ts := range cTS {
36 allTS = append(allTS, *ts)
37 }
38 }
39
40 return allTS
41 }