@@ -18,9 +18,16 @@ import (
18
18
"go.opentelemetry.io/collector/service/internal/resource"
19
19
)
20
20
21
+ var useLocalHostAsDefaultMetricsAddressFeatureGate = featuregate .GlobalRegistry ().MustRegister (
22
+ "telemetry.UseLocalHostAsDefaultMetricsAddress" ,
23
+ featuregate .StageBeta ,
24
+ featuregate .WithRegisterFromVersion ("v0.110.0" ),
25
+ featuregate .WithRegisterDescription ("controls whether default Prometheus metrics server use localhost as the default host for their endpoints" ),
26
+ )
27
+
21
28
// disableHighCardinalityMetricsfeatureGate is the feature gate that controls whether the collector should enable
22
29
// potentially high cardinality metrics. The gate will be removed when the collector allows for view configuration.
23
- var disableHighCardinalityMetricsfeatureGate = featuregate .GlobalRegistry ().MustRegister (
30
+ var disableHighCardinalityMetricsFeatureGate = featuregate .GlobalRegistry ().MustRegister (
24
31
"telemetry.disableHighCardinalityMetrics" ,
25
32
featuregate .StageAlpha ,
26
33
featuregate .WithRegisterDescription ("controls whether the collector should enable potentially high" +
@@ -67,7 +74,7 @@ func NewFactory() Factory {
67
74
}),
68
75
withMeterProvider (func (_ context.Context , set Settings , cfg component.Config ) (metric.MeterProvider , error ) {
69
76
c := * cfg .(* Config )
70
- disableHighCard := disableHighCardinalityMetricsfeatureGate .IsEnabled ()
77
+ disableHighCard := disableHighCardinalityMetricsFeatureGate .IsEnabled ()
71
78
return newMeterProvider (
72
79
meterProviderSettings {
73
80
res : resource .New (set .BuildInfo , c .Resource ),
@@ -81,6 +88,11 @@ func NewFactory() Factory {
81
88
}
82
89
83
90
func createDefaultConfig () component.Config {
91
+ metricsAddress := "localhost:8888"
92
+ if ! useLocalHostAsDefaultMetricsAddressFeatureGate .IsEnabled () {
93
+ metricsAddress = ":8888"
94
+ }
95
+
84
96
return & Config {
85
97
Logs : LogsConfig {
86
98
Level : zapcore .InfoLevel ,
@@ -100,7 +112,7 @@ func createDefaultConfig() component.Config {
100
112
},
101
113
Metrics : MetricsConfig {
102
114
Level : configtelemetry .LevelNormal ,
103
- Address : ":8888" ,
115
+ Address : metricsAddress ,
104
116
},
105
117
}
106
118
}
0 commit comments