Skip to content

Commit

Permalink
[Backport 7.64.x] [CNM] incident-35509 fixes for failed TCP telemetry (
Browse files Browse the repository at this point in the history
…#34445)

Co-authored-by: Hasan Mahmood <[email protected]>
  • Loading branch information
agent-platform-auto-pr[bot] and hmahmood authored Feb 25, 2025
1 parent ff62275 commit 27e7f82
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/network/tracer/connection/ebpf_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var EbpfTracerTelemetry = struct {
prometheus.NewDesc(connTracerModuleName+"__tcp_close_target_failures", "Counter measuring the number of failed TCP connections in tcp_close", nil, nil),
prometheus.NewDesc(connTracerModuleName+"__tcp_done_connection_flush", "Counter measuring the number of connection flushes performed in tcp_done", nil, nil),
prometheus.NewDesc(connTracerModuleName+"__tcp_close_connection_flush", "Counter measuring the number of connection flushes performed in tcp_close", nil, nil),
telemetry.NewCounter(connTracerModuleName, "tcp_failed_connections", []string{}, "Gauge measuring the number of unsupported failed TCP connections"),
telemetry.NewCounter(connTracerModuleName, "tcp_failed_connections", []string{"errno"}, "Gauge measuring the number of unsupported failed TCP connections"),
prometheus.NewDesc(connTracerModuleName+"__tcp_syn_retransmit", "Counter measuring the number of tcp retransmits of syn packets", nil, nil),
telemetry.NewCounter(connTracerModuleName, "ongoing_connect_pid_cleaned", []string{}, "Counter measuring the number of tcp_ongoing_connect_pid entries cleaned in userspace"),
telemetry.NewStatCounterWrapper(connTracerModuleName, "pid_collisions", []string{}, "Counter measuring number of process collisions"),
Expand Down Expand Up @@ -553,16 +553,16 @@ func (t *ebpfTracer) getEBPFTelemetry() *netebpf.Telemetry {
return tm
}

func (t *ebpfTracer) getTCPFailureTelemetry() map[int]uint64 {
mp, err := maps.GetMap[int, uint64](t.m.Manager, probes.TCPFailureTelemetry)
func (t *ebpfTracer) getTCPFailureTelemetry() map[int32]uint64 {
mp, err := maps.GetMap[int32, uint64](t.m.Manager, probes.TCPFailureTelemetry)
if err != nil {
log.Warnf("error retrieving tcp failure telemetry map: %s", err)
return nil
}
it := mp.IterateWithBatchSize(100)
var key int
var key int32
var val uint64
result := make(map[int]uint64)
result := make(map[int32]uint64)

for it.Next(&key, &val) {
if err := it.Err(); err != nil {
Expand Down
28 changes: 28 additions & 0 deletions pkg/network/tracer/connection/ebpf_tracer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2025-present Datadog, Inc.

//go:build linux_bpf

// Package connection provides tracing for connections
package connection

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/DataDog/datadog-agent/pkg/ebpf/maps"
"github.com/DataDog/datadog-agent/pkg/network/config"
"github.com/DataDog/datadog-agent/pkg/network/ebpf/probes"
)

func TestFailedConnectionTelemetryMapLoads(t *testing.T) {
tr, err := newEbpfTracer(config.New(), nil)
require.NoError(t, err, "could not load tracer")
t.Cleanup(tr.Stop)

_, err = maps.GetMap[int32, uint64](tr.(*ebpfTracer).m.Manager, probes.TCPFailureTelemetry)
require.NoError(t, err, "error loading tcp failure telemetry map")
}

0 comments on commit 27e7f82

Please sign in to comment.