From 9ca95e2e0e938f8d5838ea1ad6daafd6d7536c6c Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Fri, 24 Nov 2023 08:10:59 -0500 Subject: [PATCH] Remove NeedsServices from components (#5780) * service/cluster: stop using dependant components Update the cluster service to stop looking at dependant components when notifying clustered components of a cluster update. Related to #5777, as components will no longer be able to declare a dependancy on a service. * service: add soft requirement that data must not rely on runtime config Change the doc comment of service.Data to note that the returned data must not rely on runtime config. Related to #5777, as components will no longer directly depend on services. If service.Data relied on the runtime config, it would open the door for hidden circular dependencies. * flow: remove dependency from components to services This commit fully removes the dependency from components to services, leaving the NeedsServices field in component.Registration ignored. Related to #5777. * component: remove NeedsServices field Remove the unused NeedsServices field. Related to #5777. * misc: update CHANGELOG and docs for #5777 Update the CHANGELOG and docs to reflect the dropped requirement that components must depend on consumed services. Closes #5777. --- CHANGELOG.md | 7 + .../loki/source/kubernetes/kubernetes.go | 5 +- component/loki/source/podlogs/podlogs.go | 5 +- component/module/file/file.go | 11 +- component/module/git/git.go | 11 +- component/module/http/http.go | 11 +- component/module/string/string.go | 11 +- component/otelcol/auth/basic/basic.go | 8 +- component/otelcol/auth/bearer/bearer.go | 8 +- component/otelcol/auth/headers/headers.go | 8 +- component/otelcol/auth/oauth2/oauth2.go | 8 +- component/otelcol/auth/sigv4/sigv4.go | 8 +- .../connector/servicegraph/servicegraph.go | 8 +- .../connector/spanmetrics/spanmetrics.go | 8 +- .../exporter/loadbalancing/loadbalancing.go | 8 +- component/otelcol/exporter/logging/logging.go | 8 +- component/otelcol/exporter/otlp/otlp.go | 8 +- .../otelcol/exporter/otlphttp/otlphttp.go | 8 +- .../otelcol/exporter/prometheus/prometheus.go | 8 +- .../processor/attributes/attributes.go | 8 +- component/otelcol/processor/batch/batch.go | 8 +- component/otelcol/processor/filter/filter.go | 8 +- .../processor/memorylimiter/memorylimiter.go | 8 +- .../probabilistic_sampler.go | 8 +- component/otelcol/processor/span/span.go | 8 +- .../processor/tail_sampling/tail_sampling.go | 8 +- .../otelcol/processor/transform/transform.go | 8 +- component/otelcol/receiver/jaeger/jaeger.go | 6 +- component/otelcol/receiver/kafka/kafka.go | 6 +- .../otelcol/receiver/opencensus/opencensus.go | 6 +- component/otelcol/receiver/otlp/otlp.go | 6 +- .../otelcol/receiver/prometheus/prometheus.go | 8 +- component/otelcol/receiver/vcenter/vcenter.go | 6 +- component/otelcol/receiver/zipkin/zipkin.go | 6 +- component/prometheus/exporter/agent/agent.go | 10 +- .../prometheus/exporter/apache/apache.go | 10 +- component/prometheus/exporter/azure/azure.go | 10 +- .../prometheus/exporter/blackbox/blackbox.go | 10 +- .../prometheus/exporter/cadvisor/cadvisor.go | 10 +- .../exporter/cloudwatch/cloudwatch.go | 10 +- .../prometheus/exporter/consul/consul.go | 10 +- .../prometheus/exporter/dnsmasq/dnsmasq.go | 10 +- .../exporter/elasticsearch/elasticsearch.go | 10 +- component/prometheus/exporter/gcp/gcp.go | 10 +- .../prometheus/exporter/github/github.go | 10 +- component/prometheus/exporter/kafka/kafka.go | 10 +- .../exporter/memcached/memcached.go | 10 +- .../prometheus/exporter/mongodb/mongodb.go | 10 +- component/prometheus/exporter/mssql/mssql.go | 10 +- component/prometheus/exporter/mysql/mysql.go | 10 +- .../prometheus/exporter/oracledb/oracledb.go | 10 +- .../prometheus/exporter/postgres/postgres.go | 10 +- .../prometheus/exporter/process/process.go | 10 +- component/prometheus/exporter/redis/redis.go | 10 +- component/prometheus/exporter/services.go | 20 --- component/prometheus/exporter/snmp/snmp.go | 10 +- .../exporter/snowflake/snowflake.go | 10 +- component/prometheus/exporter/squid/squid.go | 10 +- .../prometheus/exporter/statsd/statsd.go | 10 +- component/prometheus/exporter/unix/unix.go | 10 +- .../prometheus/exporter/vsphere/vsphere.go | 10 +- .../prometheus/exporter/windows/windows.go | 10 +- .../operator/podmonitors/operator.go | 8 +- .../prometheus/operator/probes/probes.go | 8 +- .../servicemonitors/servicemonitors.go | 8 +- .../prometheus/receive_http/receive_http.go | 6 +- component/prometheus/relabel/relabel.go | 8 +- .../prometheus/remotewrite/remote_write.go | 8 +- component/prometheus/scrape/scrape.go | 6 +- component/pyroscope/scrape/scrape.go | 5 +- component/registry.go | 12 +- .../flow/reference/config-blocks/http.md | 11 +- pkg/flow/flow.go | 4 +- pkg/flow/flow_services.go | 9 -- pkg/flow/flow_services_test.go | 129 +++--------------- pkg/flow/internal/controller/loader.go | 16 --- pkg/flow/internal/controller/loader_test.go | 4 +- .../internal/controller/node_component.go | 28 ++-- .../controller/node_component_test.go | 4 +- service/cluster/cluster.go | 9 +- service/service.go | 18 +-- 81 files changed, 307 insertions(+), 549 deletions(-) delete mode 100644 component/prometheus/exporter/services.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b21fbe8fa33..1016e6d77409 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,10 @@ Main (unreleased) - Added metrics, alerts and dashboard visualisations to help diagnose issues with unhealthy components and components that take too long to evaluate. (@thampiotr) +- The `http` config block may now reference exports from any component. + Previously, only `remote.*` and `local.*` components could be referenced + without a circular dependency. (@rfratto) + ### Bugfixes - Permit `X-Faro-Session-ID` header in CORS requests for the `faro.receiver` @@ -218,6 +222,9 @@ v0.37.4 (2023-11-06) - Fix a bug where reloading the configuration of a `loki.write` component lead to a panic. (@tpaschalis) +- Added Kubernetes service resolver to static node's loadbalancing exporter + and to Flow's `otelcol.exporter.loadbalancing`. (@ptodev) + v0.37.3 (2023-10-26) ----------------- diff --git a/component/loki/source/kubernetes/kubernetes.go b/component/loki/source/kubernetes/kubernetes.go index ce11017c6f87..80792520e9c3 100644 --- a/component/loki/source/kubernetes/kubernetes.go +++ b/component/loki/source/kubernetes/kubernetes.go @@ -24,9 +24,8 @@ import ( func init() { component.Register(component.Registration{ - Name: "loki.source.kubernetes", - Args: Arguments{}, - NeedsServices: []string{cluster.ServiceName}, + Name: "loki.source.kubernetes", + Args: Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) diff --git a/component/loki/source/podlogs/podlogs.go b/component/loki/source/podlogs/podlogs.go index 8fa4b48b96c0..f7a194e4b79a 100644 --- a/component/loki/source/podlogs/podlogs.go +++ b/component/loki/source/podlogs/podlogs.go @@ -26,9 +26,8 @@ import ( func init() { component.Register(component.Registration{ - Name: "loki.source.podlogs", - Args: Arguments{}, - NeedsServices: []string{cluster.ServiceName}, + Name: "loki.source.podlogs", + Args: Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) diff --git a/component/module/file/file.go b/component/module/file/file.go index 68b20760d5f4..e40c5dc9ca48 100644 --- a/component/module/file/file.go +++ b/component/module/file/file.go @@ -9,19 +9,14 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/local/file" "github.com/grafana/agent/component/module" - "github.com/grafana/agent/service/cluster" - "github.com/grafana/agent/service/http" - "github.com/grafana/agent/service/labelstore" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river/rivertypes" ) func init() { component.Register(component.Registration{ - Name: "module.file", - Args: Arguments{}, - Exports: module.Exports{}, - NeedsServices: []string{http.ServiceName, cluster.ServiceName, otel_service.ServiceName, labelstore.ServiceName}, + Name: "module.file", + Args: Arguments{}, + Exports: module.Exports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) diff --git a/component/module/git/git.go b/component/module/git/git.go index 6a211fdc8843..dfe17ef2cb4a 100644 --- a/component/module/git/git.go +++ b/component/module/git/git.go @@ -14,18 +14,13 @@ import ( "github.com/grafana/agent/component/module" "github.com/grafana/agent/component/module/git/internal/vcs" "github.com/grafana/agent/pkg/flow/logging/level" - "github.com/grafana/agent/service/cluster" - "github.com/grafana/agent/service/http" - "github.com/grafana/agent/service/labelstore" - otel_service "github.com/grafana/agent/service/otel" ) func init() { component.Register(component.Registration{ - Name: "module.git", - Args: Arguments{}, - Exports: module.Exports{}, - NeedsServices: []string{http.ServiceName, cluster.ServiceName, otel_service.ServiceName, labelstore.ServiceName}, + Name: "module.git", + Args: Arguments{}, + Exports: module.Exports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) diff --git a/component/module/http/http.go b/component/module/http/http.go index a2d48f6f53b8..bc1be2158fdb 100644 --- a/component/module/http/http.go +++ b/component/module/http/http.go @@ -9,19 +9,14 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/module" remote_http "github.com/grafana/agent/component/remote/http" - "github.com/grafana/agent/service/cluster" - http_service "github.com/grafana/agent/service/http" - "github.com/grafana/agent/service/labelstore" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river/rivertypes" ) func init() { component.Register(component.Registration{ - Name: "module.http", - Args: Arguments{}, - Exports: module.Exports{}, - NeedsServices: []string{http_service.ServiceName, cluster.ServiceName, otel_service.ServiceName, labelstore.ServiceName}, + Name: "module.http", + Args: Arguments{}, + Exports: module.Exports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) diff --git a/component/module/string/string.go b/component/module/string/string.go index 7305abd75073..bd3e6193f441 100644 --- a/component/module/string/string.go +++ b/component/module/string/string.go @@ -5,19 +5,14 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/module" - "github.com/grafana/agent/service/cluster" - "github.com/grafana/agent/service/http" - "github.com/grafana/agent/service/labelstore" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river/rivertypes" ) func init() { component.Register(component.Registration{ - Name: "module.string", - Args: Arguments{}, - Exports: module.Exports{}, - NeedsServices: []string{http.ServiceName, cluster.ServiceName, otel_service.ServiceName, labelstore.ServiceName}, + Name: "module.string", + Args: Arguments{}, + Exports: module.Exports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) diff --git a/component/otelcol/auth/basic/basic.go b/component/otelcol/auth/basic/basic.go index b82209e388a3..ceae037d7f40 100644 --- a/component/otelcol/auth/basic/basic.go +++ b/component/otelcol/auth/basic/basic.go @@ -4,7 +4,6 @@ package basic import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol/auth" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river/rivertypes" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension" otelcomponent "go.opentelemetry.io/collector/component" @@ -14,10 +13,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.auth.basic", - Args: Arguments{}, - Exports: auth.Exports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.auth.basic", + Args: Arguments{}, + Exports: auth.Exports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := basicauthextension.NewFactory() diff --git a/component/otelcol/auth/bearer/bearer.go b/component/otelcol/auth/bearer/bearer.go index bfcb40e6b55d..d99ea1b7cee9 100644 --- a/component/otelcol/auth/bearer/bearer.go +++ b/component/otelcol/auth/bearer/bearer.go @@ -4,7 +4,6 @@ package bearer import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol/auth" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river/rivertypes" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension" otelcomponent "go.opentelemetry.io/collector/component" @@ -14,10 +13,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.auth.bearer", - Args: Arguments{}, - Exports: auth.Exports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.auth.bearer", + Args: Arguments{}, + Exports: auth.Exports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := bearertokenauthextension.NewFactory() diff --git a/component/otelcol/auth/headers/headers.go b/component/otelcol/auth/headers/headers.go index 56156759cac4..b0530639b8b4 100644 --- a/component/otelcol/auth/headers/headers.go +++ b/component/otelcol/auth/headers/headers.go @@ -8,7 +8,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol/auth" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river" "github.com/grafana/river/rivertypes" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/headerssetterextension" @@ -18,10 +17,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.auth.headers", - Args: Arguments{}, - Exports: auth.Exports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.auth.headers", + Args: Arguments{}, + Exports: auth.Exports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := headerssetterextension.NewFactory() diff --git a/component/otelcol/auth/oauth2/oauth2.go b/component/otelcol/auth/oauth2/oauth2.go index 3396dca94d06..6007bd59236a 100644 --- a/component/otelcol/auth/oauth2/oauth2.go +++ b/component/otelcol/auth/oauth2/oauth2.go @@ -7,7 +7,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/auth" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river/rivertypes" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/oauth2clientauthextension" otelcomponent "go.opentelemetry.io/collector/component" @@ -17,10 +16,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.auth.oauth2", - Args: Arguments{}, - Exports: auth.Exports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.auth.oauth2", + Args: Arguments{}, + Exports: auth.Exports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := oauth2clientauthextension.NewFactory() diff --git a/component/otelcol/auth/sigv4/sigv4.go b/component/otelcol/auth/sigv4/sigv4.go index 81336757fb6b..0a3db55c546b 100644 --- a/component/otelcol/auth/sigv4/sigv4.go +++ b/component/otelcol/auth/sigv4/sigv4.go @@ -3,7 +3,6 @@ package sigv4 import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol/auth" - otel_service "github.com/grafana/agent/service/otel" "github.com/open-telemetry/opentelemetry-collector-contrib/extension/sigv4authextension" otelcomponent "go.opentelemetry.io/collector/component" otelextension "go.opentelemetry.io/collector/extension" @@ -11,10 +10,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.auth.sigv4", - Args: Arguments{}, - Exports: auth.Exports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.auth.sigv4", + Args: Arguments{}, + Exports: auth.Exports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := sigv4authextension.NewFactory() diff --git a/component/otelcol/connector/servicegraph/servicegraph.go b/component/otelcol/connector/servicegraph/servicegraph.go index ce171700569f..e5370d89f620 100644 --- a/component/otelcol/connector/servicegraph/servicegraph.go +++ b/component/otelcol/connector/servicegraph/servicegraph.go @@ -7,7 +7,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/connector" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river" "github.com/open-telemetry/opentelemetry-collector-contrib/connector/servicegraphconnector" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/servicegraphprocessor" @@ -17,10 +16,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.connector.servicegraph", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.connector.servicegraph", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := servicegraphconnector.NewFactory() diff --git a/component/otelcol/connector/spanmetrics/spanmetrics.go b/component/otelcol/connector/spanmetrics/spanmetrics.go index 45b8b1f4bd0a..2a32c9b49642 100644 --- a/component/otelcol/connector/spanmetrics/spanmetrics.go +++ b/component/otelcol/connector/spanmetrics/spanmetrics.go @@ -8,7 +8,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/connector" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river" "github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector" otelcomponent "go.opentelemetry.io/collector/component" @@ -17,10 +16,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.connector.spanmetrics", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.connector.spanmetrics", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := spanmetricsconnector.NewFactory() diff --git a/component/otelcol/exporter/loadbalancing/loadbalancing.go b/component/otelcol/exporter/loadbalancing/loadbalancing.go index 35a42df3a328..3455318fef38 100644 --- a/component/otelcol/exporter/loadbalancing/loadbalancing.go +++ b/component/otelcol/exporter/loadbalancing/loadbalancing.go @@ -10,7 +10,6 @@ import ( "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/auth" "github.com/grafana/agent/component/otelcol/exporter" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/loadbalancingexporter" otelcomponent "go.opentelemetry.io/collector/component" @@ -24,10 +23,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.exporter.loadbalancing", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.exporter.loadbalancing", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := loadbalancingexporter.NewFactory() diff --git a/component/otelcol/exporter/logging/logging.go b/component/otelcol/exporter/logging/logging.go index c4dc735c4fca..13d12fbf312e 100644 --- a/component/otelcol/exporter/logging/logging.go +++ b/component/otelcol/exporter/logging/logging.go @@ -5,7 +5,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/exporter" - otel_service "github.com/grafana/agent/service/otel" otelcomponent "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/configtelemetry" loggingexporter "go.opentelemetry.io/collector/exporter/loggingexporter" @@ -14,10 +13,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.exporter.logging", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.exporter.logging", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := loggingexporter.NewFactory() diff --git a/component/otelcol/exporter/otlp/otlp.go b/component/otelcol/exporter/otlp/otlp.go index c58d434d992a..7ca10d2c2c0b 100644 --- a/component/otelcol/exporter/otlp/otlp.go +++ b/component/otelcol/exporter/otlp/otlp.go @@ -7,7 +7,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/exporter" - otel_service "github.com/grafana/agent/service/otel" otelcomponent "go.opentelemetry.io/collector/component" otelpexporterhelper "go.opentelemetry.io/collector/exporter/exporterhelper" "go.opentelemetry.io/collector/exporter/otlpexporter" @@ -16,10 +15,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.exporter.otlp", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.exporter.otlp", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := otlpexporter.NewFactory() diff --git a/component/otelcol/exporter/otlphttp/otlphttp.go b/component/otelcol/exporter/otlphttp/otlphttp.go index d70d0f7f8e98..0508ec2e6289 100644 --- a/component/otelcol/exporter/otlphttp/otlphttp.go +++ b/component/otelcol/exporter/otlphttp/otlphttp.go @@ -8,7 +8,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/exporter" - otel_service "github.com/grafana/agent/service/otel" otelcomponent "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/exporter/otlphttpexporter" otelextension "go.opentelemetry.io/collector/extension" @@ -16,10 +15,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.exporter.otlphttp", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.exporter.otlphttp", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := otlphttpexporter.NewFactory() diff --git a/component/otelcol/exporter/prometheus/prometheus.go b/component/otelcol/exporter/prometheus/prometheus.go index 0dd9ef49e69f..77e894dc6321 100644 --- a/component/otelcol/exporter/prometheus/prometheus.go +++ b/component/otelcol/exporter/prometheus/prometheus.go @@ -19,10 +19,10 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.exporter.prometheus", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{labelstore.ServiceName}, + Name: "otelcol.exporter.prometheus", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, + Build: func(o component.Options, a component.Arguments) (component.Component, error) { return New(o, a.(Arguments)) }, diff --git a/component/otelcol/processor/attributes/attributes.go b/component/otelcol/processor/attributes/attributes.go index c71eec8e1415..93f774e54b55 100644 --- a/component/otelcol/processor/attributes/attributes.go +++ b/component/otelcol/processor/attributes/attributes.go @@ -7,7 +7,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/processor" - otel_service "github.com/grafana/agent/service/otel" "github.com/mitchellh/mapstructure" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor" otelcomponent "go.opentelemetry.io/collector/component" @@ -16,10 +15,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.processor.attributes", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.processor.attributes", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := attributesprocessor.NewFactory() diff --git a/component/otelcol/processor/batch/batch.go b/component/otelcol/processor/batch/batch.go index 6cc54fa5f333..3c205a0e4320 100644 --- a/component/otelcol/processor/batch/batch.go +++ b/component/otelcol/processor/batch/batch.go @@ -8,7 +8,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/processor" - otel_service "github.com/grafana/agent/service/otel" otelcomponent "go.opentelemetry.io/collector/component" otelextension "go.opentelemetry.io/collector/extension" "go.opentelemetry.io/collector/processor/batchprocessor" @@ -16,10 +15,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.processor.batch", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.processor.batch", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := batchprocessor.NewFactory() diff --git a/component/otelcol/processor/filter/filter.go b/component/otelcol/processor/filter/filter.go index 864e9887688e..fe0927569558 100644 --- a/component/otelcol/processor/filter/filter.go +++ b/component/otelcol/processor/filter/filter.go @@ -4,7 +4,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/processor" - otel_service "github.com/grafana/agent/service/otel" "github.com/mitchellh/mapstructure" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor" @@ -14,10 +13,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.processor.filter", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.processor.filter", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := filterprocessor.NewFactory() diff --git a/component/otelcol/processor/memorylimiter/memorylimiter.go b/component/otelcol/processor/memorylimiter/memorylimiter.go index 0321d41cb5c4..edf3bb1016d0 100644 --- a/component/otelcol/processor/memorylimiter/memorylimiter.go +++ b/component/otelcol/processor/memorylimiter/memorylimiter.go @@ -9,7 +9,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/processor" - otel_service "github.com/grafana/agent/service/otel" otelcomponent "go.opentelemetry.io/collector/component" otelextension "go.opentelemetry.io/collector/extension" "go.opentelemetry.io/collector/processor/memorylimiterprocessor" @@ -17,10 +16,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.processor.memory_limiter", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.processor.memory_limiter", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := memorylimiterprocessor.NewFactory() diff --git a/component/otelcol/processor/probabilistic_sampler/probabilistic_sampler.go b/component/otelcol/processor/probabilistic_sampler/probabilistic_sampler.go index 72b8430de5e1..13321e6af49e 100644 --- a/component/otelcol/processor/probabilistic_sampler/probabilistic_sampler.go +++ b/component/otelcol/processor/probabilistic_sampler/probabilistic_sampler.go @@ -5,7 +5,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/processor" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor" otelcomponent "go.opentelemetry.io/collector/component" @@ -14,10 +13,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.processor.probabilistic_sampler", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.processor.probabilistic_sampler", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := probabilisticsamplerprocessor.NewFactory() diff --git a/component/otelcol/processor/span/span.go b/component/otelcol/processor/span/span.go index c62e8e108527..833a899d2c25 100644 --- a/component/otelcol/processor/span/span.go +++ b/component/otelcol/processor/span/span.go @@ -7,7 +7,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/processor" - otel_service "github.com/grafana/agent/service/otel" "github.com/mitchellh/mapstructure" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/spanprocessor" otelcomponent "go.opentelemetry.io/collector/component" @@ -17,10 +16,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.processor.span", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.processor.span", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := spanprocessor.NewFactory() diff --git a/component/otelcol/processor/tail_sampling/tail_sampling.go b/component/otelcol/processor/tail_sampling/tail_sampling.go index 0a17a49bd3da..dc2f33bb661d 100644 --- a/component/otelcol/processor/tail_sampling/tail_sampling.go +++ b/component/otelcol/processor/tail_sampling/tail_sampling.go @@ -8,7 +8,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/processor" - otel_service "github.com/grafana/agent/service/otel" tsp "github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor" otelcomponent "go.opentelemetry.io/collector/component" otelextension "go.opentelemetry.io/collector/extension" @@ -16,10 +15,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.processor.tail_sampling", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.processor.tail_sampling", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := tsp.NewFactory() diff --git a/component/otelcol/processor/transform/transform.go b/component/otelcol/processor/transform/transform.go index 85f86e5ac1ca..222e7c3289a8 100644 --- a/component/otelcol/processor/transform/transform.go +++ b/component/otelcol/processor/transform/transform.go @@ -8,7 +8,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/processor" - otel_service "github.com/grafana/agent/service/otel" "github.com/mitchellh/mapstructure" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor" @@ -18,10 +17,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.processor.transform", - Args: Arguments{}, - Exports: otelcol.ConsumerExports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.processor.transform", + Args: Arguments{}, + Exports: otelcol.ConsumerExports{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := transformprocessor.NewFactory() diff --git a/component/otelcol/receiver/jaeger/jaeger.go b/component/otelcol/receiver/jaeger/jaeger.go index 1858f7a909ba..2cebb37b9114 100644 --- a/component/otelcol/receiver/jaeger/jaeger.go +++ b/component/otelcol/receiver/jaeger/jaeger.go @@ -8,7 +8,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/receiver" - otel_service "github.com/grafana/agent/service/otel" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver" otelcomponent "go.opentelemetry.io/collector/component" otelconfiggrpc "go.opentelemetry.io/collector/config/configgrpc" @@ -18,9 +17,8 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.receiver.jaeger", - Args: Arguments{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.receiver.jaeger", + Args: Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := jaegerreceiver.NewFactory() diff --git a/component/otelcol/receiver/kafka/kafka.go b/component/otelcol/receiver/kafka/kafka.go index 2a41159b103b..2111f04c2579 100644 --- a/component/otelcol/receiver/kafka/kafka.go +++ b/component/otelcol/receiver/kafka/kafka.go @@ -7,7 +7,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/receiver" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river/rivertypes" "github.com/mitchellh/mapstructure" "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/kafkaexporter" @@ -18,9 +17,8 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.receiver.kafka", - Args: Arguments{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.receiver.kafka", + Args: Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := kafkareceiver.NewFactory() diff --git a/component/otelcol/receiver/opencensus/opencensus.go b/component/otelcol/receiver/opencensus/opencensus.go index 63df3da32118..7f4c64ee0ace 100644 --- a/component/otelcol/receiver/opencensus/opencensus.go +++ b/component/otelcol/receiver/opencensus/opencensus.go @@ -6,7 +6,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/receiver" - otel_service "github.com/grafana/agent/service/otel" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver" otelcomponent "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/extension" @@ -14,9 +13,8 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.receiver.opencensus", - Args: Arguments{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.receiver.opencensus", + Args: Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := opencensusreceiver.NewFactory() diff --git a/component/otelcol/receiver/otlp/otlp.go b/component/otelcol/receiver/otlp/otlp.go index 4ca6106551e3..bfdb20365ef8 100644 --- a/component/otelcol/receiver/otlp/otlp.go +++ b/component/otelcol/receiver/otlp/otlp.go @@ -9,7 +9,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/receiver" - otel_service "github.com/grafana/agent/service/otel" otelcomponent "go.opentelemetry.io/collector/component" otelextension "go.opentelemetry.io/collector/extension" "go.opentelemetry.io/collector/receiver/otlpreceiver" @@ -17,9 +16,8 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.receiver.otlp", - Args: Arguments{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.receiver.otlp", + Args: Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := otlpreceiver.NewFactory() diff --git a/component/otelcol/receiver/prometheus/prometheus.go b/component/otelcol/receiver/prometheus/prometheus.go index 7928f504287b..5a54de7337b8 100644 --- a/component/otelcol/receiver/prometheus/prometheus.go +++ b/component/otelcol/receiver/prometheus/prometheus.go @@ -15,7 +15,6 @@ import ( "github.com/grafana/agent/component/otelcol/receiver/prometheus/internal" "github.com/grafana/agent/pkg/build" "github.com/grafana/agent/pkg/util/zapadapter" - otel_service "github.com/grafana/agent/service/otel" "github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/storage" otelcomponent "go.opentelemetry.io/collector/component" @@ -26,10 +25,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.receiver.prometheus", - Args: Arguments{}, - Exports: Exports{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.receiver.prometheus", + Args: Arguments{}, + Exports: Exports{}, Build: func(o component.Options, a component.Arguments) (component.Component, error) { return New(o, a.(Arguments)) diff --git a/component/otelcol/receiver/vcenter/vcenter.go b/component/otelcol/receiver/vcenter/vcenter.go index 88efd9402940..346110da1ecd 100644 --- a/component/otelcol/receiver/vcenter/vcenter.go +++ b/component/otelcol/receiver/vcenter/vcenter.go @@ -8,7 +8,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/receiver" - otel_service "github.com/grafana/agent/service/otel" "github.com/grafana/river/rivertypes" "github.com/mitchellh/mapstructure" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver" @@ -19,9 +18,8 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.receiver.vcenter", - Args: Arguments{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.receiver.vcenter", + Args: Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := vcenterreceiver.NewFactory() diff --git a/component/otelcol/receiver/zipkin/zipkin.go b/component/otelcol/receiver/zipkin/zipkin.go index 50ac8fb23cb7..1727d38a0d05 100644 --- a/component/otelcol/receiver/zipkin/zipkin.go +++ b/component/otelcol/receiver/zipkin/zipkin.go @@ -5,7 +5,6 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/otelcol" "github.com/grafana/agent/component/otelcol/receiver" - otel_service "github.com/grafana/agent/service/otel" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver" otelcomponent "go.opentelemetry.io/collector/component" otelextension "go.opentelemetry.io/collector/extension" @@ -13,9 +12,8 @@ import ( func init() { component.Register(component.Registration{ - Name: "otelcol.receiver.zipkin", - Args: Arguments{}, - NeedsServices: []string{otel_service.ServiceName}, + Name: "otelcol.receiver.zipkin", + Args: Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { fact := zipkinreceiver.NewFactory() diff --git a/component/prometheus/exporter/agent/agent.go b/component/prometheus/exporter/agent/agent.go index 6d8064d2771b..5a02005c92b1 100644 --- a/component/prometheus/exporter/agent/agent.go +++ b/component/prometheus/exporter/agent/agent.go @@ -9,11 +9,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.agent", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "agent"), + Name: "prometheus.exporter.agent", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "agent"), }) } diff --git a/component/prometheus/exporter/apache/apache.go b/component/prometheus/exporter/apache/apache.go index 802792f545bd..4ba9d8166832 100644 --- a/component/prometheus/exporter/apache/apache.go +++ b/component/prometheus/exporter/apache/apache.go @@ -9,11 +9,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.apache", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "apache"), + Name: "prometheus.exporter.apache", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "apache"), }) } diff --git a/component/prometheus/exporter/azure/azure.go b/component/prometheus/exporter/azure/azure.go index 0b2d8483e6a9..9f454d40ce11 100644 --- a/component/prometheus/exporter/azure/azure.go +++ b/component/prometheus/exporter/azure/azure.go @@ -9,11 +9,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.azure", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "azure"), + Name: "prometheus.exporter.azure", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "azure"), }) } diff --git a/component/prometheus/exporter/blackbox/blackbox.go b/component/prometheus/exporter/blackbox/blackbox.go index 206ac1f1d12b..0388560443a8 100644 --- a/component/prometheus/exporter/blackbox/blackbox.go +++ b/component/prometheus/exporter/blackbox/blackbox.go @@ -19,11 +19,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.blackbox", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.NewWithTargetBuilder(createExporter, "blackbox", buildBlackboxTargets), + Name: "prometheus.exporter.blackbox", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.NewWithTargetBuilder(createExporter, "blackbox", buildBlackboxTargets), }) } diff --git a/component/prometheus/exporter/cadvisor/cadvisor.go b/component/prometheus/exporter/cadvisor/cadvisor.go index 14e60493930e..2e19f82cf469 100644 --- a/component/prometheus/exporter/cadvisor/cadvisor.go +++ b/component/prometheus/exporter/cadvisor/cadvisor.go @@ -11,11 +11,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.cadvisor", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "cadvisor"), + Name: "prometheus.exporter.cadvisor", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "cadvisor"), }) } diff --git a/component/prometheus/exporter/cloudwatch/cloudwatch.go b/component/prometheus/exporter/cloudwatch/cloudwatch.go index 6d8dc2b6d83c..aa957ce56562 100644 --- a/component/prometheus/exporter/cloudwatch/cloudwatch.go +++ b/component/prometheus/exporter/cloudwatch/cloudwatch.go @@ -11,11 +11,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.cloudwatch", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "cloudwatch"), + Name: "prometheus.exporter.cloudwatch", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "cloudwatch"), }) } diff --git a/component/prometheus/exporter/consul/consul.go b/component/prometheus/exporter/consul/consul.go index 862dc7042017..ce301f8ddc6b 100644 --- a/component/prometheus/exporter/consul/consul.go +++ b/component/prometheus/exporter/consul/consul.go @@ -11,11 +11,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.consul", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "consul"), + Name: "prometheus.exporter.consul", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "consul"), }) } diff --git a/component/prometheus/exporter/dnsmasq/dnsmasq.go b/component/prometheus/exporter/dnsmasq/dnsmasq.go index 5daaf17df4c0..f856fc4bd7df 100644 --- a/component/prometheus/exporter/dnsmasq/dnsmasq.go +++ b/component/prometheus/exporter/dnsmasq/dnsmasq.go @@ -9,11 +9,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.dnsmasq", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "dnsmasq"), + Name: "prometheus.exporter.dnsmasq", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "dnsmasq"), }) } diff --git a/component/prometheus/exporter/elasticsearch/elasticsearch.go b/component/prometheus/exporter/elasticsearch/elasticsearch.go index efe3a3b41897..345af3291906 100644 --- a/component/prometheus/exporter/elasticsearch/elasticsearch.go +++ b/component/prometheus/exporter/elasticsearch/elasticsearch.go @@ -12,11 +12,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.elasticsearch", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "elasticsearch"), + Name: "prometheus.exporter.elasticsearch", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "elasticsearch"), }) } diff --git a/component/prometheus/exporter/gcp/gcp.go b/component/prometheus/exporter/gcp/gcp.go index b5581b7884c4..0147b72819b3 100644 --- a/component/prometheus/exporter/gcp/gcp.go +++ b/component/prometheus/exporter/gcp/gcp.go @@ -11,11 +11,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.gcp", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "gcp"), + Name: "prometheus.exporter.gcp", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "gcp"), }) } diff --git a/component/prometheus/exporter/github/github.go b/component/prometheus/exporter/github/github.go index 354005b4e692..4d3dab5a0f2f 100644 --- a/component/prometheus/exporter/github/github.go +++ b/component/prometheus/exporter/github/github.go @@ -11,11 +11,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.github", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "github"), + Name: "prometheus.exporter.github", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "github"), }) } diff --git a/component/prometheus/exporter/kafka/kafka.go b/component/prometheus/exporter/kafka/kafka.go index 1fa01bf4d614..f146c40bae3c 100644 --- a/component/prometheus/exporter/kafka/kafka.go +++ b/component/prometheus/exporter/kafka/kafka.go @@ -50,11 +50,11 @@ type Arguments struct { func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.kafka", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.NewWithTargetBuilder(createExporter, "kafka", customizeTarget), + Name: "prometheus.exporter.kafka", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.NewWithTargetBuilder(createExporter, "kafka", customizeTarget), }) } diff --git a/component/prometheus/exporter/memcached/memcached.go b/component/prometheus/exporter/memcached/memcached.go index de5213a273a2..09d5214855fc 100644 --- a/component/prometheus/exporter/memcached/memcached.go +++ b/component/prometheus/exporter/memcached/memcached.go @@ -12,11 +12,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.memcached", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "memcached"), + Name: "prometheus.exporter.memcached", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "memcached"), }) } diff --git a/component/prometheus/exporter/mongodb/mongodb.go b/component/prometheus/exporter/mongodb/mongodb.go index 6905865285bd..0c0064c5b5c1 100644 --- a/component/prometheus/exporter/mongodb/mongodb.go +++ b/component/prometheus/exporter/mongodb/mongodb.go @@ -11,11 +11,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.mongodb", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "mongodb"), + Name: "prometheus.exporter.mongodb", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "mongodb"), }) } diff --git a/component/prometheus/exporter/mssql/mssql.go b/component/prometheus/exporter/mssql/mssql.go index 819be78a8927..3e9770fb8892 100644 --- a/component/prometheus/exporter/mssql/mssql.go +++ b/component/prometheus/exporter/mssql/mssql.go @@ -14,11 +14,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.mssql", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "mssql"), + Name: "prometheus.exporter.mssql", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "mssql"), }) } diff --git a/component/prometheus/exporter/mysql/mysql.go b/component/prometheus/exporter/mysql/mysql.go index 90201a450a36..b23f3e170394 100644 --- a/component/prometheus/exporter/mysql/mysql.go +++ b/component/prometheus/exporter/mysql/mysql.go @@ -12,11 +12,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.mysql", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "mysql"), + Name: "prometheus.exporter.mysql", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "mysql"), }) } diff --git a/component/prometheus/exporter/oracledb/oracledb.go b/component/prometheus/exporter/oracledb/oracledb.go index de3fd28ac90b..60926d445fbb 100644 --- a/component/prometheus/exporter/oracledb/oracledb.go +++ b/component/prometheus/exporter/oracledb/oracledb.go @@ -15,11 +15,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.oracledb", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "oracledb"), + Name: "prometheus.exporter.oracledb", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "oracledb"), }) } diff --git a/component/prometheus/exporter/postgres/postgres.go b/component/prometheus/exporter/postgres/postgres.go index 97f940f910bf..9a3f170c1734 100644 --- a/component/prometheus/exporter/postgres/postgres.go +++ b/component/prometheus/exporter/postgres/postgres.go @@ -15,11 +15,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.postgres", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "postgres"), + Name: "prometheus.exporter.postgres", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "postgres"), }) } diff --git a/component/prometheus/exporter/process/process.go b/component/prometheus/exporter/process/process.go index 89aa613d1fae..6d8109d76fd8 100644 --- a/component/prometheus/exporter/process/process.go +++ b/component/prometheus/exporter/process/process.go @@ -10,11 +10,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.process", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createIntegration, "process"), + Name: "prometheus.exporter.process", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createIntegration, "process"), }) } diff --git a/component/prometheus/exporter/redis/redis.go b/component/prometheus/exporter/redis/redis.go index c6fc45822bf3..3522b07fb78e 100644 --- a/component/prometheus/exporter/redis/redis.go +++ b/component/prometheus/exporter/redis/redis.go @@ -15,11 +15,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.redis", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "redis"), + Name: "prometheus.exporter.redis", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "redis"), }) } diff --git a/component/prometheus/exporter/services.go b/component/prometheus/exporter/services.go deleted file mode 100644 index 272c1fde2590..000000000000 --- a/component/prometheus/exporter/services.go +++ /dev/null @@ -1,20 +0,0 @@ -package exporter - -import ( - "github.com/grafana/agent/service/http" - "golang.org/x/exp/maps" -) - -// RequiredServices returns the set of services needed by all -// prometheus.exporter components. Callers may optionally pass in additional -// services to add to the returned list. -func RequiredServices(additionalServices ...string) []string { - services := map[string]struct{}{ - http.ServiceName: {}, - } - for _, svc := range additionalServices { - services[svc] = struct{}{} - } - - return maps.Keys(services) -} diff --git a/component/prometheus/exporter/snmp/snmp.go b/component/prometheus/exporter/snmp/snmp.go index e34feff275db..a050c331a85b 100644 --- a/component/prometheus/exporter/snmp/snmp.go +++ b/component/prometheus/exporter/snmp/snmp.go @@ -17,11 +17,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.snmp", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.NewWithTargetBuilder(createExporter, "snmp", buildSNMPTargets), + Name: "prometheus.exporter.snmp", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.NewWithTargetBuilder(createExporter, "snmp", buildSNMPTargets), }) } diff --git a/component/prometheus/exporter/snowflake/snowflake.go b/component/prometheus/exporter/snowflake/snowflake.go index 4b2314036062..0da475d356d5 100644 --- a/component/prometheus/exporter/snowflake/snowflake.go +++ b/component/prometheus/exporter/snowflake/snowflake.go @@ -11,11 +11,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.snowflake", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "snowflake"), + Name: "prometheus.exporter.snowflake", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "snowflake"), }) } diff --git a/component/prometheus/exporter/squid/squid.go b/component/prometheus/exporter/squid/squid.go index 00449a8cba00..4af71e076a1c 100644 --- a/component/prometheus/exporter/squid/squid.go +++ b/component/prometheus/exporter/squid/squid.go @@ -13,11 +13,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.squid", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "squid"), + Name: "prometheus.exporter.squid", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "squid"), }) } diff --git a/component/prometheus/exporter/statsd/statsd.go b/component/prometheus/exporter/statsd/statsd.go index 10c308077e23..3d7b2c0dafa1 100644 --- a/component/prometheus/exporter/statsd/statsd.go +++ b/component/prometheus/exporter/statsd/statsd.go @@ -8,11 +8,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.statsd", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "statsd"), + Name: "prometheus.exporter.statsd", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "statsd"), }) } diff --git a/component/prometheus/exporter/unix/unix.go b/component/prometheus/exporter/unix/unix.go index e33fa9a63136..b1c3af6cb859 100644 --- a/component/prometheus/exporter/unix/unix.go +++ b/component/prometheus/exporter/unix/unix.go @@ -8,11 +8,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.unix", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "unix"), + Name: "prometheus.exporter.unix", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "unix"), }) } diff --git a/component/prometheus/exporter/vsphere/vsphere.go b/component/prometheus/exporter/vsphere/vsphere.go index d50894b5e446..e8cd625c3cdf 100644 --- a/component/prometheus/exporter/vsphere/vsphere.go +++ b/component/prometheus/exporter/vsphere/vsphere.go @@ -13,11 +13,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.vsphere", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "vsphere"), + Name: "prometheus.exporter.vsphere", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "vsphere"), }) } diff --git a/component/prometheus/exporter/windows/windows.go b/component/prometheus/exporter/windows/windows.go index 214302748aee..5f05d3cc63e7 100644 --- a/component/prometheus/exporter/windows/windows.go +++ b/component/prometheus/exporter/windows/windows.go @@ -8,11 +8,11 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.exporter.windows", - Args: Arguments{}, - Exports: exporter.Exports{}, - NeedsServices: exporter.RequiredServices(), - Build: exporter.New(createExporter, "windows"), + Name: "prometheus.exporter.windows", + Args: Arguments{}, + Exports: exporter.Exports{}, + + Build: exporter.New(createExporter, "windows"), }) } diff --git a/component/prometheus/operator/podmonitors/operator.go b/component/prometheus/operator/podmonitors/operator.go index 41fb781f5db4..ea41d6f0fe27 100644 --- a/component/prometheus/operator/podmonitors/operator.go +++ b/component/prometheus/operator/podmonitors/operator.go @@ -4,16 +4,12 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/prometheus/operator" "github.com/grafana/agent/component/prometheus/operator/common" - "github.com/grafana/agent/service/cluster" - "github.com/grafana/agent/service/http" - "github.com/grafana/agent/service/labelstore" ) func init() { component.Register(component.Registration{ - Name: "prometheus.operator.podmonitors", - Args: operator.Arguments{}, - NeedsServices: []string{cluster.ServiceName, http.ServiceName, labelstore.ServiceName}, + Name: "prometheus.operator.podmonitors", + Args: operator.Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return common.New(opts, args, common.KindPodMonitor) diff --git a/component/prometheus/operator/probes/probes.go b/component/prometheus/operator/probes/probes.go index 00dad3fd9821..a8d96b428489 100644 --- a/component/prometheus/operator/probes/probes.go +++ b/component/prometheus/operator/probes/probes.go @@ -4,16 +4,12 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/prometheus/operator" "github.com/grafana/agent/component/prometheus/operator/common" - "github.com/grafana/agent/service/cluster" - "github.com/grafana/agent/service/http" - "github.com/grafana/agent/service/labelstore" ) func init() { component.Register(component.Registration{ - Name: "prometheus.operator.probes", - Args: operator.Arguments{}, - NeedsServices: []string{cluster.ServiceName, http.ServiceName, labelstore.ServiceName}, + Name: "prometheus.operator.probes", + Args: operator.Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return common.New(opts, args, common.KindProbe) diff --git a/component/prometheus/operator/servicemonitors/servicemonitors.go b/component/prometheus/operator/servicemonitors/servicemonitors.go index 8df947f10883..55c1e34c2bbe 100644 --- a/component/prometheus/operator/servicemonitors/servicemonitors.go +++ b/component/prometheus/operator/servicemonitors/servicemonitors.go @@ -4,16 +4,12 @@ import ( "github.com/grafana/agent/component" "github.com/grafana/agent/component/prometheus/operator" "github.com/grafana/agent/component/prometheus/operator/common" - "github.com/grafana/agent/service/cluster" - "github.com/grafana/agent/service/http" - "github.com/grafana/agent/service/labelstore" ) func init() { component.Register(component.Registration{ - Name: "prometheus.operator.servicemonitors", - Args: operator.Arguments{}, - NeedsServices: []string{cluster.ServiceName, http.ServiceName, labelstore.ServiceName}, + Name: "prometheus.operator.servicemonitors", + Args: operator.Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return common.New(opts, args, common.KindServiceMonitor) diff --git a/component/prometheus/receive_http/receive_http.go b/component/prometheus/receive_http/receive_http.go index 5fc0abb91b1c..3e78e1e7472c 100644 --- a/component/prometheus/receive_http/receive_http.go +++ b/component/prometheus/receive_http/receive_http.go @@ -21,9 +21,9 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.receive_http", - Args: Arguments{}, - NeedsServices: []string{labelstore.ServiceName}, + Name: "prometheus.receive_http", + Args: Arguments{}, + Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) }, diff --git a/component/prometheus/relabel/relabel.go b/component/prometheus/relabel/relabel.go index 2f8fd5ab077c..c7b39ad6b0f4 100644 --- a/component/prometheus/relabel/relabel.go +++ b/component/prometheus/relabel/relabel.go @@ -26,10 +26,10 @@ import ( func init() { component.Register(component.Registration{ - Name: "prometheus.relabel", - Args: Arguments{}, - Exports: Exports{}, - NeedsServices: []string{labelstore.ServiceName}, + Name: "prometheus.relabel", + Args: Arguments{}, + Exports: Exports{}, + Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) }, diff --git a/component/prometheus/remotewrite/remote_write.go b/component/prometheus/remotewrite/remote_write.go index ed6ec0089b39..e337ff8f8cca 100644 --- a/component/prometheus/remotewrite/remote_write.go +++ b/component/prometheus/remotewrite/remote_write.go @@ -38,10 +38,10 @@ func init() { remote.UserAgent = useragent.Get() component.Register(component.Registration{ - Name: "prometheus.remote_write", - Args: Arguments{}, - Exports: Exports{}, - NeedsServices: []string{labelstore.ServiceName}, + Name: "prometheus.remote_write", + Args: Arguments{}, + Exports: Exports{}, + Build: func(o component.Options, c component.Arguments) (component.Component, error) { return New(o, c.(Arguments)) }, diff --git a/component/prometheus/scrape/scrape.go b/component/prometheus/scrape/scrape.go index d700221d1a15..8db6fc27d47e 100644 --- a/component/prometheus/scrape/scrape.go +++ b/component/prometheus/scrape/scrape.go @@ -30,9 +30,9 @@ func init() { scrape.UserAgent = useragent.Get() component.Register(component.Registration{ - Name: "prometheus.scrape", - Args: Arguments{}, - NeedsServices: []string{http.ServiceName, cluster.ServiceName, labelstore.ServiceName}, + Name: "prometheus.scrape", + Args: Arguments{}, + Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) }, diff --git a/component/pyroscope/scrape/scrape.go b/component/pyroscope/scrape/scrape.go index 846fee049e5e..bf84c1567e4f 100644 --- a/component/pyroscope/scrape/scrape.go +++ b/component/pyroscope/scrape/scrape.go @@ -33,9 +33,8 @@ const ( func init() { component.Register(component.Registration{ - Name: "pyroscope.scrape", - Args: Arguments{}, - NeedsServices: []string{cluster.ServiceName}, + Name: "pyroscope.scrape", + Args: Arguments{}, Build: func(opts component.Options, args component.Arguments) (component.Component, error) { return New(opts, args.(Arguments)) diff --git a/component/registry.go b/component/registry.go index 20a364be81c4..79b8bff2b574 100644 --- a/component/registry.go +++ b/component/registry.go @@ -97,8 +97,7 @@ type Options struct { // GetServiceData retrieves data for a service by calling // [service.Service.Data] for the specified service. // - // GetServiceData will return an error if the service does not exist or was - // not listed as a dependency with the registration of the component. + // GetServiceData will return an error if the service does not exist. // // The result of GetServiceData may be cached as the value will not change at // runtime. @@ -127,15 +126,6 @@ type Registration struct { // A component which does not expose exports must leave this set to nil. Exports Exports - // NeedsServices holds the set of service names which this component depends - // on to run. If NeedsServices includes an invalid service name (either - // because of a cyclic dependency or the named service doesn't exist), - // components will fail to evaluate. - // - // Modules which are loaded by the registered component will only be able to - // access services in this list. - NeedsServices []string - // Build should construct a new component from an initial Arguments and set // of options. Build func(opts Options, args Arguments) (Component, error) diff --git a/docs/sources/flow/reference/config-blocks/http.md b/docs/sources/flow/reference/config-blocks/http.md index 9f56dc9fc5bd..9ee6de41187f 100644 --- a/docs/sources/flow/reference/config-blocks/http.md +++ b/docs/sources/flow/reference/config-blocks/http.md @@ -16,15 +16,6 @@ title: http block HTTP server functions. `http` is specified without a label and can only be provided once per configuration file. -{{% admonition type="note" %}} -While the `http` block can reference component exports, some components that -rely on the HTTP server have a hidden dependency on the `http` block that may -result in a circular dependency error. - -Only references to components named `remote.*` or `local.*` are guaranteed to -work without any circular dependency errors. -{{% /admonition %}} - ## Example ```river @@ -184,7 +175,7 @@ will serve the found certificate even if it is not compatible with the specified ### server block -The `server` block is used to find the certificate to check the signer. If multiple certificates are found the +The `server` block is used to find the certificate to check the signer. If multiple certificates are found the `windows_certificate_filter` will choose the certificate with the expiration farthest in the future. Name | Type | Description | Default | Required diff --git a/pkg/flow/flow.go b/pkg/flow/flow.go index 9b2294718f61..ec16333568ee 100644 --- a/pkg/flow/flow.go +++ b/pkg/flow/flow.go @@ -192,7 +192,7 @@ func newController(o controllerOptions) *Flow { OnExportsChange: o.OnExportsChange, Registerer: o.Reg, ControllerID: o.ControllerID, - NewModuleController: func(id string, availableServices []string) controller.ModuleController { + NewModuleController: func(id string) controller.ModuleController { return newModuleController(&moduleControllerOptions{ ComponentRegistry: o.ComponentRegistry, ModuleRegistry: o.ModuleRegistry, @@ -201,7 +201,7 @@ func newController(o controllerOptions) *Flow { Reg: o.Reg, DataPath: o.DataPath, ID: id, - ServiceMap: serviceMap.FilterByName(availableServices), + ServiceMap: serviceMap, WorkerPool: workerPool, }) }, diff --git a/pkg/flow/flow_services.go b/pkg/flow/flow_services.go index 76496fb7acc6..46a1c3526128 100644 --- a/pkg/flow/flow_services.go +++ b/pkg/flow/flow_services.go @@ -35,15 +35,6 @@ func serviceConsumersForGraph(graph *dag.Graph, serviceName string, includePeerS for _, consumer := range dependants { // Only return instances of component.Component and service.Service. switch consumer := consumer.(type) { - case *controller.ComponentNode: - if component := consumer.Component(); component != nil { - consumers = append(consumers, service.Consumer{ - Type: service.ConsumerTypeComponent, - ID: consumer.NodeID(), - Value: component, - }) - } - case *controller.ServiceNode: if !includePeerServices { continue diff --git a/pkg/flow/flow_services_test.go b/pkg/flow/flow_services_test.go index 7639daea8144..a4bf2b4cb848 100644 --- a/pkg/flow/flow_services_test.go +++ b/pkg/flow/flow_services_test.go @@ -178,82 +178,6 @@ func TestFlow_GetServiceConsumers(t *testing.T) { require.Equal(t, expectConsumers, ctrl.GetServiceConsumers("svc_a")) } -func TestFlow_GetServiceConsumers_Modules(t *testing.T) { - defer verifyNoGoroutineLeaks(t) - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - componentRunning := util.NewWaitTrigger() - - var ( - svc = &testservices.Fake{ - DefinitionFunc: func() service.Definition { - return service.Definition{Name: "service"} - }, - } - - registry = controller.RegistryMap{ - "module_loader": component.Registration{ - Name: "module_loader", - Args: struct{}{}, - NeedsServices: []string{"service"}, - Build: func(opts component.Options, _ component.Arguments) (component.Component, error) { - mod, err := opts.ModuleController.NewModule("", nil) - require.NoError(t, err, "Failed to create module") - - err = mod.LoadConfig([]byte(`service_consumer "example" {}`), nil) - require.NoError(t, err, "Failed to load module config") - - return &testcomponents.Fake{ - RunFunc: func(ctx context.Context) error { - mod.Run(ctx) - <-ctx.Done() - return nil - }, - }, nil - }, - }, - - "service_consumer": component.Registration{ - Name: "service_consumer", - Args: struct{}{}, - NeedsServices: []string{"service"}, - Build: func(o component.Options, _ component.Arguments) (component.Component, error) { - return &testcomponents.Fake{ - RunFunc: func(ctx context.Context) error { - componentRunning.Trigger() - <-ctx.Done() - return nil - }, - }, nil - }, - }, - } - ) - - cfg := `module_loader "example" {}` - - f, err := ParseSource(t.Name(), []byte(cfg)) - require.NoError(t, err) - require.NotNil(t, f) - - opts := testOptions(t) - opts.Services = append(opts.Services, svc) - - ctrl := newController(controllerOptions{ - Options: opts, - ComponentRegistry: registry, - ModuleRegistry: newModuleRegistry(), - }) - require.NoError(t, ctrl.LoadSource(f, nil)) - go ctrl.Run(ctx) - - require.NoError(t, componentRunning.Wait(5*time.Second), "Component should have been built") - - consumers := ctrl.GetServiceConsumers("service") - require.Len(t, consumers, 2, "There should be a consumer for the module loader and the module's component") -} - func TestComponents_Using_Services(t *testing.T) { defer verifyNoGoroutineLeaks(t) ctx, cancel := context.WithCancel(context.Background()) @@ -267,9 +191,9 @@ func TestComponents_Using_Services(t *testing.T) { ) var ( - dependencySvc = &testservices.Fake{ + existsSvc = &testservices.Fake{ DefinitionFunc: func() service.Definition { - return service.Definition{Name: "dependency"} + return service.Definition{Name: "exists"} }, RunFunc: func(ctx context.Context, host service.Host) error { @@ -284,27 +208,18 @@ func TestComponents_Using_Services(t *testing.T) { }, } - nonDependencySvc = &testservices.Fake{ - DefinitionFunc: func() service.Definition { - return service.Definition{Name: "non_dependency"} - }, - } - registry = controller.RegistryMap{ "service_consumer": component.Registration{ - Name: "service_consumer", - Args: struct{}{}, - NeedsServices: []string{"dependency"}, + Name: "service_consumer", + Args: struct{}{}, + Build: func(opts component.Options, args component.Arguments) (component.Component, error) { // Call Trigger in a defer so we can make some extra assertions before // the test exits. defer componentBuilt.Trigger() - _, err := opts.GetServiceData("dependency") - require.NoError(t, err, "component should be able to access services it depends on") - - _, err = opts.GetServiceData("non_dependency") - require.Error(t, err, "component should not be able to access services it doesn't depend on") + _, err := opts.GetServiceData("exists") + require.NoError(t, err, "component should be able to access services which exist") _, err = opts.GetServiceData("does_not_exist") require.Error(t, err, "component should not be able to access non-existent service") @@ -324,7 +239,7 @@ func TestComponents_Using_Services(t *testing.T) { require.NotNil(t, f) opts := testOptions(t) - opts.Services = append(opts.Services, dependencySvc, nonDependencySvc) + opts.Services = append(opts.Services, existsSvc) ctrl := newController(controllerOptions{ Options: opts, @@ -346,23 +261,17 @@ func TestComponents_Using_Services_In_Modules(t *testing.T) { componentBuilt := util.NewWaitTrigger() var ( - propagatedSvc = &testservices.Fake{ + existsSvc = &testservices.Fake{ DefinitionFunc: func() service.Definition { - return service.Definition{Name: "propagated_service"} - }, - } - - nonPropagatedSvc = &testservices.Fake{ - DefinitionFunc: func() service.Definition { - return service.Definition{Name: "non_propagated_service"} + return service.Definition{Name: "exists"} }, } registry = controller.RegistryMap{ "module_loader": component.Registration{ - Name: "module_loader", - Args: struct{}{}, - NeedsServices: []string{"propagated_service"}, + Name: "module_loader", + Args: struct{}{}, + Build: func(opts component.Options, _ component.Arguments) (component.Component, error) { mod, err := opts.ModuleController.NewModule("", nil) require.NoError(t, err, "Failed to create module") @@ -381,16 +290,16 @@ func TestComponents_Using_Services_In_Modules(t *testing.T) { }, "service_consumer": component.Registration{ - Name: "service_consumer", - Args: struct{}{}, - NeedsServices: []string{"propagated_service"}, + Name: "service_consumer", + Args: struct{}{}, + Build: func(opts component.Options, _ component.Arguments) (component.Component, error) { // Call Trigger in a defer so we can make some extra assertions before // the test exits. defer componentBuilt.Trigger() - _, err := opts.GetServiceData("propagated_service") - require.NoError(t, err, "component should be able to access services that were propagated to it") + _, err := opts.GetServiceData("exists") + require.NoError(t, err, "component should be able to access services which exist") return &testcomponents.Fake{}, nil }, @@ -405,7 +314,7 @@ func TestComponents_Using_Services_In_Modules(t *testing.T) { require.NotNil(t, f) opts := testOptions(t) - opts.Services = append(opts.Services, propagatedSvc, nonPropagatedSvc) + opts.Services = append(opts.Services, existsSvc) ctrl := newController(controllerOptions{ Options: opts, diff --git a/pkg/flow/internal/controller/loader.go b/pkg/flow/internal/controller/loader.go index d44a2a5062eb..e968e8102fe0 100644 --- a/pkg/flow/internal/controller/loader.go +++ b/pkg/flow/internal/controller/loader.go @@ -493,22 +493,6 @@ func (l *Loader) wireGraphEdges(g *dag.Graph) diag.Diagnostics { continue } - g.AddEdge(dag.Edge{From: n, To: dep}) - } - - case *ComponentNode: // Component depending on service. - for _, depName := range n.Registration().NeedsServices { - dep := g.GetByID(depName) - if dep == nil { - diags.Add(diag.Diagnostic{ - Severity: diag.SeverityLevelError, - Message: fmt.Sprintf("%s component depends on undefined service %q; please report this issue to project maintainers", n.NodeID(), depName), - StartPos: ast.StartPos(n.Block()).Position(), - EndPos: ast.EndPos(n.Block()).Position(), - }) - continue - } - g.AddEdge(dag.Edge{From: n, To: dep}) } } diff --git a/pkg/flow/internal/controller/loader_test.go b/pkg/flow/internal/controller/loader_test.go index c6b491f4c899..fee35ec587b5 100644 --- a/pkg/flow/internal/controller/loader_test.go +++ b/pkg/flow/internal/controller/loader_test.go @@ -75,7 +75,7 @@ func TestLoader(t *testing.T) { DataPath: t.TempDir(), OnComponentUpdate: func(cn *controller.ComponentNode) { /* no-op */ }, Registerer: prometheus.NewRegistry(), - NewModuleController: func(id string, availableServices []string) controller.ModuleController { + NewModuleController: func(id string) controller.ModuleController { return nil }, }, @@ -209,7 +209,7 @@ func TestScopeWithFailingComponent(t *testing.T) { DataPath: t.TempDir(), OnComponentUpdate: func(cn *controller.ComponentNode) { /* no-op */ }, Registerer: prometheus.NewRegistry(), - NewModuleController: func(id string, availableServices []string) controller.ModuleController { + NewModuleController: func(id string) controller.ModuleController { return fakeModuleController{} }, }, diff --git a/pkg/flow/internal/controller/node_component.go b/pkg/flow/internal/controller/node_component.go index e86ac1af3dd6..b99597809d4b 100644 --- a/pkg/flow/internal/controller/node_component.go +++ b/pkg/flow/internal/controller/node_component.go @@ -63,15 +63,15 @@ type DialFunc func(ctx context.Context, network, address string) (net.Conn, erro // ComponentGlobals are used by ComponentNodes to build managed components. All // ComponentNodes should use the same ComponentGlobals. type ComponentGlobals struct { - Logger *logging.Logger // Logger shared between all managed components. - TraceProvider trace.TracerProvider // Tracer shared between all managed components. - DataPath string // Shared directory where component data may be stored - OnComponentUpdate func(cn *ComponentNode) // Informs controller that we need to reevaluate - OnExportsChange func(exports map[string]any) // Invoked when the managed component updated its exports - Registerer prometheus.Registerer // Registerer for serving agent and component metrics - ControllerID string // ID of controller. - NewModuleController func(id string, availableServices []string) ModuleController // Func to generate a module controller. - GetServiceData func(name string) (interface{}, error) // Get data for a service. + Logger *logging.Logger // Logger shared between all managed components. + TraceProvider trace.TracerProvider // Tracer shared between all managed components. + DataPath string // Shared directory where component data may be stored + OnComponentUpdate func(cn *ComponentNode) // Informs controller that we need to reevaluate + OnExportsChange func(exports map[string]any) // Invoked when the managed component updated its exports + Registerer prometheus.Registerer // Registerer for serving agent and component metrics + ControllerID string // ID of controller. + NewModuleController func(id string) ModuleController // Func to generate a module controller. + GetServiceData func(name string) (interface{}, error) // Get data for a service. } // ComponentNode is a controller node which manages a user-defined component. @@ -145,7 +145,7 @@ func NewComponentNode(globals ComponentGlobals, reg component.Registration, b *a componentName: strings.Join(b.Name, "."), reg: reg, exportsType: getExportsType(reg), - moduleController: globals.NewModuleController(globalID, reg.NeedsServices), + moduleController: globals.NewModuleController(globalID), OnComponentUpdate: globals.OnComponentUpdate, block: b, @@ -164,11 +164,6 @@ func NewComponentNode(globals ComponentGlobals, reg component.Registration, b *a } func getManagedOptions(globals ComponentGlobals, cn *ComponentNode) component.Options { - allowedServices := make(map[string]struct{}, len(cn.Registration().NeedsServices)) - for _, svc := range cn.Registration().NeedsServices { - allowedServices[svc] = struct{}{} - } - cn.registry = prometheus.NewRegistry() return component.Options{ ID: cn.globalID, @@ -184,9 +179,6 @@ func getManagedOptions(globals ComponentGlobals, cn *ComponentNode) component.Op ModuleController: cn.moduleController, GetServiceData: func(name string) (interface{}, error) { - if _, allowed := allowedServices[name]; !allowed { - return nil, fmt.Errorf("cannot access service data for service %q because it was not listed as a dependency", name) - } return globals.GetServiceData(name) }, } diff --git a/pkg/flow/internal/controller/node_component_test.go b/pkg/flow/internal/controller/node_component_test.go index ced3067f7e7d..6eb46f004601 100644 --- a/pkg/flow/internal/controller/node_component_test.go +++ b/pkg/flow/internal/controller/node_component_test.go @@ -11,7 +11,7 @@ func TestGlobalID(t *testing.T) { mo := getManagedOptions(ComponentGlobals{ DataPath: "/data/", ControllerID: "module.file", - NewModuleController: func(id string, availableServices []string) ModuleController { + NewModuleController: func(id string) ModuleController { return nil }, }, &ComponentNode{ @@ -25,7 +25,7 @@ func TestLocalID(t *testing.T) { mo := getManagedOptions(ComponentGlobals{ DataPath: "/data/", ControllerID: "", - NewModuleController: func(id string, availableServices []string) ModuleController { + NewModuleController: func(id string) ModuleController { return nil }, }, &ComponentNode{ diff --git a/service/cluster/cluster.go b/service/cluster/cluster.go index 398a0db92979..23b8ea4f293a 100644 --- a/service/cluster/cluster.go +++ b/service/cluster/cluster.go @@ -216,21 +216,22 @@ func (s *Service) Run(ctx context.Context, host service.Host) error { } level.Info(s.log).Log("msg", "peers changed", "new_peers", strings.Join(names, ",")) - // Notify dependant components about the clustering change. - for _, consumer := range host.GetServiceConsumers(ServiceName) { + // Notify all components about the clustering change. + components := component.GetAllComponents(host, component.InfoOptions{}) + for _, component := range components { if ctx.Err() != nil { // Stop early if we exited so we don't do unnecessary work notifying // consumers that do not need to be notified. break } - clusterComponent, ok := consumer.Value.(Component) + clusterComponent, ok := component.Component.(Component) if !ok { continue } _, span := tracer.Start(spanCtx, "NotifyClusterChange", trace.WithSpanKind(trace.SpanKindInternal)) - span.SetAttributes(attribute.String("consumer_id", consumer.ID)) + span.SetAttributes(attribute.String("component_id", component.ID.String())) clusterComponent.NotifyClusterChange() diff --git a/service/service.go b/service/service.go index 1da511a91c0f..564bb23b86b9 100644 --- a/service/service.go +++ b/service/service.go @@ -51,8 +51,8 @@ type Host interface { // exist. ListComponents(moduleID string, opts component.InfoOptions) ([]*component.Info, error) - // GetServiceConsumers gets the list of components and services which depend - // on a service by name. + // GetServiceConsumers gets the list of services which depend on a service by + // name. GetServiceConsumers(serviceName string) []Consumer } @@ -73,8 +73,7 @@ const ( // ConsumerTypeInvalid is the default value for ConsumerType. ConsumerTypeInvalid ConsumerType = iota - ConsumerTypeComponent // ConsumerTypeComponent represents a component which uses a service. - ConsumerTypeService // ConsumerTypeService represents a serviec which uses another service. + ConsumerTypeService // ConsumerTypeService represents a service which uses another service. ) // String returns a string representation of the ConsumerType. @@ -82,8 +81,6 @@ func (ct ConsumerType) String() string { switch ct { case ConsumerTypeInvalid: return "invalid" - case ConsumerTypeComponent: - return "component" case ConsumerTypeService: return "service" } @@ -113,9 +110,12 @@ type Service interface { // while Run is active. Update(newConfig any) error - // Data returns the Data associated with a Service. Data - // must always return the same value across multiple calls, - // as callers are expected to be able to cache the result. + // Data returns the Data associated with a Service. Data must always return + // the same value across multiple calls, as callers are expected to be able + // to cache the result. + // + // The return result of Data must not rely on the runtime config of the + // service. // // Data may be invoked before Run. Data() any