Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APR-258] Add option to compress logs with zstd #27148

Merged
merged 106 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
f994dd7
Add option to compress logs with zstd.
StephenWakely Jun 28, 2024
20ad1a3
Formatting
StephenWakely Jun 28, 2024
a5f4f8e
Linters
StephenWakely Jun 28, 2024
f345970
Add telemetry to the compressor.
StephenWakely Jul 1, 2024
9e4f325
Reuse metric compression component for logs.
StephenWakely Aug 30, 2024
720586b
Add gzip strategy
StephenWakely Sep 2, 2024
d548d9c
Add gzip strategy
StephenWakely Sep 2, 2024
7e4ded1
Remove old compression code.
StephenWakely Sep 2, 2024
bb841d6
Caller can limit compression algorithms available.
StephenWakely Sep 3, 2024
03c3252
Correct compress bound for gzip.
StephenWakely Sep 4, 2024
9d6acea
Merge remote-tracking branch 'origin' into stephen/zstd_logs
StephenWakely Sep 4, 2024
fd38e3c
Fix broken tests.
StephenWakely Sep 5, 2024
3ec6157
Tidy
StephenWakely Sep 5, 2024
f87e432
Fix dependency runtime errors.
StephenWakely Sep 9, 2024
38aafb7
Fix dependency for otel
StephenWakely Sep 9, 2024
37cfb7f
Wip, fix tests
StephenWakely Sep 11, 2024
08713c5
Merge remote-tracking branch 'origin' into stephen/zstd_logs
StephenWakely Sep 20, 2024
8a62b59
Fix tests to load compressor from provided config.
StephenWakely Sep 20, 2024
f729333
Remove unnecessary metrics.
StephenWakely Sep 20, 2024
ad84375
Include jemalloc
StephenWakely Sep 20, 2024
de2dc05
Fix linter errors
StephenWakely Sep 23, 2024
6db5379
replace
StephenWakely Sep 25, 2024
949157d
Add logging to compression strategies
StephenWakely Sep 25, 2024
835d804
Merge remote-tracking branch 'origin' into stephen/zstd_logs
StephenWakely Nov 6, 2024
0d5f4b4
Linter errors
StephenWakely Nov 7, 2024
d3ca210
Added extra build tag.
StephenWakely Nov 11, 2024
46d2553
Lint
StephenWakely Nov 11, 2024
5a6fa64
Fix tests.
StephenWakely Nov 18, 2024
6e54576
Added dependency.
StephenWakely Nov 18, 2024
b60c9e3
Linter errors
StephenWakely Nov 18, 2024
2027535
Copyrights
StephenWakely Nov 18, 2024
1c2dc1d
gofmt
StephenWakely Nov 18, 2024
3b6c13d
Merge remote-tracking branch 'origin/main' into stephen/zstd_logs
StephenWakely Nov 19, 2024
04d9922
Merge remote-tracking branch 'origin' into stephen/zstd_logs
StephenWakely Nov 19, 2024
6759dcf
Linter errors
StephenWakely Nov 19, 2024
3ea013e
Fix otel
StephenWakely Nov 19, 2024
56fbdff
Fix test.
StephenWakely Nov 20, 2024
c28eb10
Remove jemalloc
StephenWakely Nov 20, 2024
d6f30bc
Go mod tidy
StephenWakely Nov 20, 2024
a85c0ab
Squashed commit of the following:
StephenWakely Nov 21, 2024
474d995
Fixed build errors
StephenWakely Nov 21, 2024
bd5dd02
Linter errors
StephenWakely Nov 22, 2024
7cf312c
Add gzip and no build tags option.
StephenWakely Nov 22, 2024
f076eba
Fixed remaining tests
StephenWakely Nov 22, 2024
7e8853b
Merge remote-tracking branch 'origin' into stephen/zstd_logs
StephenWakely Nov 22, 2024
983044b
CI Errors.
StephenWakely Nov 25, 2024
93c0fff
Merge remote-tracking branch 'origin' into stephen/zstd_logs
StephenWakely Nov 27, 2024
79246d9
Lints
StephenWakely Nov 28, 2024
872a4df
Merge remote-tracking branch 'origin' into stephen/zstd_logs
StephenWakely Nov 28, 2024
a11f591
Fix dodgy merge
StephenWakely Nov 28, 2024
8befb87
Fixed merge
StephenWakely Nov 28, 2024
b1b8d0d
Add missing parameter
StephenWakely Nov 28, 2024
c888885
Fix test dependency.
StephenWakely Nov 29, 2024
d8874e4
Inject compressionFactory into serverless
StephenWakely Nov 29, 2024
876b8ae
Add parameter for unsupported
StephenWakely Nov 29, 2024
320dc2b
Add some logging
StephenWakely Dec 3, 2024
703ba26
Feedback from pgimalac
StephenWakely Dec 4, 2024
fe3db79
Added compression factory for CWS reporter.
StephenWakely Dec 4, 2024
107d519
Merge remote-tracking branch 'origin/main' into stephen/zstd_logs
StephenWakely Dec 4, 2024
616f9ac
Fixed demultiplexer test
StephenWakely Dec 4, 2024
c95cb32
More details in max size comment for gzip
StephenWakely Dec 4, 2024
09112ea
Update serverless test dependencies
StephenWakely Dec 4, 2024
13fbfd6
Remove the compression factory.
StephenWakely Dec 12, 2024
ad214bb
Remove fx-factory
StephenWakely Dec 12, 2024
b60df43
Merge remote-tracking branch 'origin' into stephen/zstd_logs
StephenWakely Dec 12, 2024
3bf2fae
Gofmt
StephenWakely Dec 12, 2024
562ae56
Update components
StephenWakely Dec 13, 2024
d22884a
Update components
StephenWakely Dec 13, 2024
5b7f07e
TEMPORARILY change the default compression for logs
StephenWakely Dec 13, 2024
2b3b083
Remove unused code
StephenWakely Dec 16, 2024
b6d5380
Fixed tests.
StephenWakely Dec 17, 2024
ce2a5ff
Added a NoopCompressor module.
StephenWakely Dec 17, 2024
a61f56d
Merge branch 'main' into stephen/zstd_logs
remeh Dec 20, 2024
7b0caf9
inv tidy && inv tidy
remeh Dec 20, 2024
d55cf94
PR feedback
jszwedko Dec 20, 2024
3bc1ad9
Replace version numbers for compression module
jszwedko Dec 20, 2024
c3f4e4e
Avoid throwing away error
jszwedko Dec 20, 2024
219ab7f
Create multiple components
StephenWakely Dec 20, 2024
cda88e9
Refactor to separate components
StephenWakely Jan 3, 2025
f7a59b5
Passed lints
StephenWakely Jan 7, 2025
fb0fadc
Fix tests
StephenWakely Jan 9, 2025
a53f926
Added separate otel compression component.
StephenWakely Jan 10, 2025
23bb4da
Fix otel integration test.
StephenWakely Jan 10, 2025
11c6975
Merge remote-tracking branch 'origin/main' into stephen/zstd_logs
StephenWakely Jan 10, 2025
2bca491
Lints
StephenWakely Jan 13, 2025
d1883bf
Merge remote-tracking branch 'origin/main' into stephen/zstd_logs
StephenWakely Jan 13, 2025
7e4cbe6
Fix tests.
StephenWakely Jan 13, 2025
82a66c6
Lints
StephenWakely Jan 13, 2025
db10f48
More lints
StephenWakely Jan 13, 2025
5f75fa9
Lints
StephenWakely Jan 13, 2025
5081593
Extra module replaces
StephenWakely Jan 14, 2025
ce710df
Fix modules
StephenWakely Jan 14, 2025
12b8f2d
Merge remote-tracking branch 'origin/main' into stephen/zstd_logs
StephenWakely Jan 14, 2025
3a5ac7b
Fix go versions for otel
StephenWakely Jan 14, 2025
c5a1010
Lints
StephenWakely Jan 14, 2025
243d01d
More lints
StephenWakely Jan 14, 2025
820f26f
Provide fx
StephenWakely Jan 15, 2025
bce1dc4
Merge remote-tracking branch 'origin/main' into stephen/zstd_logs
StephenWakely Jan 15, 2025
da72b2f
Update compression module name.
StephenWakely Jan 15, 2025
746fe48
Inject metrics compression for systray.
StephenWakely Jan 15, 2025
7566372
Revert serverless test module
StephenWakely Jan 15, 2025
4dbb30b
Updated with feedback from Olivier
StephenWakely Jan 15, 2025
77cc39f
Fix fromconfig.
StephenWakely Jan 16, 2025
1c75357
Merge remote-tracking branch 'origin/main' into stephen/zstd_logs
StephenWakely Jan 16, 2025
63770e2
Feedback from Rémy and Brian
StephenWakely Jan 16, 2025
fdc16ca
Update copyright
StephenWakely Jan 16, 2025
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
4 changes: 3 additions & 1 deletion cmd/cluster-agent/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import (
rccomp "github.com/DataDog/datadog-agent/comp/remote-config/rcservice"
"github.com/DataDog/datadog-agent/comp/remote-config/rcservice/rcserviceimpl"
"github.com/DataDog/datadog-agent/comp/remote-config/rctelemetryreporter/rctelemetryreporterimpl"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
"github.com/DataDog/datadog-agent/pkg/clusteragent"
admissionpkg "github.com/DataDog/datadog-agent/pkg/clusteragent/admission"
admissionpatch "github.com/DataDog/datadog-agent/pkg/clusteragent/admission/patch"
Expand Down Expand Up @@ -227,6 +228,7 @@ func start(log log.Component,
logReceiver optional.Option[integrations.Component],
_ healthprobe.Component,
settings settings.Component,
compressionFactory compression.Factory,
datadogConfig config.Component,
) error {
stopCh := make(chan struct{})
Expand Down Expand Up @@ -440,7 +442,7 @@ func start(log log.Component,
go func() {
defer wg.Done()

if err := runCompliance(mainCtx, demultiplexer, wmeta, apiCl, le.IsLeader); err != nil {
if err := runCompliance(mainCtx, demultiplexer, wmeta, apiCl, compressionFactory, le.IsLeader); err != nil {
pkglog.Errorf("Error while running compliance agent: %v", err)
}
}()
Expand Down
9 changes: 5 additions & 4 deletions cmd/cluster-agent/subcommands/start/compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
"github.com/DataDog/datadog-agent/pkg/aggregator/sender"
"github.com/DataDog/datadog-agent/pkg/compliance"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
Expand All @@ -31,9 +32,9 @@ const (
intakeTrackType = "compliance"
)

func runCompliance(ctx context.Context, senderManager sender.SenderManager, wmeta workloadmeta.Component, apiCl *apiserver.APIClient, isLeader func() bool) error {
func runCompliance(ctx context.Context, senderManager sender.SenderManager, wmeta workloadmeta.Component, apiCl *apiserver.APIClient, compressionFactory compression.Factory, isLeader func() bool) error {
stopper := startstop.NewSerialStopper()
if err := startCompliance(senderManager, wmeta, stopper, apiCl, isLeader); err != nil {
if err := startCompliance(senderManager, wmeta, stopper, apiCl, isLeader, compressionFactory); err != nil {
return err
}

Expand Down Expand Up @@ -72,7 +73,7 @@ func newLogContextCompliance() (*config.Endpoints, *client.DestinationsContext,
return newLogContext(logsConfigComplianceKeys, "cspm-intake.")
}

func startCompliance(senderManager sender.SenderManager, wmeta workloadmeta.Component, stopper startstop.Stopper, apiCl *apiserver.APIClient, isLeader func() bool) error {
func startCompliance(senderManager sender.SenderManager, wmeta workloadmeta.Component, stopper startstop.Stopper, apiCl *apiserver.APIClient, isLeader func() bool, compressionFactory compression.Factory) error {
endpoints, ctx, err := newLogContextCompliance()
if err != nil {
log.Error(err)
Expand All @@ -87,7 +88,7 @@ func startCompliance(senderManager sender.SenderManager, wmeta workloadmeta.Comp
return err
}

reporter := compliance.NewLogReporter(hname, "compliance-agent", "compliance", endpoints, ctx)
reporter := compliance.NewLogReporter(hname, "compliance-agent", "compliance", endpoints, ctx, compressionFactory)
statsdClient, err := simpleTelemetrySenderFromSenderManager(senderManager)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions cmd/dogstatsd/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
"github.com/DataDog/datadog-agent/comp/metadata/runner"
metadatarunnerimpl "github.com/DataDog/datadog-agent/comp/metadata/runner/runnerimpl"
compressionfx "github.com/DataDog/datadog-agent/comp/serializer/compression/fx"
compressionfxfactory "github.com/DataDog/datadog-agent/comp/serializer/compression/fx-factory"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
"github.com/DataDog/datadog-agent/pkg/serializer"
"github.com/DataDog/datadog-agent/pkg/status/health"
Expand Down Expand Up @@ -142,6 +143,7 @@ func RunDogstatsdFct(cliParams *CLIParams, defaultConfPath string, defaultLogFil
AgentType: workloadmeta.NodeAgent,
InitHelper: common.GetWorkloadmetaInit(),
}),
compressionfxfactory.ModuleFactory(),
compressionfx.Module(),
demultiplexerimpl.Module(demultiplexerimpl.NewDefaultParams(
demultiplexerimpl.WithContinueOnMissingHostname(),
Expand Down
2 changes: 2 additions & 0 deletions cmd/otel-agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
remoteTaggerFx "github.com/DataDog/datadog-agent/comp/core/tagger/fx-remote"
taggerTypes "github.com/DataDog/datadog-agent/comp/core/tagger/types"
"github.com/DataDog/datadog-agent/comp/core/telemetry/telemetryimpl"
compressionfx "github.com/DataDog/datadog-agent/comp/serializer/compression/fx-factory"

workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
workloadmetafx "github.com/DataDog/datadog-agent/comp/core/workloadmeta/fx"
Expand Down Expand Up @@ -128,6 +129,7 @@ func runOTelAgentCommand(ctx context.Context, params *subcommands.GlobalParams,
fetchonlyimpl.Module(),
collectorfx.Module(),
collectorcontribFx.Module(),
compressionfx.ModuleFactory(),
converterfx.Module(),
fx.Provide(func(cp converter.Component) confmap.Converter {
return cp
Expand Down
5 changes: 3 additions & 2 deletions cmd/security-agent/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/DataDog/datadog-agent/comp/dogstatsd"
"github.com/DataDog/datadog-agent/comp/dogstatsd/statsd"
"github.com/DataDog/datadog-agent/comp/metadata/host/hostimpl"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
commonsettings "github.com/DataDog/datadog-agent/pkg/config/settings"

"github.com/DataDog/datadog-agent/pkg/collector/python"
Expand Down Expand Up @@ -133,7 +134,7 @@ func (s *service) Run(svcctx context.Context) error {
AgentType: catalog,
}
}),
fx.Provide(func(log log.Component, config config.Component, statsd statsd.Component, wmeta workloadmeta.Component) (status.InformationProvider, *agent.RuntimeSecurityAgent, error) {
fx.Provide(func(log log.Component, config config.Component, statsd statsd.Component, wmeta workloadmeta.Component, compression compression.Factory) (status.InformationProvider, *agent.RuntimeSecurityAgent, error) {
stopper := startstop.NewSerialStopper()

statsdClient, err := statsd.CreateForHostPort(setup.GetBindHost(config), config.GetInt("dogstatsd_port"))
Expand All @@ -147,7 +148,7 @@ func (s *service) Run(svcctx context.Context) error {
return status.NewInformationProvider(nil), nil, err
}

runtimeAgent, err := runtime.StartRuntimeSecurity(log, config, hostnameDetected, stopper, statsdClient, wmeta)
runtimeAgent, err := runtime.StartRuntimeSecurity(log, config, hostnameDetected, stopper, statsdClient, wmeta, compression)
if err != nil {
return status.NewInformationProvider(nil), nil, err
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/security-agent/subcommands/check/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig/sysprobeconfigimpl"
"github.com/DataDog/datadog-agent/comp/dogstatsd"
"github.com/DataDog/datadog-agent/comp/dogstatsd/statsd"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
"github.com/DataDog/datadog-agent/pkg/compliance"
"github.com/DataDog/datadog-agent/pkg/compliance/k8sconfig"
"github.com/DataDog/datadog-agent/pkg/security/common"
Expand Down Expand Up @@ -109,7 +110,7 @@ func commandsWrapped(bundleParamsFactory func() core.BundleParams) []*cobra.Comm
}

// RunCheck runs a check
func RunCheck(log log.Component, config config.Component, _ secrets.Component, statsdComp statsd.Component, checkArgs *CliParams) error {
func RunCheck(log log.Component, config config.Component, _ secrets.Component, statsdComp statsd.Component, checkArgs *CliParams, compressionFactory compression.Factory) error {
hname, err := hostname.Get(context.TODO())
if err != nil {
return err
Expand Down Expand Up @@ -218,7 +219,7 @@ func RunCheck(log log.Component, config config.Component, _ secrets.Component, s
}
}
if checkArgs.report {
if err := reportComplianceEvents(log, events); err != nil {
if err := reportComplianceEvents(log, events, compressionFactory); err != nil {
log.Error(err)
return err
}
Expand All @@ -241,7 +242,7 @@ func dumpComplianceEvents(reportFile string, events []*compliance.CheckEvent) er
return nil
}

func reportComplianceEvents(log log.Component, events []*compliance.CheckEvent) error {
func reportComplianceEvents(log log.Component, events []*compliance.CheckEvent, compressionFactory compression.Factory) error {
hostnameDetected, err := utils.GetHostnameWithContextAndFallback(context.Background())
if err != nil {
return log.Errorf("Error while getting hostname, exiting: %v", err)
Expand All @@ -250,7 +251,7 @@ func reportComplianceEvents(log log.Component, events []*compliance.CheckEvent)
if err != nil {
return fmt.Errorf("reporter: could not reate log context for compliance: %w", err)
}
reporter := compliance.NewLogReporter(hostnameDetected, "compliance-agent", "compliance", endpoints, context)
reporter := compliance.NewLogReporter(hostnameDetected, "compliance-agent", "compliance", endpoints, context, compressionFactory)
defer reporter.Stop()
for _, event := range events {
reporter.ReportEvent(event)
Expand Down
5 changes: 3 additions & 2 deletions cmd/security-agent/subcommands/compliance/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/config"
log "github.com/DataDog/datadog-agent/comp/core/log/def"
"github.com/DataDog/datadog-agent/comp/core/secrets"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
"github.com/DataDog/datadog-agent/pkg/compliance"
"github.com/DataDog/datadog-agent/pkg/compliance/aptconfig"
"github.com/DataDog/datadog-agent/pkg/compliance/dbconfig"
Expand Down Expand Up @@ -176,7 +177,7 @@ func complianceEventCommand(globalParams *command.GlobalParams) *cobra.Command {
return eventCmd
}

func eventRun(log log.Component, eventArgs *eventCliParams) error {
func eventRun(log log.Component, eventArgs *eventCliParams, compressionFactory compression.Factory) error {
hostnameDetected, err := secutils.GetHostnameWithContextAndFallback(context.Background())
if err != nil {
return log.Errorf("Error while getting hostname, exiting: %v", err)
Expand All @@ -187,7 +188,7 @@ func eventRun(log log.Component, eventArgs *eventCliParams) error {
return err
}

reporter := compliance.NewLogReporter(hostnameDetected, eventArgs.sourceName, eventArgs.sourceType, endpoints, dstContext)
reporter := compliance.NewLogReporter(hostnameDetected, eventArgs.sourceName, eventArgs.sourceType, endpoints, dstContext, compressionFactory)
defer reporter.Stop()

eventData := make(map[string]interface{})
Expand Down
14 changes: 12 additions & 2 deletions cmd/security-agent/subcommands/compliance/compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/sysprobeconfig"
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
"github.com/DataDog/datadog-agent/comp/dogstatsd/constants"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
"github.com/DataDog/datadog-agent/pkg/compliance"
"github.com/DataDog/datadog-agent/pkg/security/common"
"github.com/DataDog/datadog-agent/pkg/security/telemetry"
Expand All @@ -28,7 +29,16 @@ import (

// StartCompliance runs the compliance sub-agent running compliance benchmarks
// and checks.
func StartCompliance(log log.Component, config config.Component, sysprobeconfig sysprobeconfig.Component, hostname string, stopper startstop.Stopper, statsdClient ddgostatsd.ClientInterface, wmeta workloadmeta.Component) (*compliance.Agent, error) {
func StartCompliance(log log.Component,
config config.Component,
sysprobeconfig sysprobeconfig.Component,
hostname string,
stopper startstop.Stopper,
statsdClient ddgostatsd.ClientInterface,
wmeta workloadmeta.Component,
compressionFactory compression.Factory,
) (*compliance.Agent, error) {

enabled := config.GetBool("compliance_config.enabled")
configDir := config.GetString("compliance_config.dir")
metricsEnabled := config.GetBool("compliance_config.metrics.enabled")
Expand Down Expand Up @@ -67,7 +77,7 @@ func StartCompliance(log log.Component, config config.Component, sysprobeconfig
enabledConfigurationsExporters = append(enabledConfigurationsExporters, compliance.DBExporter)
}

reporter := compliance.NewLogReporter(hostname, "compliance-agent", "compliance", endpoints, context)
reporter := compliance.NewLogReporter(hostname, "compliance-agent", "compliance", endpoints, context, compressionFactory)
telemetrySender := telemetry.NewSimpleTelemetrySenderFromStatsd(statsdClient)

agent := compliance.NewAgent(telemetrySender, wmeta, compliance.AgentOptions{
Expand Down
5 changes: 3 additions & 2 deletions cmd/security-agent/subcommands/runtime/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
log "github.com/DataDog/datadog-agent/comp/core/log/def"
"github.com/DataDog/datadog-agent/comp/core/secrets"
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
secagent "github.com/DataDog/datadog-agent/pkg/security/agent"
"github.com/DataDog/datadog-agent/pkg/security/common"
Expand Down Expand Up @@ -698,7 +699,7 @@ func reloadRuntimePolicies(_ log.Component, _ config.Component, _ secrets.Compon
}

// StartRuntimeSecurity starts runtime security
func StartRuntimeSecurity(log log.Component, config config.Component, hostname string, stopper startstop.Stopper, statsdClient ddgostatsd.ClientInterface, wmeta workloadmeta.Component) (*secagent.RuntimeSecurityAgent, error) {
func StartRuntimeSecurity(log log.Component, config config.Component, hostname string, stopper startstop.Stopper, statsdClient ddgostatsd.ClientInterface, wmeta workloadmeta.Component, compressionFactory compression.Factory) (*secagent.RuntimeSecurityAgent, error) {
enabled := config.GetBool("runtime_security_config.enabled")
if !enabled {
log.Info("Datadog runtime security agent disabled by config")
Expand All @@ -722,7 +723,7 @@ func StartRuntimeSecurity(log log.Component, config config.Component, hostname s
}
stopper.Add(ctx)

reporter, err := reporter.NewCWSReporter(hostname, stopper, endpoints, ctx)
reporter, err := reporter.NewCWSReporter(hostname, stopper, endpoints, ctx, compressionFactory)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/DataDog/datadog-agent/comp/core/config"
log "github.com/DataDog/datadog-agent/comp/core/log/def"
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
secagent "github.com/DataDog/datadog-agent/pkg/security/agent"
"github.com/DataDog/datadog-agent/pkg/util/startstop"
"github.com/DataDog/datadog-go/v5/statsd"
Expand All @@ -28,7 +29,7 @@ func Commands(*command.GlobalParams) []*cobra.Command {
}

// StartRuntimeSecurity starts runtime security
func StartRuntimeSecurity(log log.Component, config config.Component, _ string, _ startstop.Stopper, _ statsd.ClientInterface, _ workloadmeta.Component) (*secagent.RuntimeSecurityAgent, error) {
func StartRuntimeSecurity(log log.Component, config config.Component, _ string, _ startstop.Stopper, _ statsd.ClientInterface, _ workloadmeta.Component, _ compression.Factory) (*secagent.RuntimeSecurityAgent, error) {
enabled := config.GetBool("runtime_security_config.enabled")
if !enabled {
log.Info("Datadog runtime security agent disabled by config")
Expand Down
9 changes: 5 additions & 4 deletions cmd/security-agent/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"github.com/DataDog/datadog-agent/comp/dogstatsd"
"github.com/DataDog/datadog-agent/comp/dogstatsd/statsd"
"github.com/DataDog/datadog-agent/comp/metadata/host/hostimpl"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
"github.com/DataDog/datadog-agent/pkg/api/security"
"github.com/DataDog/datadog-agent/pkg/collector/python"
pkgCompliance "github.com/DataDog/datadog-agent/pkg/compliance"
Expand Down Expand Up @@ -130,13 +131,13 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
fx.Provide(func(config config.Component, statsd statsd.Component) (ddgostatsd.ClientInterface, error) {
return statsd.CreateForHostPort(pkgconfigsetup.GetBindHost(config), config.GetInt("dogstatsd_port"))
}),
fx.Provide(func(stopper startstop.Stopper, log log.Component, config config.Component, statsdClient ddgostatsd.ClientInterface, wmeta workloadmeta.Component) (status.InformationProvider, *agent.RuntimeSecurityAgent, error) {
fx.Provide(func(stopper startstop.Stopper, log log.Component, config config.Component, statsdClient ddgostatsd.ClientInterface, wmeta workloadmeta.Component, compressionFactory compression.Factory) (status.InformationProvider, *agent.RuntimeSecurityAgent, error) {
hostnameDetected, err := utils.GetHostnameWithContextAndFallback(context.TODO())
if err != nil {
return status.NewInformationProvider(nil), nil, err
}

runtimeAgent, err := runtime.StartRuntimeSecurity(log, config, hostnameDetected, stopper, statsdClient, wmeta)
runtimeAgent, err := runtime.StartRuntimeSecurity(log, config, hostnameDetected, stopper, statsdClient, wmeta, compressionFactory)
if err != nil {
return status.NewInformationProvider(nil), nil, err
}
Expand All @@ -148,14 +149,14 @@ func Commands(globalParams *command.GlobalParams) []*cobra.Command {
// TODO - components: Do not remove runtimeAgent ref until "github.com/DataDog/datadog-agent/pkg/security/agent" is a component so they're not GCed
return status.NewInformationProvider(runtimeAgent.StatusProvider()), runtimeAgent, nil
}),
fx.Provide(func(stopper startstop.Stopper, log log.Component, config config.Component, statsdClient ddgostatsd.ClientInterface, sysprobeconfig sysprobeconfig.Component, wmeta workloadmeta.Component) (status.InformationProvider, *pkgCompliance.Agent, error) {
fx.Provide(func(stopper startstop.Stopper, log log.Component, config config.Component, statsdClient ddgostatsd.ClientInterface, sysprobeconfig sysprobeconfig.Component, wmeta workloadmeta.Component, compressionFactory compression.Factory) (status.InformationProvider, *pkgCompliance.Agent, error) {
hostnameDetected, err := utils.GetHostnameWithContextAndFallback(context.TODO())
if err != nil {
return status.NewInformationProvider(nil), nil, err
}

// start compliance security agent
complianceAgent, err := compliance.StartCompliance(log, config, sysprobeconfig, hostnameDetected, stopper, statsdClient, wmeta)
complianceAgent, err := compliance.StartCompliance(log, config, sysprobeconfig, hostnameDetected, stopper, statsdClient, wmeta, compressionFactory)
if err != nil {
return status.NewInformationProvider(nil), nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/serverless-init/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def"
logsAgent "github.com/DataDog/datadog-agent/comp/logs/agent"
logConfig "github.com/DataDog/datadog-agent/comp/logs/agent/config"
compression "github.com/DataDog/datadog-agent/comp/serializer/compression/def"
"github.com/DataDog/datadog-agent/pkg/logs/sources"
serverlessLogs "github.com/DataDog/datadog-agent/pkg/serverless/logs"
serverlessTag "github.com/DataDog/datadog-agent/pkg/serverless/tags"
Expand Down Expand Up @@ -53,8 +54,8 @@ func CreateConfig(origin string) *Config {
}

// SetupLogAgent creates the log agent and sets the base tags
func SetupLogAgent(conf *Config, tags map[string]string, tagger tagger.Component) logsAgent.ServerlessLogsAgent {
logsAgent, _ := serverlessLogs.SetupLogAgent(conf.Channel, sourceName, conf.source, tagger)
func SetupLogAgent(conf *Config, tags map[string]string, tagger tagger.Component, compressionFactory compression.Factory) logsAgent.ServerlessLogsAgent {
logsAgent, _ := serverlessLogs.SetupLogAgent(conf.Channel, sourceName, conf.source, tagger, compressionFactory)

tagsArray := serverlessTag.MapToArray(tags)

Expand Down
Loading
Loading