Closed
Bug 1357001
Opened 7 years ago
Closed 7 years ago
Improve Telemetry python script errors
Categories
(Toolkit :: Telemetry, enhancement, P1)
Toolkit
Telemetry
Tracking
()
RESOLVED
FIXED
mozilla55
Tracking | Status | |
---|---|---|
firefox55 | --- | fixed |
People
(Reporter: gfritzsche, Assigned: gfritzsche)
Details
(Whiteboard: [measurement:client])
Attachments
(5 files, 3 obsolete files)
9.95 KB,
patch
|
chutten
:
review+
|
Details | Diff | Splinter Review |
11.46 KB,
patch
|
chutten
:
review+
|
Details | Diff | Splinter Review |
25.22 KB,
patch
|
chutten
:
review+
|
Details | Diff | Splinter Review |
48.78 KB,
patch
|
gfritzsche
:
review+
|
Details | Diff | Splinter Review |
21.08 KB,
patch
|
gfritzsche
:
review+
|
Details | Diff | Splinter Review |
Currently we throw errors from the histogram, scalar & event parsing python scripts when a condition is not met. This produces hard to read errors. We should refactor this to show clear error messages while still failing the build. We may want to merge the probe-scraper updates into m-c [1] before this, to avoid further rebasing pain later. 1: https://github.com/mozilla/probe-scraper/issues/6
Assignee | ||
Comment 1•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → gfritzsche
Priority: P2 → P1
Comment 2•7 years ago
|
||
Comment on attachment 8858770 [details] [diff] [review] First cut Review of attachment 8858770 [details] [diff] [review]: ----------------------------------------------------------------- Some notes. ::: toolkit/components/telemetry/Histograms.json @@ +5,5 @@ > "description": "has accessibility support been instantiated" > }, > "A11Y_CONSUMERS": { > "expires_in_version": "default", > + "kind": "count", Uh... I don't think this is allowed. ::: toolkit/components/telemetry/gen-histogram-data.py @@ +180,5 @@ > def main(output, *filenames): > + try: > + histograms = list(histogram_tools.from_files(filenames)) > + except histogram_tools.BuildError as ex: > + print("\nError processing histograms:\n" + str(ex) + "\n") Can we be more specific? "Error processes histograms when generating histogram data: " ::: toolkit/components/telemetry/gen-histogram-enum.py @@ +45,5 @@ > # Load the histograms. > + try: > + all_histograms = list(histogram_tools.from_files(filenames)) > + except histogram_tools.BuildError as ex: > + print("\nError processing histograms:\n" + str(ex) + "\n") Ditto: "Error processing histograms when generating histogram enum: " ::: toolkit/components/telemetry/histogram_tools.py @@ +453,5 @@ > definition['n_buckets']) > > > # This hook function loads the histograms into an OrderedDict. > +# It will raise a Exception if duplicate keys are found. It raises a BuildError, specifically. @@ +471,5 @@ > def from_Histograms_json(filename): > with open(filename, 'r') as f: > try: > histograms = json.load(f, object_pairs_hook=load_histograms_into_dict) > except ValueError, e: This change is all about removing the ValueErrors, no?
Assignee | ||
Comment 3•7 years ago
|
||
(In reply to Chris H-C :chutten from comment #2) > Comment on attachment 8858770 [details] [diff] [review] > First cut > > Review of attachment 8858770 [details] [diff] [review]: > ----------------------------------------------------------------- > > Some notes. This was a WIP patch, no need to review yet.
Assignee | ||
Comment 4•7 years ago
|
||
Assignee | ||
Comment 5•7 years ago
|
||
Assignee | ||
Comment 6•7 years ago
|
||
Assignee | ||
Comment 7•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Attachment #8858770 -
Attachment is obsolete: true
Assignee | ||
Comment 8•7 years ago
|
||
Assignee | ||
Comment 9•7 years ago
|
||
Comment on attachment 8859245 [details] [diff] [review] Part 1 - Unify validation errors in probe parsing scripts @gps: Looking at the pattern used in e.g. gen-histogram-data.py, does that look good for you from a build perspective? The motivation here is to stop throwing exception stacks at developers for errors in Histograms.json, instead giving them only clear error messages. So i'm changing the Telemetry build scripts to do the following on errors: - print error messages with N lines and (just `print()` them) - fail the build (using `sys.exit(1)`)
Attachment #8859245 -
Flags: review?(chutten)
Attachment #8859245 -
Flags: feedback?(gps)
Assignee | ||
Comment 10•7 years ago
|
||
Comment on attachment 8859246 [details] [diff] [review] Part 2 - Make histogram error message style more consistent Besides fixing the messages, i also removed the table_dispatch() helper. It was giving a very unspecific error message, which seems to better fit on the callers side. Looking through its uses, i still find table_dispatch() rather hard to read and don't see big value in it. So i decided to just remove it and refactor table handling a bit.
Attachment #8859246 -
Flags: review?(chutten)
Comment 11•7 years ago
|
||
Comment on attachment 8859245 [details] [diff] [review] Part 1 - Unify validation errors in probe parsing scripts Review of attachment 8859245 [details] [diff] [review]: ----------------------------------------------------------------- Seems straightforward enough. ::: toolkit/components/telemetry/histogram_tools.py @@ +451,5 @@ > definition['n_buckets']) > > > # This hook function loads the histograms into an OrderedDict. > +# It will raise a Exception if duplicate keys are found. May as well say ParserError, no?
Attachment #8859245 -
Flags: review?(chutten) → review+
Assignee | ||
Updated•7 years ago
|
Attachment #8859247 -
Flags: review?(chutten)
Assignee | ||
Updated•7 years ago
|
Attachment #8859248 -
Flags: review?(chutten)
Assignee | ||
Updated•7 years ago
|
Attachment #8860394 -
Flags: review?(chutten)
Assignee | ||
Comment 12•7 years ago
|
||
(In reply to Georg Fritzsche [:gfritzsche] from comment #8) > Created attachment 8860394 [details] [diff] [review] > Part 5 - Fix linting errors I should roll this into the other patches, but that would mean a lot of re-basing for the later ones.
Comment 13•7 years ago
|
||
Comment on attachment 8859246 [details] [diff] [review] Part 2 - Make histogram error message style more consistent Review of attachment 8859246 [details] [diff] [review]: ----------------------------------------------------------------- I don't think you should remove table_dispatch. It's been running fine since it was introduced. If you feel it must go, at least split it into its own commit. It has little to do with the error message improvements going on in this patch. ::: toolkit/components/telemetry/gen-histogram-data.py @@ +129,5 @@ > > for histogram in histograms: > + kind = histogram.kind() > + if not kind in table: > + raise Exception('Unknown kind "%s" for histogram "%s".' % (kind, histogram.name())) You're switching from ParserError to Exception. Deliberately?
Attachment #8859246 -
Flags: review?(chutten) → review-
Updated•7 years ago
|
Attachment #8859247 -
Flags: review?(chutten) → review+
Updated•7 years ago
|
Attachment #8859248 -
Flags: review?(chutten) → review+
Updated•7 years ago
|
Attachment #8860394 -
Flags: review?(chutten) → review+
Comment 14•7 years ago
|
||
Comment on attachment 8859245 [details] [diff] [review] Part 1 - Unify validation errors in probe parsing scripts Review of attachment 8859245 [details] [diff] [review]: ----------------------------------------------------------------- This is fine. With the exception of raising BaseException, you could have done the same thing by adding "except Exception" everywhere you now use "except ParseError." But it's good practice to have a dedicated error type. So how this is implemented definitely isn't wrong. ::: toolkit/components/telemetry/histogram_tools.py @@ -86,5 @@ > whitelists = json.load(f) > for name, whitelist in whitelists.iteritems(): > whitelists[name] = set(whitelist) > except ValueError, e: > - raise BaseException('error parsing whitelist (%s)' % whitelist_path) BaseException should never be raised directly. Raise Exception for a generic error instead. The reason is special exceptions like KeyboardInterrupt, SystemExit, and GeneratorExit inherit from BaseException whereas Exception is in a different tree from these special exceptions. A catch-almost-everything exception handler is written as "except Exception" so it doesn't catch these special exceptions. The bareword "except:" catches BaseException which can lead to e.g. swallowing ^C requests.
Attachment #8859245 -
Flags: feedback?(gps) → feedback+
Assignee | ||
Comment 15•7 years ago
|
||
(In reply to Chris H-C :chutten from comment #13) > I don't think you should remove table_dispatch. It's been running fine since > it was introduced. > > If you feel it must go, at least split it into its own commit. It has little > to do with the error message improvements going on in this patch. My main problem is that we want specific error messages across the code. Also passing error messages as parameters i don't see the value of this function anymore. I wonder what this gains us over just putting the three lines at the caller site. If instead i just put those three lines at the caller site, i don't have to look up anymore what this function does (i regularly do that). Any better suggestions for the error message and readability?
Flags: needinfo?(chutten)
Assignee | ||
Comment 16•7 years ago
|
||
(In reply to Chris H-C :chutten from comment #13) > ::: toolkit/components/telemetry/gen-histogram-data.py > @@ +129,5 @@ > > > > for histogram in histograms: > > + kind = histogram.kind() > > + if not kind in table: > > + raise Exception('Unknown kind "%s" for histogram "%s".' % (kind, histogram.name())) > > You're switching from ParserError to Exception. Deliberately? Yes - i've been using ParserError for "error message for parsing/validation failures the user needs to see and possibly fix". Not finding the `kind` here in the table is a programming error that we might want to see a stack for, so i don't think this should be a ParserError.
Comment 17•7 years ago
|
||
Comment on attachment 8859246 [details] [diff] [review] Part 2 - Make histogram error message style more consistent Review of attachment 8859246 [details] [diff] [review]: ----------------------------------------------------------------- Very well.
Attachment #8859246 -
Flags: review- → review+
Updated•7 years ago
|
Flags: needinfo?(chutten)
Assignee | ||
Comment 18•7 years ago
|
||
Assignee | ||
Comment 19•7 years ago
|
||
Assignee | ||
Updated•7 years ago
|
Attachment #8862602 -
Attachment description: Part 1 - Unify validation errors in probe parsing scripts. f=gps → Part 1 - Unify validation errors in probe parsing scripts. r=chutten, f=gps
Attachment #8862602 -
Flags: review+
Assignee | ||
Updated•7 years ago
|
Attachment #8862603 -
Attachment description: Part 2 - Make histogram error message style more consistent → Part 2 - Make histogram error message style more consistent. r=chutten
Attachment #8862603 -
Flags: review+
Assignee | ||
Updated•7 years ago
|
Attachment #8859245 -
Attachment is obsolete: true
Assignee | ||
Updated•7 years ago
|
Attachment #8859246 -
Attachment is obsolete: true
Assignee | ||
Updated•7 years ago
|
Keywords: checkin-needed
Comment 20•7 years ago
|
||
Pushed by cbook@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/29237e2192a9 Part 1 - Unify validation errors in probe parsing scripts. r=chutten, f=gps https://hg.mozilla.org/integration/mozilla-inbound/rev/a73ed8eaedf9 Part 2 - Make histogram error message style more consistent. r=chutten https://hg.mozilla.org/integration/mozilla-inbound/rev/c55c6f471cfb Part 3 - Make scalar error messages style more consistent. r=chutten https://hg.mozilla.org/integration/mozilla-inbound/rev/b439880e27a1 Part 4 - Make event error messages style more consistent. r=chutten https://hg.mozilla.org/integration/mozilla-inbound/rev/5cf54ffdded1 Part 5 - Fix linting errors. r=chutten
Keywords: checkin-needed
Comment 21•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/29237e2192a9 https://hg.mozilla.org/mozilla-central/rev/a73ed8eaedf9 https://hg.mozilla.org/mozilla-central/rev/c55c6f471cfb https://hg.mozilla.org/mozilla-central/rev/b439880e27a1 https://hg.mozilla.org/mozilla-central/rev/5cf54ffdded1
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in
before you can comment on or make changes to this bug.
Description
•