forked from SumoLogic/sumologic-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpdata.go
38 lines (30 loc) · 814 Bytes
/
pdata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package metricfrequencyprocessor
import (
"math"
"sort"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
)
type pdataTimestampByValue []pcommon.Timestamp
func (pta pdataTimestampByValue) Len() int {
return len(pta)
}
func (pta pdataTimestampByValue) Less(i, j int) bool {
return pta[i] < pta[j]
}
func (pta pdataTimestampByValue) Swap(i, j int) {
pta[i], pta[j] = pta[j], pta[i]
}
func sortTimestampArray(timestamps []pcommon.Timestamp) {
sort.Sort(pdataTimestampByValue(timestamps))
}
func getVal(point pmetric.NumberDataPoint) float64 {
switch point.ValueType() {
case pmetric.NumberDataPointValueTypeDouble:
return point.DoubleValue()
case pmetric.NumberDataPointValueTypeInt:
return float64(point.IntValue())
default:
return math.NaN()
}
}