Skip to content

Conversation

@NassimBtk
Copy link
Contributor

  • Added changelog entry for the bug fix in prometheusexporter
  • Updated newCollector to handle empty namespace configuration

Description

This pull request addresses an issue in the prometheusexporter where an error was logged if the namespace was not configured, even though this is a valid configuration scenario. The changes ensure that the exporter only attempts to build and log errors for the namespace if it is explicitly specified, improving error handling and reducing unnecessary log noise.

Bug Fixes and Error Handling

  • Updated the namespace initialization in exporter/prometheusexporter/collector.go so that the namespace is only built and error-checked if config.Namespace is set, preventing misleading error logs when the namespace is intentionally omitted.

Documentation and Release Notes

  • Added a changelog entry .chloggen/prometheus-skip-namespace-build-if-missing.yaml to document the bug fix in RN.

Link to tracking issue

Fixes #43015

- Added changelog entry for the bug fix in `prometheusexporter`
- Updated `newCollector` to handle empty namespace configuration
- Extracted namespace normalization logic into `normalizeNamespace`
function
- Added unit tests for empty, invalid, and sanitized namespaces
- Updated `TestNormalizeNamespaceEmpty` to use `require.Empty`
- Updated `TestNormalizeNamespaceInvalid` to use `require.Empty`
Copy link
Contributor

@constanca-m constanca-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix

@songy23 songy23 merged commit 51b3544 into open-telemetry:main Sep 29, 2025
185 checks passed
@github-actions github-actions bot added this to the next release milestone Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[exporter/prometheus] failed to build namespace should not be logged as error when namespace is optional

5 participants