Add reporting of checks fetch latency
Change-Id: I0455409e593f7fff68fce83404f917834ad677d7
diff --git a/polygerrit-ui/app/services/app-context-init.ts b/polygerrit-ui/app/services/app-context-init.ts
index dab894e..9af86d2 100644
--- a/polygerrit-ui/app/services/app-context-init.ts
+++ b/polygerrit-ui/app/services/app-context-init.ts
@@ -73,7 +73,7 @@
authService: () => new Auth(appContext.eventEmitter),
restApiService: () => new GrRestApiInterface(appContext.authService),
changeService: () => new ChangeService(),
- checksService: () => new ChecksService(),
+ checksService: () => new ChecksService(appContext.reportingService),
jsApiService: () => new GrJsApiInterface(),
storageService: () => new GrStorageService(),
configService: () => new ConfigService(),
diff --git a/polygerrit-ui/app/services/checks/checks-service.ts b/polygerrit-ui/app/services/checks/checks-service.ts
index 250cea5..c517fb89 100644
--- a/polygerrit-ui/app/services/checks/checks-service.ts
+++ b/polygerrit-ui/app/services/checks/checks-service.ts
@@ -54,6 +54,7 @@
import {getCurrentRevision} from '../../utils/change-util';
import {getShaByPatchNum} from '../../utils/patch-set-util';
import {assertIsDefined} from '../../utils/common-util';
+import {ReportingService} from '../gr-reporting/gr-reporting';
export class ChecksService {
private readonly providers: {[name: string]: ChecksProvider} = {};
@@ -64,7 +65,7 @@
private readonly documentVisibilityChange$ = new BehaviorSubject(undefined);
- constructor() {
+ constructor(readonly reporting: ReportingService) {
checkToPluginMap$.subscribe(map => {
this.checkToPluginMap = map;
});
@@ -150,8 +151,7 @@
commmitMessage: getCurrentRevision(change)?.commit?.message,
changeInfo: change,
};
- updateStateSetLoading(pluginName);
- return from(this.providers[pluginName].fetch(data));
+ return this.fetchResults(pluginName, data);
}
),
catchError(e => {
@@ -183,4 +183,16 @@
}
});
}
+
+ private fetchResults(pluginName: string, data: ChangeData) {
+ updateStateSetLoading(pluginName);
+ const timer = this.reporting.getTimer('ChecksPluginFetch');
+ const fetchPromise = this.providers[pluginName]
+ .fetch(data)
+ .then(response => {
+ timer.end({pluginName});
+ return response;
+ });
+ return from(fetchPromise);
+ }
}
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
index d7081ce..bbdb02a 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
@@ -24,7 +24,7 @@
export interface Timer {
reset(): this;
- end(): this;
+ end(eventDetails?: EventDetails): this;
withMaximum(maximum: number): this;
}
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
index 5fd4234..4e6ece2 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
@@ -713,7 +713,7 @@
},
// Stop the timer and report the intervening time.
- end: () => {
+ end: (eventDetails?: EventDetails) => {
if (called) {
throw new Error(`Timer for "${name}" already ended.`);
}
@@ -725,7 +725,7 @@
return timer;
}
- this._reportTiming(name, time);
+ this._reportTiming(name, time, eventDetails);
return timer;
},