Skip to content

Commit

Permalink
usm: Remove irrelevant agent payload telemetry option (#33931)
Browse files Browse the repository at this point in the history
  • Loading branch information
guyarb authored Feb 11, 2025
1 parent a77568f commit 48ffdc4
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 102 deletions.
29 changes: 0 additions & 29 deletions pkg/network/encoding/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/DataDog/datadog-agent/pkg/network/protocols"
"github.com/DataDog/datadog-agent/pkg/network/protocols/http"
"github.com/DataDog/datadog-agent/pkg/network/protocols/kafka"
"github.com/DataDog/datadog-agent/pkg/network/protocols/telemetry"
"github.com/DataDog/datadog-agent/pkg/network/protocols/tls"
"github.com/DataDog/datadog-agent/pkg/process/util"
)
Expand Down Expand Up @@ -880,34 +879,6 @@ func TestPooledHTTP2ObjectGarbageRegression(t *testing.T) {
}
}

func TestUSMPayloadTelemetry(t *testing.T) {
telemetry.Clear()
t.Cleanup(telemetry.Clear)

// Set metric present in the payload telemetry list to an arbitrary value
m1 := telemetry.NewCounter("usm.http.total_hits", telemetry.OptPayloadTelemetry)
m1.Add(10)
require.Contains(t, network.USMPayloadTelemetry, network.ConnTelemetryType(m1.Name()))

// Add another metric that is not present in the allowed list
m2 := telemetry.NewCounter("foobar", telemetry.OptPayloadTelemetry)
m2.Add(50)
require.NotContains(t, network.USMPayloadTelemetry, network.ConnTelemetryType(m2.Name()))

// Perform a marshal/unmarshal cycle
in := new(network.Connections)
blobWriter := getBlobWriter(t, assert.New(t), in, "application/protobuf")

unmarshaler := unmarshal.GetUnmarshaler("application/protobuf")
result, err := unmarshaler.Unmarshal(blobWriter.Bytes())
require.NoError(t, err)

// Assert that the correct metric is present in the emitted payload
payloadTelemetry := result.ConnTelemetryMap
assert.Equal(t, int64(10), payloadTelemetry["usm.http.total_hits"])
assert.NotContains(t, payloadTelemetry, "foobar")
}

func TestKafkaSerializationWithLocalhostTraffic(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("the feature is only supported on linux.")
Expand Down
10 changes: 1 addition & 9 deletions pkg/network/encoding/marshal/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,9 @@ func FormatCompilationTelemetry(builder *model.ConnectionsBuilder, telByAsset ma

// FormatConnectionTelemetry converts telemetry from its internal representation to a protobuf message
func FormatConnectionTelemetry(builder *model.ConnectionsBuilder, tel map[network.ConnTelemetryType]int64) {
// Fetch USM payload telemetry
ret := GetUSMPayloadTelemetry()

// Merge it with NPM telemetry
for k, v := range tel {
ret[string(k)] = v
}

for k, v := range ret {
builder.AddConnTelemetryMap(func(w *model.Connections_ConnTelemetryMapEntryBuilder) {
w.SetKey(k)
w.SetKey(string(k))
w.SetValue(v)
})
}
Expand Down
35 changes: 0 additions & 35 deletions pkg/network/encoding/marshal/usm_payload_telemetry.go

This file was deleted.

8 changes: 0 additions & 8 deletions pkg/network/event_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ const (
ConnsBpfMapSize ConnTelemetryType = "conns_bpf_map_size"
ConntrackSamplingPercent ConnTelemetryType = "conntrack_sampling_percent"
NPMDriverFlowsMissedMaxExceeded ConnTelemetryType = "driver_flows_missed_max_exceeded"

// USM Payload Telemetry
USMHTTPHits ConnTelemetryType = "usm.http.total_hits"
)

//revive:enable
Expand Down Expand Up @@ -196,11 +193,6 @@ var (
MonotonicUDPSendsMissed,
MonotonicDNSPacketsDropped,
}

// USMPayloadTelemetry lists all USM metrics that are sent as payload telemetry
USMPayloadTelemetry = []ConnTelemetryType{
USMHTTPHits,
}
)

// RuntimeCompilationTelemetry stores telemetry related to the runtime compilation of various assets
Expand Down
3 changes: 0 additions & 3 deletions pkg/network/protocols/telemetry/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ const (

// OptPrometheus designates a metric that should be emitted using prometheus
OptPrometheus = "_prometheus"

// OptPayloadTelemetry designates a metric that should be emitted as agent payload telemetry
OptPayloadTelemetry = "_payload_telemetry"
)
4 changes: 0 additions & 4 deletions pkg/network/protocols/telemetry/registry_testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ func Clear() {
globalRegistry.Lock()
globalRegistry.metrics = nil
globalRegistry.Unlock()

telemetryDelta.mux.Lock()
telemetryDelta.stateByClientID = make(map[string]*clientState)
telemetryDelta.mux.Unlock()
}
14 changes: 0 additions & 14 deletions pkg/network/protocols/telemetry/reporters.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,6 @@ func ReportStatsd() {
}
}

var telemetryDelta deltaCalculator

// ReportPayloadTelemetry returns a map with all metrics tagged with `OptPayloadTelemetry`
// The return format is consistent with what we use in the protobuf messages sent to the backend
func ReportPayloadTelemetry(clientID string) map[string]int64 {
metrics := globalRegistry.GetMetrics(OptPayloadTelemetry)
previousValues := telemetryDelta.GetState(clientID)
result := make(map[string]int64, len(metrics))
for _, metric := range metrics {
result[metric.base().name] = previousValues.ValueFor(metric)
}
return result
}

var clientMux sync.Mutex
var client statsd.ClientInterface

Expand Down

0 comments on commit 48ffdc4

Please sign in to comment.