@@ -49,10 +49,10 @@ var (
49
49
)
50
50
51
51
const (
52
- send_bytes = "ebpf_exporter_ipv4_send_bytes"
53
- recv_bytes = "ebpf_exporter_ipv4_recv_bytes"
54
- ingress = "ingress"
55
- egress = "egress"
52
+ sendBytes = "ebpf_exporter_ipv4_send_bytes"
53
+ recvBytes = "ebpf_exporter_ipv4_recv_bytes"
54
+ ingress = "ingress"
55
+ egress = "egress"
56
56
)
57
57
58
58
func init () {
@@ -125,33 +125,33 @@ func Collect(ctx context.Context) error {
125
125
if err != nil {
126
126
return err
127
127
}
128
- var send_bytes_metric * prom2json.Family
129
- var recv_bytes_metric * prom2json.Family
128
+ var sendBytesMetric * prom2json.Family
129
+ var recvBytesMetric * prom2json.Family
130
130
for _ , v := range ebpfScrape {
131
- if v .Name == send_bytes {
132
- send_bytes_metric = v
131
+ if v .Name == sendBytes {
132
+ sendBytesMetric = v
133
133
}
134
- if v .Name == recv_bytes {
135
- recv_bytes_metric = v
134
+ if v .Name == recvBytes {
135
+ recvBytesMetric = v
136
136
}
137
- if send_bytes_metric != nil && recv_bytes_metric != nil {
137
+ if sendBytesMetric != nil && recvBytesMetric != nil {
138
138
break
139
139
}
140
140
}
141
- if send_bytes_metric == nil {
142
- return fmt .Errorf ("Metric %v doesn't exist" , send_bytes )
141
+ if sendBytesMetric == nil {
142
+ return fmt .Errorf ("Metric %v doesn't exist" , sendBytes )
143
143
}
144
- if recv_bytes_metric == nil {
145
- return fmt .Errorf ("Metric %v doesn't exist" , recv_bytes )
144
+ if recvBytesMetric == nil {
145
+ return fmt .Errorf ("Metric %v doesn't exist" , recvBytes )
146
146
}
147
147
148
- sendHostBytes , err := toHostMetrics (send_bytes_metric , egress )
148
+ sendHostBytes , err := toHostMetrics (sendBytesMetric , egress )
149
149
if err != nil {
150
- log .Errorf ("Conversion to host metric failed for %v, err: %v" , send_bytes , err )
150
+ log .Errorf ("Conversion to host metric failed for %v, err: %v" , sendBytes , err )
151
151
}
152
- recvHostBytes , err := toHostMetrics (recv_bytes_metric , ingress )
152
+ recvHostBytes , err := toHostMetrics (recvBytesMetric , ingress )
153
153
if err != nil {
154
- log .Errorf ("Conversion to host metric failed for %v, err: %v" , recv_bytes , err )
154
+ log .Errorf ("Conversion to host metric failed for %v, err: %v" , recvBytes , err )
155
155
}
156
156
157
157
singleton .mu .Lock ()
@@ -164,7 +164,7 @@ func Collect(ctx context.Context) error {
164
164
}
165
165
166
166
// toHostMetrics converts ebpf metrics into planet explorer prometheus metrics.
167
- func toHostMetrics (bytes_metric * prom2json.Family , direction string ) ([]Metric , error ) {
167
+ func toHostMetrics (bytesMetric * prom2json.Family , direction string ) ([]Metric , error ) {
168
168
var hosts []Metric
169
169
inventoryHosts := inventory .Get ()
170
170
@@ -183,11 +183,11 @@ func toHostMetrics(bytes_metric *prom2json.Family, direction string) ([]Metric,
183
183
}
184
184
log .Debugf ("Local address doesn't exist in the inventory: %v" , localAddr .String ())
185
185
186
- for _ , m := range bytes_metric .Metrics {
186
+ for _ , m := range bytesMetric .Metrics {
187
187
metric := m .(prom2json.Metric )
188
- destIp := net .ParseIP (metric .Labels ["daddr" ])
188
+ destIP := net .ParseIP (metric .Labels ["daddr" ])
189
189
190
- if destIp .Equal (localAddr ) || destIp .Equal (nil ) {
190
+ if destIP .Equal (nil ) || destIP .Equal (localAddr ) {
191
191
continue
192
192
}
193
193
0 commit comments