diff --git a/apps/active_directory_ds.go b/apps/active_directory_ds.go index e27fe144e8..7cdfebc1e2 100644 --- a/apps/active_directory_ds.go +++ b/apps/active_directory_ds.go @@ -32,7 +32,7 @@ func (r MetricsReceiverActiveDirectoryDS) Type() string { return "active_directory_ds" } -func (r MetricsReceiverActiveDirectoryDS) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverActiveDirectoryDS) Pipelines(_ context.Context) []otel.ReceiverPipeline { return []otel.ReceiverPipeline{{ Receiver: otel.Component{ Type: "active_directory_ds", diff --git a/apps/activemq.go b/apps/activemq.go index 363a356396..317a896953 100644 --- a/apps/activemq.go +++ b/apps/activemq.go @@ -15,6 +15,8 @@ package apps import ( + "context" + "github.com/GoogleCloudPlatform/ops-agent/confgenerator" "github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel" ) @@ -32,7 +34,7 @@ func (r MetricsReceiverActivemq) Type() string { return "activemq" } -func (r MetricsReceiverActivemq) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverActivemq) Pipelines(_ context.Context) []otel.ReceiverPipeline { targetSystem := "activemq" diff --git a/apps/aerospike.go b/apps/aerospike.go index 0b149cb967..de726fbdcc 100644 --- a/apps/aerospike.go +++ b/apps/aerospike.go @@ -15,6 +15,7 @@ package apps import ( + "context" "time" "github.com/GoogleCloudPlatform/ops-agent/confgenerator" @@ -50,7 +51,7 @@ var ( ) // Pipelines is the OTEL pipelines created from MetricsReceiverAerospike -func (r MetricsReceiverAerospike) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverAerospike) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.Endpoint == "" { r.Endpoint = defaultAerospikeEndpoint } diff --git a/apps/apache.go b/apps/apache.go index 371a6c7fc8..f4c5acadb6 100644 --- a/apps/apache.go +++ b/apps/apache.go @@ -36,7 +36,7 @@ func (r MetricsReceiverApache) Type() string { return "apache" } -func (r MetricsReceiverApache) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverApache) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.ServerStatusURL == "" { r.ServerStatusURL = defaultServerStatusURL } diff --git a/apps/cassandra.go b/apps/cassandra.go index 4ea3c41f2d..74e36116f2 100644 --- a/apps/cassandra.go +++ b/apps/cassandra.go @@ -36,7 +36,7 @@ func (r MetricsReceiverCassandra) Type() string { return "cassandra" } -func (r MetricsReceiverCassandra) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverCassandra) Pipelines(_ context.Context) []otel.ReceiverPipeline { targetSystem := "cassandra" return r.MetricsReceiverSharedJVM. diff --git a/apps/couchbase.go b/apps/couchbase.go index 91e157b474..1eaa9b9ae9 100644 --- a/apps/couchbase.go +++ b/apps/couchbase.go @@ -43,7 +43,7 @@ func (r MetricsReceiverCouchbase) Type() string { } // Pipelines will construct the prometheus receiver configuration -func (r MetricsReceiverCouchbase) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverCouchbase) Pipelines(_ context.Context) []otel.ReceiverPipeline { targets := []string{r.Endpoint} if r.Endpoint == "" { targets = []string{defaultCouchbaseEndpoint} diff --git a/apps/couchdb.go b/apps/couchdb.go index 82f7cd761d..0fbe00ded6 100644 --- a/apps/couchdb.go +++ b/apps/couchdb.go @@ -40,7 +40,7 @@ func (MetricsReceiverCouchdb) Type() string { return "couchdb" } -func (r MetricsReceiverCouchdb) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverCouchdb) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.Endpoint == "" { r.Endpoint = defaultCouchdbEndpoint } diff --git a/apps/elasticsearch.go b/apps/elasticsearch.go index ad4f56c6ab..71d62628e2 100644 --- a/apps/elasticsearch.go +++ b/apps/elasticsearch.go @@ -45,7 +45,7 @@ func (r MetricsReceiverElasticsearch) Type() string { return "elasticsearch" } -func (r MetricsReceiverElasticsearch) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverElasticsearch) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.Endpoint == "" { r.Endpoint = defaultElasticsearchEndpoint } diff --git a/apps/flink.go b/apps/flink.go index c5c5b14610..d612fe5504 100644 --- a/apps/flink.go +++ b/apps/flink.go @@ -34,7 +34,7 @@ func (MetricsReceiverFlink) Type() string { const defaultFlinkEndpoint = "http://localhost:8081" -func (r MetricsReceiverFlink) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverFlink) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.Endpoint == "" { r.Endpoint = defaultFlinkEndpoint } diff --git a/apps/hadoop.go b/apps/hadoop.go index 4e424523ee..b69bc608d1 100644 --- a/apps/hadoop.go +++ b/apps/hadoop.go @@ -35,7 +35,7 @@ func (r MetricsReceiverHadoop) Type() string { return "hadoop" } -func (r MetricsReceiverHadoop) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverHadoop) Pipelines(_ context.Context) []otel.ReceiverPipeline { targetSystem := "hadoop" if r.MetricsReceiverSharedCollectJVM.ShouldCollectJVMMetrics() { targetSystem = fmt.Sprintf("%s,%s", targetSystem, "jvm") diff --git a/apps/hbase.go b/apps/hbase.go index 9efda3b8a7..8db3cde9b6 100644 --- a/apps/hbase.go +++ b/apps/hbase.go @@ -35,7 +35,7 @@ func (r MetricsReceiverHbase) Type() string { return "hbase" } -func (r MetricsReceiverHbase) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverHbase) Pipelines(_ context.Context) []otel.ReceiverPipeline { targetSystem := "hbase" if r.MetricsReceiverSharedCollectJVM.ShouldCollectJVMMetrics() { targetSystem = fmt.Sprintf("%s,%s", targetSystem, "jvm") diff --git a/apps/hostmetrics.go b/apps/hostmetrics.go index f20823ea51..f199c6fc13 100644 --- a/apps/hostmetrics.go +++ b/apps/hostmetrics.go @@ -15,6 +15,8 @@ package apps import ( + "context" + "github.com/GoogleCloudPlatform/ops-agent/confgenerator" "github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel" ) @@ -29,7 +31,7 @@ func (r MetricsReceiverHostmetrics) Type() string { return "hostmetrics" } -func (r MetricsReceiverHostmetrics) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverHostmetrics) Pipelines(_ context.Context) []otel.ReceiverPipeline { return []otel.ReceiverPipeline{{ Receiver: otel.Component{ Type: "hostmetrics", diff --git a/apps/iis.go b/apps/iis.go index a14ec616e4..a996fec3ae 100644 --- a/apps/iis.go +++ b/apps/iis.go @@ -36,7 +36,7 @@ func (r MetricsReceiverIis) Type() string { return "iis" } -func (r MetricsReceiverIis) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverIis) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.ReceiverVersion == "2" { return []otel.ReceiverPipeline{{ Receiver: otel.Component{ diff --git a/apps/jetty.go b/apps/jetty.go index 05f579dd27..9c89e2ffd1 100644 --- a/apps/jetty.go +++ b/apps/jetty.go @@ -35,7 +35,7 @@ func (r MetricsReceiverJetty) Type() string { return "jetty" } -func (r MetricsReceiverJetty) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverJetty) Pipelines(_ context.Context) []otel.ReceiverPipeline { targetSystem := "jetty" if r.MetricsReceiverSharedCollectJVM.ShouldCollectJVMMetrics() { targetSystem = fmt.Sprintf("%s,%s", targetSystem, "jvm") diff --git a/apps/jvm.go b/apps/jvm.go index 34b25f4239..c9b7ab8857 100644 --- a/apps/jvm.go +++ b/apps/jvm.go @@ -15,6 +15,8 @@ package apps import ( + "context" + "github.com/GoogleCloudPlatform/ops-agent/confgenerator" "github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel" ) @@ -31,7 +33,7 @@ func (r MetricsReceiverJVM) Type() string { return "jvm" } -func (r MetricsReceiverJVM) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverJVM) Pipelines(_ context.Context) []otel.ReceiverPipeline { return r.MetricsReceiverSharedJVM. WithDefaultEndpoint(defaultJVMEndpoint). ConfigurePipelines( diff --git a/apps/kafka.go b/apps/kafka.go index 771588493f..c041c015f6 100644 --- a/apps/kafka.go +++ b/apps/kafka.go @@ -35,7 +35,7 @@ func (r MetricsReceiverKafka) Type() string { return "kafka" } -func (r MetricsReceiverKafka) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverKafka) Pipelines(_ context.Context) []otel.ReceiverPipeline { targetSystem := "kafka" return r.MetricsReceiverSharedJVM. WithDefaultEndpoint(defaultKafkaEndpoint). diff --git a/apps/memcached.go b/apps/memcached.go index e5c0c0811c..a694939e59 100644 --- a/apps/memcached.go +++ b/apps/memcached.go @@ -15,6 +15,8 @@ package apps import ( + "context" + "github.com/GoogleCloudPlatform/ops-agent/confgenerator" "github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel" ) @@ -33,7 +35,7 @@ func (r MetricsReceiverMemcached) Type() string { return "memcached" } -func (r MetricsReceiverMemcached) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverMemcached) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.Endpoint == "" { r.Endpoint = defaultMemcachedTCPEndpoint } diff --git a/apps/mongodb.go b/apps/mongodb.go index 666d4208ca..d597081e81 100644 --- a/apps/mongodb.go +++ b/apps/mongodb.go @@ -46,7 +46,7 @@ func (r MetricsReceiverMongoDB) Type() string { return "mongodb" } -func (r MetricsReceiverMongoDB) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverMongoDB) Pipelines(_ context.Context) []otel.ReceiverPipeline { transport := "tcp" if r.Endpoint == "" { r.Endpoint = defaultMongodbEndpoint diff --git a/apps/mssql.go b/apps/mssql.go index b667f93181..04a0f6b06e 100644 --- a/apps/mssql.go +++ b/apps/mssql.go @@ -15,6 +15,8 @@ package apps import ( + "context" + "github.com/GoogleCloudPlatform/ops-agent/confgenerator" "github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel" "github.com/GoogleCloudPlatform/ops-agent/internal/platform" @@ -32,7 +34,7 @@ func (MetricsReceiverMssql) Type() string { return "mssql" } -func (m MetricsReceiverMssql) Pipelines() []otel.ReceiverPipeline { +func (m MetricsReceiverMssql) Pipelines(_ context.Context) []otel.ReceiverPipeline { if m.ReceiverVersion == "2" { return []otel.ReceiverPipeline{{ Receiver: otel.Component{ diff --git a/apps/mysql.go b/apps/mysql.go index bc106c1c32..0d46fc22c3 100644 --- a/apps/mysql.go +++ b/apps/mysql.go @@ -16,6 +16,8 @@ package apps import ( "context" + "fmt" + "strings" "github.com/GoogleCloudPlatform/ops-agent/confgenerator" "github.com/GoogleCloudPlatform/ops-agent/confgenerator/fluentbit" @@ -23,9 +25,6 @@ import ( "github.com/GoogleCloudPlatform/ops-agent/internal/secret" "github.com/go-sql-driver/mysql" - - "fmt" - "strings" ) type MetricsReceiverMySql struct { @@ -45,7 +44,7 @@ func (r MetricsReceiverMySql) Type() string { return "mysql" } -func (r MetricsReceiverMySql) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverMySql) Pipelines(_ context.Context) []otel.ReceiverPipeline { transport := "tcp" if r.Endpoint == "" { transport = "unix" diff --git a/apps/nginx.go b/apps/nginx.go index a74b7d7959..fca06e1873 100644 --- a/apps/nginx.go +++ b/apps/nginx.go @@ -36,7 +36,7 @@ func (r MetricsReceiverNginx) Type() string { return "nginx" } -func (r MetricsReceiverNginx) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverNginx) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.StubStatusURL == "" { r.StubStatusURL = defaultStubStatusURL } diff --git a/apps/oracledb.go b/apps/oracledb.go index 055f85c8d2..4c355501f8 100644 --- a/apps/oracledb.go +++ b/apps/oracledb.go @@ -49,7 +49,7 @@ func (r MetricsReceiverOracleDB) Type() string { return "oracledb" } -func (r MetricsReceiverOracleDB) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverOracleDB) Pipelines(_ context.Context) []otel.ReceiverPipeline { endpoint := r.Endpoint if r.Endpoint == "" { endpoint = defaultOracleDBEndpoint diff --git a/apps/otlp.go b/apps/otlp.go index c44a8d649c..9b2dc93428 100644 --- a/apps/otlp.go +++ b/apps/otlp.go @@ -15,6 +15,7 @@ package apps import ( + "context" "fmt" "regexp" "strings" @@ -119,7 +120,7 @@ func (r ReceiverOTLP) metricsProcessors() (otel.ExporterType, otel.ResourceDetec } } -func (r ReceiverOTLP) Pipelines() []otel.ReceiverPipeline { +func (r ReceiverOTLP) Pipelines(_ context.Context) []otel.ReceiverPipeline { endpoint := r.GRPCEndpoint if endpoint == "" { endpoint = defaultGRPCEndpoint diff --git a/apps/postgresql.go b/apps/postgresql.go index 932538b510..0934a103cf 100644 --- a/apps/postgresql.go +++ b/apps/postgresql.go @@ -16,13 +16,12 @@ package apps import ( "context" + "strings" "github.com/GoogleCloudPlatform/ops-agent/confgenerator" "github.com/GoogleCloudPlatform/ops-agent/confgenerator/fluentbit" "github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel" "github.com/GoogleCloudPlatform/ops-agent/internal/secret" - - "strings" ) type MetricsReceiverPostgresql struct { @@ -46,7 +45,7 @@ func (r MetricsReceiverPostgresql) Type() string { return "postgresql" } -func (r MetricsReceiverPostgresql) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverPostgresql) Pipelines(_ context.Context) []otel.ReceiverPipeline { transport := "tcp" if r.Endpoint == "" { transport = "unix" diff --git a/apps/rabbitmq.go b/apps/rabbitmq.go index 91e33d7ba5..90590ec71c 100644 --- a/apps/rabbitmq.go +++ b/apps/rabbitmq.go @@ -134,7 +134,7 @@ func (r MetricsReceiverRabbitmq) Type() string { return "rabbitmq" } -func (r MetricsReceiverRabbitmq) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverRabbitmq) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.Endpoint == "" { r.Endpoint = defaultRabbitmqTCPEndpoint } diff --git a/apps/redis.go b/apps/redis.go index 153dc4d13f..8826687920 100644 --- a/apps/redis.go +++ b/apps/redis.go @@ -40,7 +40,7 @@ func (r MetricsReceiverRedis) Type() string { return "redis" } -func (r MetricsReceiverRedis) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverRedis) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.Address == "" { r.Address = defaultRedisEndpoint } diff --git a/apps/saphana.go b/apps/saphana.go index b3fe4d0be6..2cc79226fb 100644 --- a/apps/saphana.go +++ b/apps/saphana.go @@ -154,7 +154,7 @@ func (s MetricsReceiverSapHana) Type() string { return "saphana" } -func (s MetricsReceiverSapHana) Pipelines() []otel.ReceiverPipeline { +func (s MetricsReceiverSapHana) Pipelines(_ context.Context) []otel.ReceiverPipeline { if s.Endpoint == "" { s.Endpoint = defaultSapHanaEndpoint } diff --git a/apps/solr.go b/apps/solr.go index 2828d6e07e..587d8d03ad 100644 --- a/apps/solr.go +++ b/apps/solr.go @@ -34,7 +34,7 @@ func (r MetricsReceiverSolr) Type() string { return "solr" } -func (r MetricsReceiverSolr) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverSolr) Pipelines(_ context.Context) []otel.ReceiverPipeline { targetSystem := "solr" return r.MetricsReceiverSharedJVM. diff --git a/apps/tomcat.go b/apps/tomcat.go index 2feb07a694..26584abffe 100644 --- a/apps/tomcat.go +++ b/apps/tomcat.go @@ -36,7 +36,7 @@ func (r MetricsReceiverTomcat) Type() string { return "tomcat" } -func (r MetricsReceiverTomcat) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverTomcat) Pipelines(_ context.Context) []otel.ReceiverPipeline { targetSystem := "tomcat" return r.MetricsReceiverSharedJVM. diff --git a/apps/varnish.go b/apps/varnish.go index 52749881c4..09f4ae4f5e 100644 --- a/apps/varnish.go +++ b/apps/varnish.go @@ -33,7 +33,7 @@ func (MetricsReceiverVarnish) Type() string { return "varnish" } -func (r MetricsReceiverVarnish) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverVarnish) Pipelines(_ context.Context) []otel.ReceiverPipeline { return []otel.ReceiverPipeline{{ Receiver: otel.Component{ Type: "varnish", diff --git a/apps/vault.go b/apps/vault.go index c8dc002b7d..b4c5497b9f 100644 --- a/apps/vault.go +++ b/apps/vault.go @@ -75,7 +75,7 @@ func (r MetricsReceiverVault) Type() string { return "vault" } -func (r MetricsReceiverVault) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverVault) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.Endpoint == "" { r.Endpoint = defaultVaultEndpoint } diff --git a/apps/wildfly.go b/apps/wildfly.go index ac3fade293..522cdca936 100644 --- a/apps/wildfly.go +++ b/apps/wildfly.go @@ -35,7 +35,7 @@ func (r MetricsReceiverWildfly) Type() string { return "wildfly" } -func (r MetricsReceiverWildfly) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverWildfly) Pipelines(_ context.Context) []otel.ReceiverPipeline { targetSystem := "wildfly" if r.MetricsReceiverSharedJVM.Endpoint != "" && !strings.HasPrefix(r.MetricsReceiverSharedJVM.Endpoint, "service:jmx") { diff --git a/apps/zookeeper.go b/apps/zookeeper.go index 79c72c9172..e30bdcf134 100644 --- a/apps/zookeeper.go +++ b/apps/zookeeper.go @@ -40,7 +40,7 @@ func (MetricsReceiverZookeeper) Type() string { return "zookeeper" } -func (r MetricsReceiverZookeeper) Pipelines() []otel.ReceiverPipeline { +func (r MetricsReceiverZookeeper) Pipelines(_ context.Context) []otel.ReceiverPipeline { if r.Endpoint == "" { r.Endpoint = defaultZookeeperEndpoint } diff --git a/confgenerator/confgenerator.go b/confgenerator/confgenerator.go index 5d49831192..26727f5bb2 100644 --- a/confgenerator/confgenerator.go +++ b/confgenerator/confgenerator.go @@ -97,7 +97,7 @@ func (uc *UnifiedConfig) GenerateOtelConfig(ctx context.Context) (string, error) if uc.Metrics != nil { var err error - receiverPipelines, pipelines, err = uc.generateOtelPipelines() + receiverPipelines, pipelines, err = uc.generateOtelPipelines(ctx) if err != nil { return "", err } @@ -141,12 +141,12 @@ func (uc *UnifiedConfig) GenerateOtelConfig(ctx context.Context) (string, error) } // generateOtelPipelines generates a map of OTel pipeline names to OTel pipelines. -func (uc *UnifiedConfig) generateOtelPipelines() (map[string]otel.ReceiverPipeline, map[string]otel.Pipeline, error) { +func (uc *UnifiedConfig) generateOtelPipelines(ctx context.Context) (map[string]otel.ReceiverPipeline, map[string]otel.Pipeline, error) { m := uc.Metrics outR := make(map[string]otel.ReceiverPipeline) outP := make(map[string]otel.Pipeline) addReceiver := func(pipelineType, pID, rID string, receiver OTelReceiver, processorIDs []string) error { - for i, receiverPipeline := range receiver.Pipelines() { + for i, receiverPipeline := range receiver.Pipelines(ctx) { receiverPipelineName := strings.ReplaceAll(rID, "_", "__") if i > 0 { receiverPipelineName = fmt.Sprintf("%s_%d", receiverPipelineName, i) diff --git a/confgenerator/config.go b/confgenerator/config.go index 9c16879e61..a6fe67ccb8 100644 --- a/confgenerator/config.go +++ b/confgenerator/config.go @@ -571,7 +571,7 @@ type Metrics struct { type OTelReceiver interface { Component - Pipelines() []otel.ReceiverPipeline + Pipelines(ctx context.Context) []otel.ReceiverPipeline } type MetricsReceiver interface { @@ -781,14 +781,14 @@ type TracesService struct { Pipelines map[string]*Pipeline } -func (uc *UnifiedConfig) Validate() error { +func (uc *UnifiedConfig) Validate(ctx context.Context) error { if uc.Logging != nil { if err := uc.Logging.Validate(); err != nil { return err } } if uc.Metrics != nil { - if err := uc.ValidateMetrics(); err != nil { + if err := uc.ValidateMetrics(ctx); err != nil { return err } } @@ -903,7 +903,7 @@ func (uc *UnifiedConfig) TracesReceivers() (map[string]TracesReceiver, error) { return validReceivers, nil } -func (uc *UnifiedConfig) ValidateMetrics() error { +func (uc *UnifiedConfig) ValidateMetrics(ctx context.Context) error { m := uc.Metrics subagent := "metrics" if len(m.Exporters) > 0 { @@ -931,7 +931,7 @@ func (uc *UnifiedConfig) ValidateMetrics() error { return err } - if err := validateSSLConfig(receivers); err != nil { + if err := validateSSLConfig(receivers, ctx); err != nil { return err } } @@ -1104,9 +1104,9 @@ func validateIncompatibleJVMReceivers(typeCounts map[string]int) error { return nil } -func validateSSLConfig(receivers metricsReceiverMap) error { +func validateSSLConfig(receivers metricsReceiverMap, ctx context.Context) error { for receiverId, receiver := range receivers { - for _, pipeline := range receiver.Pipelines() { + for _, pipeline := range receiver.Pipelines(ctx) { if tlsCfg, ok := pipeline.Receiver.Config.(map[string]interface{})["tls"]; ok { cfg := tlsCfg.(map[string]interface{}) // If insecure, no other fields are allowed diff --git a/confgenerator/confmerger.go b/confgenerator/confmerger.go index e358931df7..28133c69a0 100644 --- a/confgenerator/confmerger.go +++ b/confgenerator/confmerger.go @@ -41,7 +41,7 @@ func MergeConfFiles(ctx context.Context, userConfPath string, builtInConfStructs mergeConfigs(result, overrides) } - if err := result.Validate(); err != nil { + if err := result.Validate(ctx); err != nil { return nil, err } diff --git a/confgenerator/feature_tracking_test.go b/confgenerator/feature_tracking_test.go index 408399a2be..3feefb152c 100644 --- a/confgenerator/feature_tracking_test.go +++ b/confgenerator/feature_tracking_test.go @@ -15,6 +15,7 @@ package confgenerator_test import ( "bytes" + "context" "encoding/csv" "errors" "fmt" @@ -572,7 +573,7 @@ func (m MetricsReceiverFoo) Type() string { return "metricsReceiverFoo" } -func (m MetricsReceiverFoo) Pipelines() []otel.ReceiverPipeline { +func (m MetricsReceiverFoo) Pipelines(_ context.Context) []otel.ReceiverPipeline { return nil } @@ -915,7 +916,7 @@ func (m Example) Type() string { return "example" } -func (m Example) Pipelines() []otel.ReceiverPipeline { +func (m Example) Pipelines(_ context.Context) []otel.ReceiverPipeline { return nil } diff --git a/confgenerator/prometheus.go b/confgenerator/prometheus.go index 1248deb98a..9c5eef11e8 100644 --- a/confgenerator/prometheus.go +++ b/confgenerator/prometheus.go @@ -15,6 +15,7 @@ package confgenerator import ( + "context" "errors" "fmt" "os" @@ -73,7 +74,7 @@ func (r PrometheusMetrics) Type() string { return "prometheus" } -func (r PrometheusMetrics) Pipelines() []otel.ReceiverPipeline { +func (r PrometheusMetrics) Pipelines(_ context.Context) []otel.ReceiverPipeline { // Get the resource metadata for the instance we're running on. if gceMetadata, ok := MetadataResource.(resourcedetector.GCEResource); ok { // Create a prometheus style mapping for the GCE metadata.