Skip to content

Commit 7ecdc47

Browse files
Alex Botenpantuza
Alex Boten
authored andcommitted
[service] use WithNamespace instead of WrapRegistererWithPrefix (open-telemetry#8988)
Using this functionality in the otel prom exporter fixes a bug where the target_info was prefixed as otelcol_target_info previously. --------- Signed-off-by: Alex Boten <[email protected]>
1 parent 217de16 commit 7ecdc47

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: use WithNamespace instead of WrapRegistererWithPrefix
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [8988]
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: |
19+
Using this functionality in the otel prom exporter fixes a bug where the
20+
target_info was prefixed as otelcol_target_info previously.
21+
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

service/internal/proctelemetry/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,16 @@ func initPrometheusExporter(prometheusConfig *config.Prometheus, asyncErrorChann
203203
if prometheusConfig.Port == nil {
204204
return nil, nil, fmt.Errorf("port must be specified")
205205
}
206-
wrappedRegisterer := prometheus.WrapRegistererWithPrefix("otelcol_", promRegistry)
207206
exporter, err := otelprom.New(
208-
otelprom.WithRegisterer(wrappedRegisterer),
207+
otelprom.WithRegisterer(promRegistry),
209208
// https://github.com/open-telemetry/opentelemetry-collector/issues/8043
210209
otelprom.WithoutUnits(),
211210
// Disabled for the moment until this becomes stable, and we are ready to break backwards compatibility.
212211
otelprom.WithoutScopeInfo(),
213212
otelprom.WithProducer(opencensus.NewMetricProducer()),
214213
// This allows us to produce metrics that are backwards compatible w/ opencensus
215214
otelprom.WithoutCounterSuffixes(),
215+
otelprom.WithNamespace("otelcol"),
216216
)
217217
if err != nil {
218218
return nil, nil, fmt.Errorf("error creating otel prometheus exporter: %w", err)

service/telemetry_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func TestTelemetryInit(t *testing.T) {
149149
"net_host_port": "",
150150
},
151151
},
152-
metricPrefix + "target_info": {
152+
"target_info": {
153153
value: 0,
154154
labels: map[string]string{
155155
"service_name": "otelcol",
@@ -180,7 +180,7 @@ func TestTelemetryInit(t *testing.T) {
180180
value: 10,
181181
labels: map[string]string{},
182182
},
183-
metricPrefix + "target_info": {
183+
"target_info": {
184184
value: 0,
185185
labels: map[string]string{
186186
"service_name": "otelcol",
@@ -236,7 +236,7 @@ func TestTelemetryInit(t *testing.T) {
236236
"net_host_port": "",
237237
},
238238
},
239-
metricPrefix + "target_info": {
239+
"target_info": {
240240
value: 0,
241241
labels: map[string]string{
242242
"service_name": "otelcol",

0 commit comments

Comments
 (0)