-
Notifications
You must be signed in to change notification settings - Fork 244
/
Copy pathinput.go
34 lines (28 loc) · 974 Bytes
/
input.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
package tracing
import (
"errors"
"log"
"github.com/cloudflare/ebpf_exporter/v2/config"
"github.com/cloudflare/ebpf_exporter/v2/decoder"
"github.com/prometheus/client_golang/prometheus"
)
// HandleInput reads inputs from the input channel and turns them into spans
func HandleInput(input <-chan []byte, provider Provider, decoders *decoder.Set, configName string, config config.Span, errorCounter prometheus.Counter) {
for raw := range input {
err := handleRawBytes(raw, provider, decoders, configName, config)
if err != nil {
if !errors.Is(err, decoder.ErrSkipLabelSet) {
errorCounter.Inc()
log.Printf("Error handing raw span bytes: %v", err)
}
continue
}
}
}
func handleRawBytes(raw []byte, provider Provider, decoders *decoder.Set, configName string, config config.Span) error {
decoded, err := extractLabels(raw, decoders, config)
if err != nil {
return err
}
return handleDecodedLabels(provider, decoded, configName, config)
}