-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ASCII-931][component] Create orchestrator forwarder component (#21058)
* Move NewOrchestratorForwarder into a new component * Reduce the number of calls to `InitAndStartAgentDemultiplexerForTest` Goal: Make next commit easier Note: DemultiplexerMock cannot be used in pkg/aggregator because comp/aggregator depends on pkg/aggregator * Use orchestrator forwarder component. * Make orchestrator component optional * Fix TestDemuxForwardersCreated * Update CODEOWNERS (aggregator is owned by agent-metrics-logs) * Fix linters * Move the component to comp/forwarder/orchestrator * Fix lint-components * Fix Windows compilation issue * Disable Orchestrator Forwarder for open telemetry * Update .github/CODEOWNERS Co-authored-by: Pierre Margueritte <[email protected]> * Remove empty lines * Improve comment for Component.Reset * Use constructor for Params * Fix windows linter * Improve comments * Fix code owner --------- Co-authored-by: Pierre Margueritte <[email protected]>
- Loading branch information
Showing
34 changed files
with
398 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2023-present Datadog, Inc. | ||
|
||
// Package orchestrator implements the orchestrator forwarder component. | ||
package orchestrator | ||
|
||
import "github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" | ||
|
||
// team: agent-metrics-logs | ||
|
||
// Component is the component type. | ||
// The main method of this component is `Get` which returns the forwarder instance only if it enabled. | ||
type Component interface { | ||
// Get the forwarder instance if it exists. | ||
Get() (defaultforwarder.Forwarder, bool) | ||
|
||
// TODO: (components): This function is used to know if Stop was already called in AgentDemultiplexer.Stop. | ||
// Reset results `Get` methods to return false. | ||
// Remove it when Stop is not part of this interface. | ||
Reset() | ||
} |
37 changes: 37 additions & 0 deletions
37
comp/forwarder/orchestrator/orchestratorimpl/forwarder_no_orchestrator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2023-present Datadog, Inc. | ||
|
||
//go:build !orchestrator | ||
|
||
// Package orchestratorimpl implements the orchestrator forwarder component. | ||
package orchestratorimpl | ||
|
||
import ( | ||
"go.uber.org/fx" | ||
|
||
"github.com/DataDog/datadog-agent/comp/core/config" | ||
"github.com/DataDog/datadog-agent/comp/core/log" | ||
"github.com/DataDog/datadog-agent/comp/forwarder/defaultforwarder" | ||
"github.com/DataDog/datadog-agent/comp/forwarder/orchestrator" | ||
"github.com/DataDog/datadog-agent/pkg/util/fxutil" | ||
"github.com/DataDog/datadog-agent/pkg/util/optional" | ||
) | ||
|
||
// Module defines the fx options for this component. | ||
var Module = fxutil.Component( | ||
fx.Provide(newOrchestratorForwarder), | ||
) | ||
|
||
// newOrchestratorForwarder builds the orchestrator forwarder. | ||
// This func has been extracted in this file to not include all the orchestrator | ||
// dependencies (k8s, several MBs) while building binaries not needing these. | ||
func newOrchestratorForwarder(_ log.Component, _ config.Component, params Params) orchestrator.Component { | ||
if params.useNoopOrchestratorForwarder { | ||
forwarder := optional.NewOption[defaultforwarder.Forwarder](defaultforwarder.NoopForwarder{}) | ||
return &forwarder | ||
} | ||
forwarder := optional.NewNoneOption[defaultforwarder.Forwarder]() | ||
return &forwarder | ||
} |
Oops, something went wrong.