allow for metric value class customization#1158
Open
mpnowacki-reef wants to merge 3 commits intoprometheus:masterfrom
Open
allow for metric value class customization#1158mpnowacki-reef wants to merge 3 commits intoprometheus:masterfrom
mpnowacki-reef wants to merge 3 commits intoprometheus:masterfrom
Conversation
Comment on lines
+700
to
+704
| def test_env_var_value_class(self): | ||
| # We need a class to point to. Let's use MutexValue itself but via string | ||
| os.environ['PROMETHEUS_VALUE_CLASS'] = 'prometheus_client.values.MutexValue' | ||
| importlib.reload(values) | ||
| self.assertEqual(values.ValueClass, values.MutexValue) |
There was a problem hiding this comment.
This doesn't test anything because MutexValue is the default. Better point at something non-default, maybe to values.MmapedValue or even some random class from stdlib (we won't use it anyway, just need to check assignment)
| module = importlib.import_module(module_path) | ||
| return getattr(module, class_name) | ||
| except (ImportError, AttributeError) as e: | ||
| raise ImportError(f"Could not import PROMETHEUS_VALUE_CLASS '{value_class_path}': {e}") from None |
There was a problem hiding this comment.
Suggested change
| raise ImportError(f"Could not import PROMETHEUS_VALUE_CLASS '{value_class_path}': {e}") from None | |
| raise ImportError(f"Could not import PROMETHEUS_VALUE_CLASS '{value_class_path}'") from e |
Member
csmarchbanks
left a comment
There was a problem hiding this comment.
Can you describe your use case here a bit more? My initial reaction is that this is too complicated/niche to be supported by this client but I am happy to learn more.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.