Skip to content

Initialize transport service in Performance Monitoring when performance() is called. #2506

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

Merged
merged 4 commits into from
Jan 9, 2020

Conversation

zijianjoy
Copy link
Contributor

  1. Rename cc_service to transport_service since we expect migration to Firelog service in the future.
  2. transport_service.ts used to start setTimeout() when this file is loaded. This change wraps it into initialization function, which should be called when performance() is called (it is when developer activates Performance Monitoring component).
  3. Update testing to call useFakeTimers() inside describe() instead of before loading transport_service.ts.

Copy link
Contributor

@hsubox76 hsubox76 left a comment

Choose a reason for hiding this comment

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

Tests look great, thanks!

One nit, please feel free to ignore if this is out of scope, but there are some ongoing TS errors (from before this change) on oob_resources_services.test.ts, would it be possible to add //@ts-ignore Assignment to read-only property. lines above the two assignments to api.onFirstInputDelay in that file, to get rid of the console errors when running perf tests?

@@ -17,7 +17,7 @@

import { stub, SinonStub, useFakeTimers, SinonFakeTimers } from 'sinon';
import { Trace } from '../resources/trace';
import * as ccService from './cc_service';
import * as ccService from './transport_service';
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are replacing all the context of CC to Transport, should we import it as transportService instead of ccService?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, thank you!

Copy link
Contributor

@visumickey visumickey left a comment

Choose a reason for hiding this comment

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

Changes look good to me (Logically). Might need some syntactic approval from others.

fetchStub.restore();
});

it('throws an error when logging an empty message', done => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think the "done" is doing much here. It is usually used for callback based async code. Here adding a done at the end of the main block does not accomplish much.
https://mochajs.org/#asynchronous-code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed for not async test.

@@ -27,6 +28,7 @@ export function setupOobResources(): void {
if (!getIid()) {
return;
}
setupTransportService();
Copy link
Contributor

Choose a reason for hiding this comment

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

setupOobResources is called when the call to get iid and RC is responsed. Starting the transport cycle here means that the initial time of sending logs is "iid call + RC call + 5.5s". I suggest not including those calls in the initial delay to avoid it from being undeterministic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved initialization call to controllers/perf.ts.

@zijianjoy zijianjoy merged commit 9c28e7b into master Jan 9, 2020
@hsubox76 hsubox76 added this to the next milestone Jan 9, 2020
@firebase firebase locked and limited conversation to collaborators Feb 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants