Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pkg/network/protocols/http/incomplete_iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@

package http

import (
"time"
)

// IncompleteBuffer is responsible for buffering incomplete transactions
// (eg. httpTX objects that have either only the request or response information)
type IncompleteBuffer interface {
Add(tx Transaction)
Flush(now time.Time) []Transaction
Flush() []Transaction
}
2 changes: 1 addition & 1 deletion pkg/network/protocols/http/incomplete_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (b *incompleteBuffer) Add(tx Transaction) {
}
}

func (b *incompleteBuffer) Flush(time.Time) []Transaction {
func (b *incompleteBuffer) Flush() []Transaction {
var (
joined []Transaction
previous = b.data
Expand Down
8 changes: 4 additions & 4 deletions pkg/network/protocols/http/incomplete_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestOrphanEntries(t *testing.T) {

buffer.Add(request)
now = now.Add(5 * time.Second)
complete := buffer.Flush(now)
complete := buffer.Flush()
assert.Len(t, complete, 0)

response := &EbpfEvent{
Expand All @@ -44,7 +44,7 @@ func TestOrphanEntries(t *testing.T) {
}
response.Tuple.Sport = 60000
buffer.Add(response)
complete = buffer.Flush(now)
complete = buffer.Flush()
require.Len(t, complete, 1)

completeTX := complete[0]
Expand All @@ -67,14 +67,14 @@ func TestOrphanEntries(t *testing.T) {
},
}
buffer.Add(request)
_ = buffer.Flush(time.Time{})
_ = buffer.Flush()

require.NotEmpty(t, buffer.data)
for key := range buffer.data {
buffer.data[key].requests[0].(*EbpfEvent).Http.Request_started = uint64(startTime - buffer.minAgeNano)
}

_ = buffer.Flush(time.Time{})
_ = buffer.Flush()
require.Empty(t, buffer.data)
})
}
4 changes: 1 addition & 3 deletions pkg/network/protocols/http/incomplete_stats_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
package http

import (
"time"

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

Expand All @@ -26,4 +24,4 @@ func NewIncompleteBuffer(*config.Config, *Telemetry) IncompleteBuffer {
func (b *incompleteBuffer) Add(Transaction) {}

//nolint:revive // TODO(WKIT) Fix revive linter
func (b *incompleteBuffer) Flush(time.Time) []Transaction { return nil }
func (b *incompleteBuffer) Flush() []Transaction { return nil }
2 changes: 1 addition & 1 deletion pkg/network/protocols/http/statkeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (h *StatKeeper) GetAndResetAllStats() (stats map[Key]*RequestStats) {
h.mux.Lock()
defer h.mux.Unlock()

for _, tx := range h.incomplete.Flush(time.Now()) {
for _, tx := range h.incomplete.Flush() {
h.add(tx)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/network/protocols/http2/incomplete_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (b *incompleteBuffer) Add(tx http.Transaction) {
}

// Flush flushes the buffer and returns the joined transactions.
func (b *incompleteBuffer) Flush(time.Time) []http.Transaction {
func (b *incompleteBuffer) Flush() []http.Transaction {
var (
joined []http.Transaction
previous = b.data
Expand Down
8 changes: 4 additions & 4 deletions pkg/network/protocols/http2/incomplete_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ func TestIncompleteBuffer(t *testing.T) {
},
}
buffer.Add(request)
transactions := buffer.Flush(now)
transactions := buffer.Flush()
require.Empty(t, transactions)
assert.True(t, len(buffer.data) == 1)

buffer.data[0].Stream.Response_last_seen = uint64(now.Add(time.Second).UnixNano())
transactions = buffer.Flush(now)
transactions = buffer.Flush()
require.Len(t, transactions, 1)
assert.True(t, len(buffer.data) == 0)
})
Expand All @@ -78,11 +78,11 @@ func TestIncompleteBuffer(t *testing.T) {
},
}
buffer.Add(request)
_ = buffer.Flush(time.Time{})
_ = buffer.Flush()
require.NotEmpty(t, buffer.data)

buffer.data[0].Stream.Request_started = uint64(startTime - buffer.minAgeNano)
_ = buffer.Flush(time.Time{})
_ = buffer.Flush()
require.Empty(t, buffer.data)
})
}
Loading