Commit be64af16 by Jon Ferreira Committed by Jon Ferreira

Block graph queries from being queued until annotation datasource promises resolve

parent f37a60dc
...@@ -8,6 +8,7 @@ import { makeRegions, dedupAnnotations } from './events_processing'; ...@@ -8,6 +8,7 @@ import { makeRegions, dedupAnnotations } from './events_processing';
export class AnnotationsSrv { export class AnnotationsSrv {
globalAnnotationsPromise: any; globalAnnotationsPromise: any;
alertStatesPromise: any; alertStatesPromise: any;
datasourcePromises: any;
/** @ngInject */ /** @ngInject */
constructor(private $rootScope, private $q, private datasourceSrv, private backendSrv, private timeSrv) { constructor(private $rootScope, private $q, private datasourceSrv, private backendSrv, private timeSrv) {
...@@ -18,6 +19,7 @@ export class AnnotationsSrv { ...@@ -18,6 +19,7 @@ export class AnnotationsSrv {
clearCache() { clearCache() {
this.globalAnnotationsPromise = null; this.globalAnnotationsPromise = null;
this.alertStatesPromise = null; this.alertStatesPromise = null;
this.datasourcePromises = null;
} }
getAnnotations(options) { getAnnotations(options) {
...@@ -90,6 +92,7 @@ export class AnnotationsSrv { ...@@ -90,6 +92,7 @@ export class AnnotationsSrv {
const range = this.timeSrv.timeRange(); const range = this.timeSrv.timeRange();
const promises = []; const promises = [];
const dsPromises = [];
for (const annotation of dashboard.annotations.list) { for (const annotation of dashboard.annotations.list) {
if (!annotation.enable) { if (!annotation.enable) {
...@@ -99,10 +102,10 @@ export class AnnotationsSrv { ...@@ -99,10 +102,10 @@ export class AnnotationsSrv {
if (annotation.snapshotData) { if (annotation.snapshotData) {
return this.translateQueryResult(annotation, annotation.snapshotData); return this.translateQueryResult(annotation, annotation.snapshotData);
} }
const datasourcePromise = this.datasourceSrv.get(annotation.datasource);
dsPromises.push(datasourcePromise);
promises.push( promises.push(
this.datasourceSrv datasourcePromise
.get(annotation.datasource)
.then(datasource => { .then(datasource => {
// issue query against data source // issue query against data source
return datasource.annotationQuery({ return datasource.annotationQuery({
...@@ -122,7 +125,7 @@ export class AnnotationsSrv { ...@@ -122,7 +125,7 @@ export class AnnotationsSrv {
}) })
); );
} }
this.datasourcePromises = this.$q.all(dsPromises);
this.globalAnnotationsPromise = this.$q.all(promises); this.globalAnnotationsPromise = this.$q.all(promises);
return this.globalAnnotationsPromise; return this.globalAnnotationsPromise;
} }
......
...@@ -156,7 +156,16 @@ class GraphCtrl extends MetricsPanelCtrl { ...@@ -156,7 +156,16 @@ class GraphCtrl extends MetricsPanelCtrl {
panel: this.panel, panel: this.panel,
range: this.range, range: this.range,
}); });
/* Wait for annotationSrv requests to get datasources to
* resolve before issuing queries. This allows the annotations
* service to fire annotations queries before graph queries
* (but not wait for completion). This resolves
* issue 11806.
*/
return this.annotationsSrv.datasourcePromises.then(r => {
return super.issueQueries(datasource); return super.issueQueries(datasource);
});
} }
zoomOut(evt) { zoomOut(evt) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment