-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
tcp_queue_tracer.go
46 lines (36 loc) · 1.17 KB
/
tcp_queue_tracer.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
39
40
41
42
43
44
45
46
// +build linux
package modules
import (
"fmt"
"net/http"
"github.com/DataDog/datadog-agent/cmd/system-probe/api/module"
"github.com/DataDog/datadog-agent/cmd/system-probe/config"
"github.com/DataDog/datadog-agent/cmd/system-probe/utils"
"github.com/DataDog/datadog-agent/pkg/collector/corechecks/ebpf/probe"
"github.com/DataDog/datadog-agent/pkg/ebpf"
)
// TCPQueueLength Factory
var TCPQueueLength = module.Factory{
Name: config.TCPQueueLengthTracerModule,
Fn: func(cfg *config.Config) (module.Module, error) {
t, err := probe.NewTCPQueueLengthTracer(ebpf.NewConfig())
if err != nil {
return nil, fmt.Errorf("unable to start the TCP queue length tracer: %w", err)
}
return &tcpQueueLengthModule{t}, nil
},
}
var _ module.Module = &tcpQueueLengthModule{}
type tcpQueueLengthModule struct {
*probe.TCPQueueLengthTracer
}
func (t *tcpQueueLengthModule) Register(httpMux *module.Router) error {
httpMux.HandleFunc("/check/tcp_queue_length", func(w http.ResponseWriter, req *http.Request) {
stats := t.TCPQueueLengthTracer.GetAndFlush()
utils.WriteAsJSON(w, stats)
})
return nil
}
func (t *tcpQueueLengthModule) GetStats() map[string]interface{} {
return nil
}