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
[explore] Fix and test slice id logging issue #3339
Merged
mistercrunch
merged 17 commits into
apache:master
from
timifasubaa:fix__slice_id__logging__issue
Aug 24, 2017
Merged
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3ae2ae5
[explore] fixed padding bug on filter section
timifasubaa ce0adb3
Merge branch 'master' of https://github.com/apache/incubator-superset
timifasubaa d59d95b
merge from upstream
timifasubaa 183c108
fix slice_id logging issue
timifasubaa 78732d9
[superset-sqllab] fix slice_id population in appropriate column
timifasubaa a638978
[explore-logging] test the slice_id logging fix
timifasubaa 8e80b7f
fix travis errors
timifasubaa 9a74baa
fix nits pointed out in PR comments
timifasubaa 8f5d9c8
cleanup tests
timifasubaa d825933
made python more beautiful
timifasubaa cfe69a2
made python even more beautiful
timifasubaa 942b3bc
made python even more more beautiful
timifasubaa 9d254a4
made python even more more more beautiful
timifasubaa 84d49bd
fix lint error
timifasubaa 1d4b5d7
make exception handling more specific
timifasubaa b4aa907
fixed silly error
timifasubaa c6036ac
fixed argument indentation
timifasubaa File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -761,24 +761,26 @@ def wrapper(*args, **kwargs): | |
post_data = request.form or {} | ||
d.update(post_data) | ||
d.update(kwargs) | ||
slice_id = d.get('slice_id', 0) | ||
slice_id = d.get('slice_id') | ||
form_data = d.get('form_data') | ||
|
||
try: | ||
slice_id = int(slice_id) if slice_id else 0 | ||
except ValueError: | ||
slice_id = int(d.get('slice_id') or json.loads(d.get('form_data')).get('slice_id')) | ||
except Exception: | ||
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. Please remove blind exceptions, You only need ValueError and TypeError |
||
slice_id = 0 | ||
|
||
params = "" | ||
try: | ||
params = json.dumps(d) | ||
except: | ||
pass | ||
stats_logger.incr(f.__name__) | ||
value = f(*args, **kwargs) | ||
|
||
sesh = db.session() | ||
log = cls( | ||
action=f.__name__, | ||
json=params, | ||
dashboard_id=d.get('dashboard_id') or None, | ||
dashboard_id=d.get('dashboard_id'), | ||
slice_id=slice_id, | ||
duration_ms=( | ||
datetime.now() - start_dttm).total_seconds() * 1000, | ||
|
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.
Isn't this ugly? You have slice_id and form_data already unpacked before and you are not using them here. That would make the code a lot more readable.
Also blind exceptions are an antipattern. If you want to go this route just catch TypeError and ValueError
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.
Would yo prefer that I break it out in the if else style I had before that doesn't use exception for flow control? I am trying out the ValueError and TypeError approach now.