prometheus: add WithNamespace option to prefix metrics #3970
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a
WithNamespace
option to the prometheus exporter.Currently, the lack of such option blocks the otel collector: open-telemetry/opentelemetry-collector#7454
To finalize the collector migration to otel-go and start enabling it by default, both instrumentations must be compatible.
Collector's OpenCensus instrumentation prefixes metrics with the
otelcol_
prefix.To match that behavior in the otel-go instrumentation, we tried to wrap a
prometheus.Registry
with theotelcol_
prefix.But since Otel Go resource attributes are exported as part of the
target_info
metric, which is also prefixed and becomesotelcol_target_info
, for example:This make it impossible for the OpenTelemetry Collector's Prometheus Receiver to properly parse the
target_info
andotel_scope_info
into the appropriated resource attributes and scope attributes. For that reason, the Otel Go instrumentation is not compatible with the existing OpenCensus instrumentation.Adding such a common option in the prometheus instrumentation would unblock the Collector's migration to Otel Go and also other external users such as: #3405 (comment)
For reference, this option is also available on collector's prometheus exporter
closes #3437