Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

empty all queues in reporterProxy once data has been sent. #1659

Merged
merged 1 commit into from
Aug 22, 2018

Conversation

annthurium
Copy link

Description of the Change

Recently, I was working on some improvements to the welcome package in atom/welcome#67. I noticed that the welcome package, which also consumes the reporter service, empties all queues after the reporter has been set. I believe the queues are emptied to guard against the possibility of the queued data being sent again if the reporter service is re-set.

This change empties the queues in the github package's ReporterProxy after data has been sent. This change also adds unit tests to verify this new functionality works as expected.

Alternate Designs

Is re-sending the same data actually something we need to worry about?

I tried to reproduce a situation where data might be re-sent to see if this is really a problem. I put a setTimeout in the metrics package so that it loads in a deferred fashion, and performed some actions that are instrumented (staging and unstaging changes). This adds data to the queues before the reporter has been set. It appears that a new ReporterProxy class is created in memory each time Atom reloads, so old events sticking around isn't a problem. However, I'm not super confident that I'm testing this in the same conditions that would occur in the wild. Clearing the queues is a simple enough change that I'd just rather do this and put any lingering worries to rest about the accuracy of our data.

Benefits

Guard against the possibility that we are re-sending data that has already been sent, which keeps our metrics accurate.

Possible Drawbacks

I can't think of any but am open to feedback.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 80.204% when pulling 55831d8 on tt-18-aug-queues into 784c17b on master.

@annthurium annthurium merged commit dfcfc64 into master Aug 22, 2018
@annthurium annthurium deleted the tt-18-aug-queues branch August 22, 2018 23:51
@@ -109,6 +109,11 @@ describe('reporterProxy', function() {
assert.deepEqual(addTimingArgs[2], {gitHubPackageVersion: version});

assert.deepEqual(incrementCounterStub.lastCall.args, [counterName]);

assert.deepEqual(reporterProxy.events.length, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

For future reference: you can do assert.lengthOf(thing, 0) to get a slightly more informative error message when it fails. 🌠

Copy link
Author

Choose a reason for hiding this comment

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

oh, thanks! I'll clean this up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Haha that wasn't meant as "you have to fix this"! It was just a random note because I'm tired 👀

Copy link
Author

Choose a reason for hiding this comment

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

totally, didn't think you meant it that way, just want to get in the habit of using better assertions <3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants