Skip to content

Doubleclick Fast Fetch: Measure potential delay of waiting for all ad urls to be constructed#9244

Merged
keithwrightbos merged 10 commits intoampproject:masterfrom
google:a4a_sra_delay_measurement
May 10, 2017
Merged

Doubleclick Fast Fetch: Measure potential delay of waiting for all ad urls to be constructed#9244
keithwrightbos merged 10 commits intoampproject:masterfrom
google:a4a_sra_delay_measurement

Conversation

@keithwrightbos
Copy link
Copy Markdown
Contributor

In advance of adding Doubleclick Fast Fetch SRA support (see #9115), measure the amount of time between first ad slot url construction and last. This will help determine if explicit SRA (waiting for each slot to build its URL) is viable by determining the amount of delay it imposes on the first slot. Note:

  • Guarded by an experiment "'a4a-measure-get-ad-urls"
  • Only enabled for doubleclick/adsense Fast Fetch based and CSI sampling indicates data collection
  • Results in sending CSI ping

@keithwrightbos
Copy link
Copy Markdown
Contributor Author

@dvoytenko mind taking a look? I still need to create tests.

@keithwrightbos keithwrightbos self-assigned this May 10, 2017
Copy link
Copy Markdown
Contributor

@glevitzky glevitzky left a comment

Choose a reason for hiding this comment

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

LGTM. Any way to test this behavior?

Edit: Just saw your comment regarding tests.

Copy link
Copy Markdown
Contributor

@dvoytenko dvoytenko left a comment

Choose a reason for hiding this comment

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

Looks good. Couple comments.

}
const getAdUrlsPromise = [];
resources.forEach(r => getAdUrlsPromise.push(r.element.getImpl().then(
instance => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to comment:
// Note that ad url promise could be null if isValidElement returns false.

}

/**
* Returns reference to implementation after it has been built.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'd be !Promise<!./base-element.BaseElement> - promise response is non-nullable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

return;
}
this.win['a4a-measuring-ad-urls'] =
(() => resourcesForDoc(this.element).getMeasuredResources(this.win,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are you wrapping this in a closure?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

throw cancellation();
}
const getAdUrlsPromise = [];
resources.forEach(r => getAdUrlsPromise.push(r.element.getImpl().then(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use a #map.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

'sraBuildRequestDelay', {
'met.delta.AD_SLOT_ID': Math.round(
this.getNow_() - startTime),
'totalSlotCount.AD_SLOT_ID': getAdUrlsPromise.length,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: use adUrls

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

r.element.getAttribute('type') == type;
})
.then(resources => {
if (promiseId != this.promiseId_) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why does a cancellation matter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Want to ensure we don't send the CSI ping if the page was destroyed. Its arguably an edge case but see no negative.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@keithwrightbos
Copy link
Copy Markdown
Contributor Author

@jridgewell PTAL, would like to get this into today's cut. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants