Skip to content

Commit da19b2c

Browse files
authored
[ AGNTLOG-56 ] - Shift pkg/logs over to the new implementation of the auditor (#36259)
1 parent d05c463 commit da19b2c

File tree

39 files changed

+175
-151
lines changed

39 files changed

+175
-151
lines changed

comp/logs/auditor/mock/auditor_mock.go

+82-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
// This product includes software developed at Datadog (https://www.datadoghq.com/).
44
// Copyright 2025-present Datadog, Inc.
55

6+
//go:build test
7+
8+
// Package mock is the mock component for the auditor
69
package mock
710

811
import (
912
compdef "github.com/DataDog/datadog-agent/comp/def"
1013
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
11-
noneimpl "github.com/DataDog/datadog-agent/comp/logs/auditor/impl-none"
14+
"github.com/DataDog/datadog-agent/pkg/logs/message"
1215
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
1316
)
1417

@@ -28,6 +31,83 @@ func AuditorMockModule() fxutil.Module {
2831

2932
func newMock() ProvidesMock {
3033
return ProvidesMock{
31-
Comp: noneimpl.NewAuditor(),
34+
Comp: NewMockAuditor(),
35+
}
36+
}
37+
38+
// NewMockAuditor returns a new mock auditor
39+
func NewMockAuditor() *Auditor {
40+
return &Auditor{
41+
Registry: Registry{},
42+
channel: make(chan *message.Payload),
43+
stopChannel: make(chan struct{}),
44+
ReceivedMessages: make([]*message.Payload, 0),
3245
}
3346
}
47+
48+
// Auditor is a mock auditor that does nothing
49+
type Auditor struct {
50+
Registry
51+
channel chan *message.Payload
52+
stopChannel chan struct{}
53+
ReceivedMessages []*message.Payload
54+
}
55+
56+
// Start starts the NullAuditor main loop
57+
func (a *Auditor) Start() {
58+
go a.run()
59+
}
60+
61+
// Stop stops the NullAuditor main loop
62+
func (a *Auditor) Stop() {
63+
a.stopChannel <- struct{}{}
64+
}
65+
66+
// Channel returns the channel messages should be sent on
67+
func (a *Auditor) Channel() chan *message.Payload {
68+
return a.channel
69+
}
70+
71+
// run is the main run loop for the null auditor
72+
func (a *Auditor) run() {
73+
for {
74+
select {
75+
case val := <-a.channel:
76+
a.ReceivedMessages = append(a.ReceivedMessages, val)
77+
case <-a.stopChannel:
78+
close(a.channel)
79+
return
80+
}
81+
}
82+
}
83+
84+
// Registry does nothing
85+
type Registry struct {
86+
offset string
87+
tailingMode string
88+
}
89+
90+
// NewMockRegistry returns a new mock registry.
91+
func NewMockRegistry() *Registry {
92+
return &Registry{}
93+
}
94+
95+
// GetOffset returns the offset.
96+
func (r *Registry) GetOffset(_ string) string {
97+
return r.offset
98+
}
99+
100+
// SetOffset sets the offset.
101+
func (r *Registry) SetOffset(offset string) {
102+
r.offset = offset
103+
}
104+
105+
// GetTailingMode returns the tailing mode.
106+
func (r *Registry) GetTailingMode(_ string) string {
107+
return r.tailingMode
108+
}
109+
110+
// SetTailingMode sets the tailing mode.
111+
func (r *Registry) SetTailingMode(tailingMode string) {
112+
r.tailingMode = tailingMode
113+
}

comp/logs/auditor/mock/registry_mock.go

-55
This file was deleted.

comp/otelcol/ddflareextension/impl/go.mod

+1-2
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,9 @@ require (
196196
github.com/DataDog/datadog-agent/pkg/config/structure v0.64.1 // indirect
197197
github.com/DataDog/datadog-agent/pkg/config/teeconfig v0.64.1 // indirect
198198
github.com/DataDog/datadog-agent/pkg/config/utils v0.64.0-rc.3 // indirect
199-
github.com/DataDog/datadog-agent/pkg/logs/auditor v0.64.0-rc.3 // indirect
200199
github.com/DataDog/datadog-agent/pkg/logs/client v0.64.0-rc.3 // indirect
201200
github.com/DataDog/datadog-agent/pkg/logs/diagnostic v0.64.0-rc.3 // indirect
202-
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.3 // indirect
201+
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.12 // indirect
203202
github.com/DataDog/datadog-agent/pkg/logs/metrics v0.64.0-rc.3 // indirect
204203
github.com/DataDog/datadog-agent/pkg/logs/pipeline v0.64.0-rc.3 // indirect
205204
github.com/DataDog/datadog-agent/pkg/logs/processor v0.64.0-rc.3 // indirect

comp/otelcol/logsagentpipeline/go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,16 @@ require (
2323
github.com/DataDog/datadog-agent/pkg/config/utils v0.61.0 // indirect
2424
github.com/DataDog/datadog-agent/pkg/config/viperconfig v0.64.1 // indirect
2525
github.com/DataDog/datadog-agent/pkg/fips v0.0.0 // indirect
26-
github.com/DataDog/datadog-agent/pkg/logs/auditor v0.64.0-rc.3 // indirect
2726
github.com/DataDog/datadog-agent/pkg/logs/client v0.64.0-rc.3 // indirect
2827
github.com/DataDog/datadog-agent/pkg/logs/diagnostic v0.64.0-rc.3 // indirect
29-
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.3 // indirect
28+
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.12 // indirect
3029
github.com/DataDog/datadog-agent/pkg/logs/metrics v0.64.0-rc.3 // indirect
3130
github.com/DataDog/datadog-agent/pkg/logs/processor v0.64.0-rc.3 // indirect
3231
github.com/DataDog/datadog-agent/pkg/logs/sds v0.64.0-rc.3 // indirect
3332
github.com/DataDog/datadog-agent/pkg/logs/sender v0.64.0-rc.3 // indirect
3433
github.com/DataDog/datadog-agent/pkg/logs/sources v0.61.0 // indirect
3534
github.com/DataDog/datadog-agent/pkg/logs/status/statusinterface v0.64.0-rc.3 // indirect
3635
github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.61.0 // indirect
37-
github.com/DataDog/datadog-agent/pkg/status/health v0.61.0 // indirect
3836
github.com/DataDog/datadog-agent/pkg/telemetry v0.64.1 // indirect
3937
github.com/DataDog/datadog-agent/pkg/util/backoff v0.61.0 // indirect
4038
github.com/DataDog/datadog-agent/pkg/util/compression v0.64.0-rc.3 // indirect

comp/otelcol/logsagentpipeline/logsagentpipelineimpl/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/DataDog/datadog-agent/pkg/logs/auditor v0.64.0-rc.3
1616
github.com/DataDog/datadog-agent/pkg/logs/client v0.64.0-rc.3
1717
github.com/DataDog/datadog-agent/pkg/logs/diagnostic v0.64.0-rc.3
18-
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.3
18+
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.12
1919
github.com/DataDog/datadog-agent/pkg/logs/metrics v0.64.0-rc.3
2020
github.com/DataDog/datadog-agent/pkg/logs/pipeline v0.64.0-rc.3
2121
github.com/DataDog/datadog-agent/pkg/logs/sources v0.61.0

comp/otelcol/otlp/components/connector/datadogconnector/go.mod

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ require (
8282
github.com/DataDog/datadog-agent/pkg/config/utils v0.64.0-rc.3 // indirect
8383
github.com/DataDog/datadog-agent/pkg/config/viperconfig v0.64.1 // indirect
8484
github.com/DataDog/datadog-agent/pkg/fips v0.64.1 // indirect
85-
github.com/DataDog/datadog-agent/pkg/logs/auditor v0.64.0-rc.3 // indirect
8685
github.com/DataDog/datadog-agent/pkg/logs/client v0.64.0-rc.3 // indirect
8786
github.com/DataDog/datadog-agent/pkg/logs/diagnostic v0.64.0-rc.3 // indirect
88-
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.3 // indirect
87+
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.12 // indirect
8988
github.com/DataDog/datadog-agent/pkg/logs/metrics v0.64.0-rc.3 // indirect
9089
github.com/DataDog/datadog-agent/pkg/logs/pipeline v0.64.0-rc.3 // indirect
9190
github.com/DataDog/datadog-agent/pkg/logs/processor v0.64.0-rc.3 // indirect

comp/otelcol/otlp/components/exporter/datadogexporter/go.mod

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/metricsclient v0.64.0-rc.3
1010
github.com/DataDog/datadog-agent/comp/trace/agent/def v0.61.0
1111
github.com/DataDog/datadog-agent/comp/trace/compression/impl-gzip v0.64.0-rc.3
12-
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.3
12+
github.com/DataDog/datadog-agent/pkg/logs/message v0.64.0-rc.12
1313
github.com/DataDog/datadog-agent/pkg/proto v0.64.2
1414
github.com/DataDog/datadog-agent/pkg/serializer v0.59.0
1515
github.com/DataDog/datadog-agent/pkg/trace v0.64.2
@@ -89,7 +89,6 @@ require (
8989
github.com/DataDog/datadog-agent/pkg/config/utils v0.61.0 // indirect
9090
github.com/DataDog/datadog-agent/pkg/config/viperconfig v0.64.1 // indirect
9191
github.com/DataDog/datadog-agent/pkg/fips v0.0.0 // indirect
92-
github.com/DataDog/datadog-agent/pkg/logs/auditor v0.64.0-rc.3 // indirect
9392
github.com/DataDog/datadog-agent/pkg/logs/client v0.64.0-rc.3 // indirect
9493
github.com/DataDog/datadog-agent/pkg/logs/diagnostic v0.64.0-rc.3 // indirect
9594
github.com/DataDog/datadog-agent/pkg/logs/metrics v0.64.0-rc.3 // indirect

pkg/logs/launchers/channel/launcher.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package channel
88

99
import (
1010
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
11-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
11+
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1212
"github.com/DataDog/datadog-agent/pkg/logs/launchers"
1313
"github.com/DataDog/datadog-agent/pkg/logs/pipeline"
1414
"github.com/DataDog/datadog-agent/pkg/logs/sources"

pkg/logs/launchers/container/launcher.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
1515
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
16-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
16+
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1717
"github.com/DataDog/datadog-agent/pkg/logs/launchers"
1818
"github.com/DataDog/datadog-agent/pkg/logs/launchers/container/tailerfactory"
1919
"github.com/DataDog/datadog-agent/pkg/logs/pipeline"

pkg/logs/launchers/container/launcher_no_kubelet_and_docker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package container
1111
import (
1212
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
1313
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
14-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
14+
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1515
"github.com/DataDog/datadog-agent/pkg/logs/launchers"
1616
"github.com/DataDog/datadog-agent/pkg/logs/pipeline"
1717
sourcesPkg "github.com/DataDog/datadog-agent/pkg/logs/sources"

pkg/logs/launchers/container/launcher_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
taggerfxmock "github.com/DataDog/datadog-agent/comp/core/tagger/fx-mock"
1818
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
1919
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
20-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
20+
auditorMock "github.com/DataDog/datadog-agent/comp/logs/auditor/mock"
2121
"github.com/DataDog/datadog-agent/pkg/logs/launchers"
2222
"github.com/DataDog/datadog-agent/pkg/logs/launchers/container/tailerfactory"
2323
"github.com/DataDog/datadog-agent/pkg/logs/pipeline"
@@ -43,7 +43,7 @@ func TestStartStop(t *testing.T) {
4343

4444
sp := launchers.NewMockSourceProvider()
4545
pl := pipeline.NewMockProvider()
46-
reg := auditor.New("/run", "agent", 0, nil)
46+
reg := auditorMock.NewMockRegistry()
4747
tailerTracker := tailers.NewTailerTracker()
4848
l.Start(sp, pl, reg, tailerTracker)
4949

pkg/logs/launchers/container/tailerfactory/factory.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ package tailerfactory
1212
import (
1313
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
1414
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
15-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
15+
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1616
"github.com/DataDog/datadog-agent/pkg/logs/internal/util/containersorpods"
1717
"github.com/DataDog/datadog-agent/pkg/logs/pipeline"
1818
"github.com/DataDog/datadog-agent/pkg/logs/sources"

pkg/logs/launchers/container/tailerfactory/tailers/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"context"
1313
"time"
1414

15-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
15+
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1616
"github.com/DataDog/datadog-agent/pkg/logs/message"
1717
"github.com/DataDog/datadog-agent/pkg/logs/sources"
1818
containerTailerPkg "github.com/DataDog/datadog-agent/pkg/logs/tailers/container"

pkg/logs/launchers/container/tailerfactory/tailers/shared.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
14-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
14+
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1515
)
1616

1717
// isEOFCorruptedOffset return true if the offset doesn't contain a

pkg/logs/launchers/container/tailerfactory/tailers/socket.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"context"
1313
"time"
1414

15-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
15+
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1616
"github.com/DataDog/datadog-agent/pkg/logs/message"
1717
"github.com/DataDog/datadog-agent/pkg/logs/sources"
1818
containerTailerPkg "github.com/DataDog/datadog-agent/pkg/logs/tailers/container"

pkg/logs/launchers/container/tailerfactory/tailers/tailer.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ package tailers
99

1010
import (
1111
"context"
12-
containerutilPkg "github.com/DataDog/datadog-agent/pkg/util/containers"
1312
"time"
1413

14+
containerutilPkg "github.com/DataDog/datadog-agent/pkg/util/containers"
15+
1516
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
16-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
17+
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1718
"github.com/DataDog/datadog-agent/pkg/logs/message"
1819
"github.com/DataDog/datadog-agent/pkg/logs/sources"
1920
containerTailerPkg "github.com/DataDog/datadog-agent/pkg/logs/tailers/container"

pkg/logs/launchers/file/launcher.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
1515
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
1616
flareController "github.com/DataDog/datadog-agent/comp/logs/agent/flare"
17-
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
17+
auditor "github.com/DataDog/datadog-agent/comp/logs/auditor/def"
1818
"github.com/DataDog/datadog-agent/pkg/logs/internal/decoder"
1919
"github.com/DataDog/datadog-agent/pkg/logs/launchers"
2020
fileprovider "github.com/DataDog/datadog-agent/pkg/logs/launchers/file/provider"

0 commit comments

Comments
 (0)