-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Injectable statsd client #7138
Merged
Merged
Injectable statsd client #7138
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7ecaca2
Merge pull request #1 from apache/master
DiggidyDave e11da34
Merge pull request #2 from apache/master
DiggidyDave 9403d49
Merge pull request #3 from apache/master
DiggidyDave 4371587
Add ability to inject statsd client; some py test/reqs updates
DiggidyDave d862804
add license to test file, and remove blank line at EOF
DiggidyDave 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 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 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 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 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 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 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 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 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 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 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 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,34 @@ | ||
from unittest import TestCase | ||
from unittest.mock import Mock, patch | ||
|
||
from superset.stats_logger import StatsdStatsLogger | ||
|
||
|
||
class StatsdStatsLoggerTest(TestCase): | ||
|
||
def verify_client_calls(self, logger, client): | ||
logger.incr('foo1') | ||
client.incr.assert_called_once() | ||
client.incr.assert_called_with('foo1') | ||
logger.decr('foo2') | ||
client.decr.assert_called_once() | ||
client.decr.assert_called_with('foo2') | ||
logger.gauge('foo3') | ||
client.gauge.assert_called_once() | ||
client.gauge.assert_called_with('foo3') | ||
logger.timing('foo4', 1.234) | ||
client.timing.assert_called_once() | ||
client.timing.assert_called_with('foo4', 1.234) | ||
|
||
def test_init_with_statsd_client(self): | ||
client = Mock() | ||
stats_logger = StatsdStatsLogger(statsd_client=client) | ||
self.verify_client_calls(stats_logger, client) | ||
|
||
def test_init_with_params(self): | ||
with patch('superset.stats_logger.StatsClient') as MockStatsdClient: | ||
mock_client = MockStatsdClient.return_value | ||
|
||
stats_logger = StatsdStatsLogger() | ||
self.verify_client_calls(stats_logger, mock_client) | ||
|
This file contains 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 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 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
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.
I'm not sure why this was here instead of in
requirements-dev.txt
where it seems to belong, maybe @john-bodley knows more about this.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.
For some context #4552
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.
I think
requirements-dev.txt
has simply grown to contain more than just the base requirements. If coverage will only be run as part of the CI then it makes sense to have it intox.ini
otherwiserequirements-dev.txt
makes sense.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.
@john-bodley it sounds like you have no objections, and if that's the case I'll leave it in
requirements-dev.txt
. I like to run unit tests, linter, and codecov quite often in my dev workflow, and its good to have everything in place and low friction for those quick iterative type of flows.