Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com>
  • Loading branch information
StephenWakely committed Sep 23, 2024
1 parent ad84375 commit de2dc05
Show file tree
Hide file tree
Showing 30 changed files with 71 additions and 64 deletions.
1 change: 0 additions & 1 deletion cmd/cluster-agent-cloudfoundry/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import (
"github.com/DataDog/datadog-agent/comp/forwarder/eventplatformreceiver/eventplatformreceiverimpl"
orchestratorForwarderImpl "github.com/DataDog/datadog-agent/comp/forwarder/orchestrator/orchestratorimpl"
integrations "github.com/DataDog/datadog-agent/comp/logs/integrations/def"
"github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl"
"github.com/DataDog/datadog-agent/pkg/clusteragent"
"github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks"
pkgcollector "github.com/DataDog/datadog-agent/pkg/collector"
Expand Down
1 change: 0 additions & 1 deletion cmd/cluster-agent/subcommands/diagnose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ 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"
"github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl"
"github.com/DataDog/datadog-agent/pkg/diagnose"
"github.com/DataDog/datadog-agent/pkg/diagnose/diagnosis"
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
Expand Down
3 changes: 1 addition & 2 deletions cmd/cluster-agent/subcommands/start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ import (
"github.com/DataDog/datadog-agent/comp/remote-config/rcservice/rcserviceimpl"
"github.com/DataDog/datadog-agent/comp/remote-config/rctelemetryreporter/rctelemetryreporterimpl"
"github.com/DataDog/datadog-agent/comp/serializer/compression"
"github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl"
"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 @@ -431,7 +430,7 @@ func start(log log.Component,
go func() {
defer wg.Done()

if err := runCompliance(mainCtx, demultiplexer, wmeta, apiCl, le.IsLeader, compressionFactory); 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func FakeSamplerMockModule() fxutil.Module {

type fakeSamplerMockDependencies struct {
fx.In
Lc fx.Lifecycle
Log log.Component
Hostname hostname.Component
Compressor compression.Component
Lc fx.Lifecycle
Log log.Component
Hostname hostname.Component
CompressionFactory compression.Factory
}

type fakeSamplerMock struct {
Expand All @@ -56,7 +56,9 @@ func (f *fakeSamplerMock) Stop(flush bool) {
}

func newFakeSamplerMock(deps fakeSamplerMockDependencies) demultiplexerComp.FakeSamplerMock {
demux := initTestAgentDemultiplexerWithFlushInterval(deps.Log, deps.Hostname, deps.Compressor, time.Hour)
compressor := deps.CompressionFactory.NewNoopCompressor()

demux := initTestAgentDemultiplexerWithFlushInterval(deps.Log, deps.Hostname, compressor, deps.CompressionFactory, time.Hour)
mock := &fakeSamplerMock{
TestAgentDemultiplexer: demux,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (a *TestAgentDemultiplexer) Reset() {
}

// initTestAgentDemultiplexerWithFlushInterval inits a TestAgentDemultiplexer with the given flush interval.
func initTestAgentDemultiplexerWithFlushInterval(log log.Component, hostname hostname.Component, compressor compression.Component, flushInterval time.Duration) *TestAgentDemultiplexer {
func initTestAgentDemultiplexerWithFlushInterval(log log.Component, hostname hostname.Component, compressor compression.Component, compressionFactory compression.Factory, flushInterval time.Duration) *TestAgentDemultiplexer {
opts := aggregator.DefaultAgentDemultiplexerOptions()
opts.FlushInterval = flushInterval
opts.DontStartForwarders = true
Expand All @@ -183,7 +183,7 @@ func initTestAgentDemultiplexerWithFlushInterval(log log.Component, hostname hos
sharedForwarderOptions := defaultforwarder.NewOptions(pkgconfigsetup.Datadog(), log, nil)
sharedForwarder := defaultforwarder.NewDefaultForwarder(pkgconfigsetup.Datadog(), log, sharedForwarderOptions)
orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{})
eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(hostname))
eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(hostname, compressionFactory))
demux := aggregator.InitAndStartAgentDemultiplexer(log, sharedForwarder, &orchestratorForwarder, opts, eventPlatformForwarder, compressor, "hostname")
return NewTestAgentDemultiplexer(demux)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
"github.com/DataDog/datadog-agent/comp/forwarder/eventplatformreceiver/eventplatformreceiverimpl"
"github.com/DataDog/datadog-agent/comp/logs/agent/config"
"github.com/DataDog/datadog-agent/comp/serializer/compression"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/config/model"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
"github.com/DataDog/datadog-agent/pkg/diagnose/diagnosis"
"github.com/DataDog/datadog-agent/pkg/logs/auditor"
"github.com/DataDog/datadog-agent/pkg/logs/client"
Expand Down
11 changes: 10 additions & 1 deletion comp/logs/agent/agentimpl/agent_serverless_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ func (a *logAgent) SetupPipeline(
destinationsCtx := client.NewDestinationsContext()

// setup the pipeline provider that provides pairs of processor and sender
pipelineProvider := pipeline.NewServerlessProvider(config.NumberOfPipelines, a.auditor, diagnosticMessageReceiver, processingRules, a.endpoints, destinationsCtx, NewStatusProvider(), a.hostname, a.config)
pipelineProvider := pipeline.NewServerlessProvider(config.NumberOfPipelines,
a.auditor,
diagnosticMessageReceiver,
processingRules,
a.endpoints,
destinationsCtx,
NewStatusProvider(),
a.hostname,
a.config,
a.compressionFactory)

lnchrs := launchers.NewLaunchers(a.sources, pipelineProvider, a.auditor, a.tracker)
lnchrs.AddLauncher(channel.NewLauncher())
Expand Down
5 changes: 0 additions & 5 deletions comp/otelcol/logsagentpipeline/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ require github.com/DataDog/datadog-agent/pkg/logs/pipeline v0.56.0-rc.3

require (
github.com/DataDog/agent-payload/v5 v5.0.106 // indirect
github.com/DataDog/datadog-agent/comp/core/config v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/core/flare/builder v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/core/flare/types v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/core/hostname/hostnameinterface v0.56.0-rc.3 // indirect
github.com/DataDog/datadog-agent/comp/core/secrets v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect
Expand All @@ -72,7 +69,6 @@ require (
github.com/DataDog/datadog-agent/comp/serializer/compression v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/config/env v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect
github.com/DataDog/datadog-agent/pkg/config/model v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/config/setup v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect
Expand Down Expand Up @@ -107,7 +103,6 @@ require (
github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect
github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect
github.com/DataDog/viper v1.13.5 // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ require (
github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect
github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect
github.com/DataDog/viper v1.13.5 // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down
1 change: 1 addition & 0 deletions comp/serializer/compression/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const ZstdEncoding = "zstd"
// GzipEncoding is the content-encoding value for Gzip
const GzipEncoding = "gzip"

// Factory is an interface to a type that can create compression strategies.
type Factory interface {
NewNoopCompressor() Component
NewCompressor(kind string, level int, option string, valid []string) Component
Expand Down
7 changes: 6 additions & 1 deletion comp/serializer/compression/compressionimpl/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ func Module() fxutil.Module {
)
}

// CompressorFactory is used to create a Compression strategy.
type CompressorFactory struct{}

// NewCompressorFactory creates a new compression factory.
func NewCompressorFactory() compression.Factory {
return &CompressorFactory{}
}

// FromConfig is used to create a compressor based on fields defined
// in the given configuration.
func FromConfig(cfg config.Component) compression.Component {
return NewCompressorFactory().NewCompressor(
cfg.GetString("serializer_compressor_kind"),
Expand All @@ -31,6 +35,7 @@ func FromConfig(cfg config.Component) compression.Component {
)
}

func (_ *CompressorFactory) NewNoopCompressor() compression.Component {
// NewNoopCompressor creates a noop compressor that performs no compression.
func (*CompressorFactory) NewNoopCompressor() compression.Component {
return strategy.NewNoopStrategy()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ import (

// NewCompressor returns a new Compressor based on serializer_compressor_kind
// This function is called only when the zlib build tag is included
func (_ *CompressorFactory) NewCompressor(_kind string, _level int, _option string, _valid []string) compression.Component {
func (*CompressorFactory) NewCompressor(_kind string, _level int, _option string, _valid []string) compression.Component {
return strategy.NewNoopStrategy()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/DataDog/datadog-agent/comp/serializer/compression"
)

// GzipStrategy is the strategy for when serializer_compression_kind is gzip
type GzipStrategy struct {
level int
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

// NewCompressor returns a new Compressor based on serializer_compressor_kind
// This function is called when both zlib and zstd build tags are included
func (_ *CompressorFactory) NewCompressor(kind string, level int, option string, valid []string) compression.Component {
func (*CompressorFactory) NewCompressor(kind string, level int, option string, valid []string) compression.Component {
if !slices.Contains(valid, kind) {
log.Warn("invalid " + option + " set. use one of " + strings.Join(valid, ", "))
return strategy.NewNoopStrategy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

// NewCompressor returns a new Compressor based on serializer_compressor_kind
// This function is called only when the zlib build tag is included
func (_ *CompressorFactory) NewCompressor(kind string, level int, option string, valid string[]) compression.Component {
func (*CompressorFactory) NewCompressor(kind string, level int, option string, valid string[]) compression.Component {
if !slices.Contains(valid, kind) {
log.Warn("invalid " + option + " set. use one of " + strings.Join(valid, ", "))
return strategy.NewNoopStrategy()
Expand Down
5 changes: 2 additions & 3 deletions pkg/aggregator/check_sampler_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/DataDog/datadog-agent/comp/core"
"github.com/DataDog/datadog-agent/comp/core/hostname"
log "github.com/DataDog/datadog-agent/comp/core/log/def"
"github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder"
"github.com/DataDog/datadog-agent/comp/forwarder/eventplatform"
"github.com/DataDog/datadog-agent/comp/forwarder/eventplatform/eventplatformimpl"
"github.com/DataDog/datadog-agent/comp/serializer/compression"
Expand Down Expand Up @@ -49,11 +48,11 @@ func benchmarkAddBucket(bucketValue int64, b *testing.B) {
options := DefaultAgentDemultiplexerOptions()
options.DontStartForwarders = true
sharedForwarder := forwarder.NewDefaultForwarder(pkgconfigsetup.Datadog(), deps.Log, forwarderOpts)
orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{})
orchestratorForwarder := optional.NewOption[forwarder.Forwarder](forwarder.NoopForwarder{})
eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(deps.Hostname, deps.CompressionFactory))

// TODO Do we do this for the benchmarks?
compressor := deps.CompressorFactory.NewCompressor(
compressor := deps.CompressionFactory.NewCompressor(
deps.Config.GetString("serializer_compressor_kind"),
deps.Config.GetInt("serializer_zstd_compressor_level"),
"serializer_compressor_kind",
Expand Down
11 changes: 2 additions & 9 deletions pkg/aggregator/demultiplexer_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type TestDeps struct {
Hostname hostname.Component
SharedForwarder defaultforwarder.Component
CompressionFactory compression.Factory
Compressor compression.Component
Config config.Component
}

Expand All @@ -35,13 +36,5 @@ func InitAndStartAgentDemultiplexerForTest(deps TestDeps, options AgentDemultipl
orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{})
eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(deps.Hostname, deps.CompressionFactory))

// TODO Could this be the MockCompressor?
compressor := deps.CompressionFactory.NewCompressor(
deps.Config.GetString("serializer_compressor_kind"),
deps.Config.GetInt("serializer_zstd_compressor_level"),
"serializer_compressor_kind",
[]string{"zstd", "zlib"},
)

return InitAndStartAgentDemultiplexer(deps.Log, deps.SharedForwarder, &orchestratorForwarder, options, eventPlatformForwarder, compressor, hostname)
return InitAndStartAgentDemultiplexer(deps.Log, deps.SharedForwarder, &orchestratorForwarder, options, eventPlatformForwarder, deps.Compressor, hostname)
}
11 changes: 10 additions & 1 deletion pkg/aggregator/demultiplexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,16 @@ func TestDemuxFlushAggregatorToSerializer(t *testing.T) {
opts := demuxTestOptions()
opts.FlushInterval = time.Hour
deps := createDemuxDeps(t, opts, eventplatformimpl.NewDefaultParams())
demux := initAgentDemultiplexer(deps.Log, deps.SharedForwarder, deps.OrchestratorFwd, opts, deps.EventPlatformFwd, deps.Compressor, "")

// TODO Could this be the MockCompressor?
compressor := deps.CompressionFactory.NewCompressor(
deps.Config.GetString("serializer_compressor_kind"),
deps.Config.GetInt("serializer_zstd_compressor_level"),
"serializer_compressor_kind",
[]string{"zstd", "zlib"},
)

demux := initAgentDemultiplexer(deps.Log, deps.SharedForwarder, deps.OrchestratorFwd, opts, deps.EventPlatformFwd, compressor, "")
demux.Aggregator().tlmContainerTagsEnabled = false
require.NotNil(demux)
require.NotNil(demux.aggregator)
Expand Down
2 changes: 1 addition & 1 deletion pkg/aggregator/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func testDemux(log log.Component, hostname hostname.Component) *AgentDemultiplex
opts := DefaultAgentDemultiplexerOptions()
opts.DontStartForwarders = true
orchestratorForwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{})
eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(hostname))
eventPlatformForwarder := optional.NewOptionPtr[eventplatform.Forwarder](eventplatformimpl.NewNoopEventPlatformForwarder(hostname, compressionimpl.NewCompressorFactory()))
demux := initAgentDemultiplexer(log, NewForwarderTest(log), &orchestratorForwarder, opts, eventPlatformForwarder, compressionimpl.NewMockCompressor(), defaultHostname)
return demux
}
Expand Down
1 change: 0 additions & 1 deletion pkg/cli/subcommands/dcaflare/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/DataDog/datadog-agent/comp/core/flare/helpers"
log "github.com/DataDog/datadog-agent/comp/core/log/def"
"github.com/DataDog/datadog-agent/comp/core/secrets"
"github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl"
"github.com/DataDog/datadog-agent/pkg/api/util"
"github.com/DataDog/datadog-agent/pkg/config/settings"
settingshttp "github.com/DataDog/datadog-agent/pkg/config/settings/http"
Expand Down
3 changes: 2 additions & 1 deletion pkg/compliance/status_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import (
"github.com/stretchr/testify/assert"

"github.com/DataDog/datadog-agent/comp/logs/agent/config"
"github.com/DataDog/datadog-agent/comp/serializer/compression/compressionimpl"
"github.com/DataDog/datadog-agent/pkg/logs/client"
)

func TestStatus(t *testing.T) {
provider := statusProvider{
agent: &Agent{
opts: AgentOptions{
Reporter: NewLogReporter("test", "test", "test", &config.Endpoints{}, &client.DestinationsContext{}),
Reporter: NewLogReporter("test", "test", "test", &config.Endpoints{}, &client.DestinationsContext{}, compressionimpl.NewCompressorFactory()),
},
},
}
Expand Down
5 changes: 0 additions & 5 deletions pkg/logs/pipeline/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,11 @@ require (

require (
github.com/DataDog/agent-payload/v5 v5.0.106 // indirect
github.com/DataDog/datadog-agent/comp/core/config v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/core/flare/builder v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/core/flare/types v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/core/secrets v0.56.2 // indirect
github.com/DataDog/datadog-agent/comp/core/telemetry v0.56.0-rc.3 // indirect
github.com/DataDog/datadog-agent/comp/def v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/config/env v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/config/mock v0.58.0-devel // indirect
github.com/DataDog/datadog-agent/pkg/config/setup v0.56.2 // indirect
github.com/DataDog/datadog-agent/pkg/config/utils v0.56.0-rc.3 // indirect
github.com/DataDog/datadog-agent/pkg/logs/metrics v0.56.0-rc.3 // indirect
Expand All @@ -108,7 +104,6 @@ require (
github.com/DataDog/datadog-agent/pkg/version v0.56.0-rc.3 // indirect
github.com/DataDog/dd-sensitive-data-scanner/sds-go/go v0.0.0-20240816154533-f7f9beb53a42 // indirect
github.com/DataDog/viper v1.13.5 // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions pkg/logs/pipeline/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/logs/sender/batch_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (

"github.com/benbjohnson/clock"

"github.com/DataDog/datadog-agent/comp/serializer/compression"
"github.com/DataDog/datadog-agent/pkg/logs/message"
"github.com/DataDog/datadog-agent/pkg/telemetry"
"github.com/DataDog/datadog-agent/pkg/util/log"
"github.com/DataDog/datadog-agent/comp/serializer/compression"
)

var (
Expand Down
Loading

0 comments on commit de2dc05

Please sign in to comment.