Skip to content

Commit 6a37505

Browse files
committed
Change default metrics address to localhost:8888
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent fe10446 commit 6a37505

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'breaking'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: service/telemetry
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note:
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: []
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: This behavior can be disabled by disabling the feature gate 'telemetry.UseLocalHostAsDefaultMetricsAddress'.
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [user, api]

service/telemetry/factory.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@ import (
1818
"go.opentelemetry.io/collector/service/internal/resource"
1919
)
2020

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+
2128
// disableHighCardinalityMetricsfeatureGate is the feature gate that controls whether the collector should enable
2229
// 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(
2431
"telemetry.disableHighCardinalityMetrics",
2532
featuregate.StageAlpha,
2633
featuregate.WithRegisterDescription("controls whether the collector should enable potentially high"+
@@ -67,7 +74,7 @@ func NewFactory() Factory {
6774
}),
6875
withMeterProvider(func(_ context.Context, set Settings, cfg component.Config) (metric.MeterProvider, error) {
6976
c := *cfg.(*Config)
70-
disableHighCard := disableHighCardinalityMetricsfeatureGate.IsEnabled()
77+
disableHighCard := disableHighCardinalityMetricsFeatureGate.IsEnabled()
7178
return newMeterProvider(
7279
meterProviderSettings{
7380
res: resource.New(set.BuildInfo, c.Resource),
@@ -81,6 +88,11 @@ func NewFactory() Factory {
8188
}
8289

8390
func createDefaultConfig() component.Config {
91+
metricsAddress := "localhost:8888"
92+
if !useLocalHostAsDefaultMetricsAddressFeatureGate.IsEnabled() {
93+
metricsAddress = ":8888"
94+
}
95+
8496
return &Config{
8597
Logs: LogsConfig{
8698
Level: zapcore.InfoLevel,
@@ -100,7 +112,7 @@ func createDefaultConfig() component.Config {
100112
},
101113
Metrics: MetricsConfig{
102114
Level: configtelemetry.LevelNormal,
103-
Address: ":8888",
115+
Address: metricsAddress,
104116
},
105117
}
106118
}

0 commit comments

Comments
 (0)