@@ -10,18 +10,20 @@ import (
10
10
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver/internal/metadata"
11
11
)
12
12
13
- type getNetworkDataFunc func (s * stats.NetworkStats ) (rx * uint64 , tx * uint64 )
13
+ type getNetworkDataFunc func (s * stats.InterfaceStats ) (rx * uint64 , tx * uint64 )
14
14
15
15
func addNetworkMetrics (mb * metadata.MetricsBuilder , networkMetrics metadata.NetworkMetrics , s * stats.NetworkStats , currentTime pcommon.Timestamp ) {
16
16
if s == nil {
17
17
return
18
18
}
19
19
20
- recordNetworkDataPoint (mb , networkMetrics .IO , s , getNetworkIO , currentTime )
21
- recordNetworkDataPoint (mb , networkMetrics .Errors , s , getNetworkErrors , currentTime )
20
+ for i := range s .Interfaces {
21
+ recordNetworkDataPoint (mb , networkMetrics .IO , & s .Interfaces [i ], getNetworkIO , currentTime )
22
+ recordNetworkDataPoint (mb , networkMetrics .Errors , & s .Interfaces [i ], getNetworkErrors , currentTime )
23
+ }
22
24
}
23
25
24
- func recordNetworkDataPoint (mb * metadata.MetricsBuilder , recordDataPoint metadata.RecordIntDataPointWithDirectionFunc , s * stats.NetworkStats , getData getNetworkDataFunc , currentTime pcommon.Timestamp ) {
26
+ func recordNetworkDataPoint (mb * metadata.MetricsBuilder , recordDataPoint metadata.RecordIntDataPointWithDirectionFunc , s * stats.InterfaceStats , getData getNetworkDataFunc , currentTime pcommon.Timestamp ) {
25
27
rx , tx := getData (s )
26
28
27
29
if rx != nil {
@@ -33,10 +35,10 @@ func recordNetworkDataPoint(mb *metadata.MetricsBuilder, recordDataPoint metadat
33
35
}
34
36
}
35
37
36
- func getNetworkIO (s * stats.NetworkStats ) (* uint64 , * uint64 ) {
38
+ func getNetworkIO (s * stats.InterfaceStats ) (* uint64 , * uint64 ) {
37
39
return s .RxBytes , s .TxBytes
38
40
}
39
41
40
- func getNetworkErrors (s * stats.NetworkStats ) (* uint64 , * uint64 ) {
42
+ func getNetworkErrors (s * stats.InterfaceStats ) (* uint64 , * uint64 ) {
41
43
return s .RxErrors , s .TxErrors
42
44
}
0 commit comments