@@ -206,10 +206,6 @@ type VarsManager interface {
206206 Watch () <- chan []* transpiler.Vars
207207}
208208
209- // ComponentsModifier is a function that takes the computed components model and modifies it before
210- // passing it into the components runtime manager.
211- type ComponentsModifier func (comps []component.Component , cfg map [string ]interface {}) ([]component.Component , error )
212-
213209// managerShutdownTimeout is how long the coordinator will wait during shutdown
214210// to receive termination states from its managers.
215211// Note: The current timeout (5s) is shorter than the default stop timeout for
@@ -249,7 +245,7 @@ type Coordinator struct {
249245 otelCfg * confmap.Conf
250246
251247 caps capabilities.Capabilities
252- modifiers []ComponentsModifier
248+ modifiers []component. ComponentsModifier
253249
254250 // The current state of the Coordinator. This value and its subfields are
255251 // safe to read directly from within the main Coordinator goroutine.
@@ -419,7 +415,7 @@ func New(
419415 otelMgr OTelManager ,
420416 fleetAcker acker.Acker ,
421417 initialUpgradeDetails * details.Details ,
422- modifiers ... ComponentsModifier ,
418+ modifiers ... component. ComponentsModifier ,
423419) * Coordinator {
424420 var fleetState cproto.State
425421 var fleetMessage string
@@ -1656,17 +1652,10 @@ func (c *Coordinator) updateManagersWithConfig(model *component.Model) {
16561652func (c * Coordinator ) splitModelBetweenManagers (model * component.Model ) (runtimeModel * component.Model , otelModel * component.Model ) {
16571653 var otelComponents , runtimeComponents []component.Component
16581654 for _ , comp := range model .Components {
1659- c .maybeOverrideRuntimeForComponent (& comp )
16601655 switch comp .RuntimeManager {
16611656 case component .OtelRuntimeManager :
16621657 otelComponents = append (otelComponents , comp )
16631658 case component .ProcessRuntimeManager :
1664- // Hack to fix https://github.com/elastic/elastic-agent/issues/11169
1665- // TODO: Remove this after https://github.com/elastic/elastic-agent/issues/10220 is resolved
1666- if comp .ID == "prometheus/metrics-monitoring" {
1667- c .logger .Warnf ("The Otel prometheus metrics monitoring input can't run in a beats process, skipping" )
1668- continue
1669- }
16701659 runtimeComponents = append (runtimeComponents , comp )
16711660 default :
16721661 // this should be impossible if we parse the configuration correctly
@@ -1688,7 +1677,7 @@ func (c *Coordinator) splitModelBetweenManagers(model *component.Model) (runtime
16881677// Normally, we use the runtime set in the component itself via the configuration, but
16891678// we may also fall back to the process runtime if the otel runtime is unsupported for
16901679// some reason. One example is the output using unsupported config options.
1691- func ( c * Coordinator ) maybeOverrideRuntimeForComponent ( comp * component.Component ) {
1680+ func maybeOverrideRuntimeForComponent ( logger * logger. Logger , comp * component.Component ) {
16921681 if comp .RuntimeManager == component .ProcessRuntimeManager {
16931682 // do nothing, the process runtime can handle any component
16941683 return
@@ -1697,7 +1686,7 @@ func (c *Coordinator) maybeOverrideRuntimeForComponent(comp *component.Component
16971686 // check if the component is actually supported
16981687 err := translate .VerifyComponentIsOtelSupported (comp )
16991688 if err != nil {
1700- c . logger .Warnf ("otel runtime is not supported for component %s, switching to process runtime, reason: %v" , comp .ID , err )
1689+ logger .Warnf ("otel runtime is not supported for component %s, switching to process runtime, reason: %v" , comp .ID , err )
17011690 comp .RuntimeManager = component .ProcessRuntimeManager
17021691 }
17031692 }
@@ -1756,8 +1745,15 @@ func (c *Coordinator) generateComponentModel() (err error) {
17561745 existingCompState [comp .Component .ID ] = comp .State .Pid
17571746 }
17581747
1748+ otelRuntimeModifier := func (comps []component.Component , cfg map [string ]interface {}) ([]component.Component , error ) {
1749+ for i := range comps {
1750+ maybeOverrideRuntimeForComponent (c .logger , & comps [i ])
1751+ }
1752+ return comps , nil
1753+ }
17591754 comps , err := c .specs .ToComponents (
17601755 cfg ,
1756+ append (c .modifiers , otelRuntimeModifier ),
17611757 configInjector ,
17621758 c .state .LogLevel ,
17631759 c .agentInfo ,
@@ -1770,13 +1766,6 @@ func (c *Coordinator) generateComponentModel() (err error) {
17701766 // Filter any disallowed inputs/outputs from the components
17711767 comps = c .filterByCapabilities (comps )
17721768
1773- for _ , modifier := range c .modifiers {
1774- comps , err = modifier (comps , cfg )
1775- if err != nil {
1776- return fmt .Errorf ("failed to modify components: %w" , err )
1777- }
1778- }
1779-
17801769 // If we made it this far, update our internal derived values and
17811770 // return with no error
17821771 c .derivedConfig = cfg
0 commit comments