Skip to content

Commit 034c00c

Browse files
authored
[receiver/prometheus] Use confighttp defaulting constructor (#49359)
#### Description The target allocator's embedded confighttp.ClientConfig defaulted to a zero value. Use the confighttp.ClientConfig defaulting constructor instead, resetting the other constructor-set fields to preserve existing behavior. #### Link to tracking issue Part of #49308. Missed it in #49307. #### Authorship - [x] I, a human, wrote this pull request description myself. <!--Please delete paragraphs that you did not use before submitting.-->
1 parent d3308cf commit 034c00c

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

receiver/prometheusreceiver/factory.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import (
99
promconfig "github.com/prometheus/prometheus/config"
1010
_ "github.com/prometheus/prometheus/plugins" // init() of this package registers service discovery impl.
1111
"go.opentelemetry.io/collector/component"
12+
"go.opentelemetry.io/collector/config/confighttp"
13+
"go.opentelemetry.io/collector/config/configoptional"
1214
"go.opentelemetry.io/collector/consumer"
1315
"go.opentelemetry.io/collector/receiver"
1416
"go.uber.org/zap"
1517

1618
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver/internal/apiserver"
1719
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver/internal/metadata"
20+
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver/internal/targetallocator"
1821
)
1922

2023
// NewFactory creates a new Prometheus receiver factory.
@@ -26,10 +29,18 @@ func NewFactory() receiver.Factory {
2629
}
2730

2831
func createDefaultConfig() component.Config {
32+
taClientConfig := confighttp.NewDefaultClientConfig()
33+
// TODO: See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/49316.
34+
taClientConfig.MaxIdleConns = 0
35+
taClientConfig.IdleConnTimeout = 0
36+
taClientConfig.ForceAttemptHTTP2 = false
2937
return &Config{
3038
PrometheusConfig: &PromConfig{
3139
GlobalConfig: promconfig.DefaultGlobalConfig,
3240
},
41+
TargetAllocator: configoptional.Default(targetallocator.Config{
42+
ClientConfig: taClientConfig,
43+
}),
3344
APIServer: apiserver.DefaultConfig(),
3445
}
3546
}

0 commit comments

Comments
 (0)