Skip to content
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

fix: only record a trace if needed by an audit #2117

Merged
merged 4 commits into from
May 3, 2017

Conversation

patrickhulce
Copy link
Collaborator

fixes #2088

needs coordination with #2062 and #2104

@paulirish
Copy link
Member

love it. can you add a quick test?

@patrickhulce
Copy link
Collaborator Author

done

@brendankenny
Copy link
Member

is it going to be weird that this only runs when creating a config with onlyCategories and/or onlyAudits? So a completely custom config won't get it (unless you're both writing your own and whitelisting).

Also should we provide an escape hatch if you want to override this and record a trace (e.g. if you're doing --save-artifacts/assets to get a trace saved?)

@patrickhulce
Copy link
Collaborator Author

is it going to be weird that this only runs when creating a config with onlyCategories and/or onlyAudits? So a completely custom config won't get it (unless you're both writing your own and whitelisting).

Seems fine to me, if you're explicitly including a trace without a reason, we shouldn't stand in your way.

Also should we provide an escape hatch if you want to override this and record a trace (e.g. if you're doing --save-artifacts/assets to get a trace saved?)

Yeah I was slightly worried about this and other scenarios that you might sneakily consume a trace through unofficial channels or something. I'd prefer to leave that an outstanding issue until we add unification of CLI and config flags in settings which I hope to start/finish/allnighter sometime before I/O :D

@paulirish
Copy link
Member

aye. If you really want a trace, then including user-timings audit doesn't seem all that bad.

@brendankenny
Copy link
Member

Seems fine to me, if you're explicitly including a trace without a reason, we shouldn't stand in your way.

I guess I meant weird the other way, that you could get a trace even if an audit didn't need one in your own config, but if you extend that config and whitelist everything suddenly it's gone

@brendankenny
Copy link
Member

I'd be ok with waiting for the great settings/flags rationalization, but maybe add a log.warn here for now? Slightly easier to figure out when wondering where your trace is.

@patrickhulce
Copy link
Collaborator Author

I'd be ok with waiting for the great settings/flags rationalization, but maybe add a log.warn here for now? Slightly easier to figure out when wondering where your trace is.

yeah good call on ⚠️

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


// disable the trace if no audit requires a trace
if (pass.recordTrace && !auditsNeedTrace) {
log.warn('config', `Trace not requested by an audit, dropping trace in ${pass.passName}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only issue with this is that validatePasses hasn't run yet, so the pass might not have a passName (and we allow no name if there's only one unnamed pass, at which point it should be DEFAULT_PASS...ugh)

Maybe 'Trace not requested by an audit, dropping trace in pass '${pass.passName}'' so at least they get a pass 'undefined'? :)

(we should figure out ordering on that at some point, too. Makes sense to validate at the end, so the actual config that's going to be run is sure to be valid, but input is also supposed to be valid so...validate twice?)

it('filtering filters out traces when not needed', () => {
const warnings = [];
const saveWarning = evt => warnings.push(evt);
log.events.addListener('warning', saveWarning);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove listener when finished?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@paulirish paulirish merged commit ff21a33 into master May 3, 2017
@paulirish paulirish deleted the only_trace_if_needed branch May 3, 2017 00:47
paulirish pushed a commit to paulirish/lighthouse that referenced this pull request May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Just running Accessibility category shouldn't record a trace
3 participants