-
Notifications
You must be signed in to change notification settings - Fork 953
opentelemetry-configuration: resolve false-positive warning logs for newer schema minor version #5436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
herin049
wants to merge
4
commits into
open-telemetry:main
Choose a base branch
from
herin049:fix/decl-config-schema-ver
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+27
−10
Open
opentelemetry-configuration: resolve false-positive warning logs for newer schema minor version #5436
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| `opentelemetry-configuration`: resolve false-positive warning logs for newer schema minor version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,10 @@ | |
| ConfigurationError, | ||
| load_config_file, | ||
| ) | ||
| from opentelemetry.configuration.file._loader import ( | ||
| _SUPPORTED_SCHEMA_MAJOR, | ||
| _SUPPORTED_SCHEMA_MINOR, | ||
| ) | ||
| from opentelemetry.configuration.models import ( | ||
| BatchSpanProcessor as BatchSpanProcessorConfig, | ||
| ) | ||
|
|
@@ -331,6 +335,8 @@ def test_typed_config_feeds_factory_function(self): | |
| class TestFileFormatValidation(unittest.TestCase): | ||
| """Validate the file_format version per the configuration spec.""" | ||
|
|
||
| _SUPPORTED = f"{_SUPPORTED_SCHEMA_MAJOR}.{_SUPPORTED_SCHEMA_MINOR}" | ||
|
|
||
| @staticmethod | ||
| def _load(file_format: str) -> OpenTelemetryConfiguration: | ||
| with tempfile.NamedTemporaryFile( | ||
|
|
@@ -344,26 +350,34 @@ def _load(file_format: str) -> OpenTelemetryConfiguration: | |
| os.unlink(path) | ||
|
|
||
| def test_supported_version_is_accepted(self): | ||
| config = self._load("1.0") | ||
| self.assertEqual(config.file_format, "1.0") | ||
| with self.assertNoLogs( | ||
| "opentelemetry.configuration.file._loader", level="WARNING" | ||
| ): | ||
| config = self._load(self._SUPPORTED) | ||
| self.assertEqual(config.file_format, self._SUPPORTED) | ||
|
|
||
| def test_pre_release_meta_tag_is_accepted(self): | ||
| # The meta tag is stripped; "1.0-rc.2" is treated as 1.0. | ||
| config = self._load("1.0-rc.2") | ||
| self.assertEqual(config.file_format, "1.0-rc.2") | ||
| # The meta tag is stripped, so the version is read as the supported one. | ||
| version = f"{self._SUPPORTED}-rc.2" | ||
| config = self._load(version) | ||
| self.assertEqual(config.file_format, version) | ||
|
|
||
| def test_newer_minor_is_accepted_with_warning(self): | ||
| version = f"{_SUPPORTED_SCHEMA_MAJOR}.{_SUPPORTED_SCHEMA_MINOR + 1}" | ||
| with self.assertLogs( | ||
| "opentelemetry.configuration.file._loader", level="WARNING" | ||
| ) as logs: | ||
| config = self._load("1.1") | ||
| self.assertEqual(config.file_format, "1.1") | ||
| config = self._load(version) | ||
| self.assertEqual(config.file_format, version) | ||
| self.assertTrue( | ||
| any("newer minor version" in message for message in logs.output) | ||
| ) | ||
|
|
||
| def test_unsupported_major_is_rejected(self): | ||
| for version in ("2.0", "0.4"): | ||
| versions = [f"{_SUPPORTED_SCHEMA_MAJOR + 1}.0"] | ||
| if _SUPPORTED_SCHEMA_MAJOR > 0: | ||
| versions.append(f"{_SUPPORTED_SCHEMA_MAJOR - 1}.0") | ||
|
Comment on lines
+378
to
+379
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we can just hardcode 0.4 since we aren't going backwards from 1.0? |
||
| for version in versions: | ||
| with self.subTest(version=version): | ||
| with self.assertRaises(ConfigurationError) as ctx: | ||
| self._load(version) | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the warning may be annoying the packages are shipping a 1.0 schema so if we bump here we are breaking support for them?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_validate_file_format()doesn't log anything if the current minor is smaller than the latest supported. From my understanding, older minor versions should be fully supported, it's just newer supported minor versions that may include functionality which isn't implemented in the SDK (which is why we log). It's the same as SemVer semantics.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ofc, all bets are off when using developmental features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah. just tested. didn't break for me while still using 1.0
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I was confused by the reading the newer major test. Should we test the older minor as well if
_SUPPORTED_SCHEMA_MINOR > 0?