Browse Source

fix(mixed data sources): fix when using two graphite data sources in mixed mode, fixes #5617

Torkel Ödegaard 9 years ago
parent
commit
ddf579f204

+ 1 - 1
public/app/plugins/datasource/graphite/datasource.ts

@@ -40,7 +40,7 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
     };
 
     if (options.panelId) {
-      httpOptions.requestId = 'panel' + options.panelId;
+      httpOptions.requestId = this.name + '.panelId.' + options.panelId;
     }
 
     return this.doGraphiteRequest(httpOptions).then(this.convertDataPointsToMs);

+ 9 - 4
public/app/plugins/datasource/graphite/specs/datasource_specs.ts

@@ -5,7 +5,7 @@ import {GraphiteDatasource} from "../datasource";
 
 describe('graphiteDatasource', function() {
   var ctx = new helpers.ServiceTestContext();
-  var instanceSettings: any = {url: ['']};
+  var instanceSettings: any = {url: [''], name: 'graphiteProd'};
 
   beforeEach(angularMocks.module('grafana.core'));
   beforeEach(angularMocks.module('grafana.services'));
@@ -24,9 +24,10 @@ describe('graphiteDatasource', function() {
 
   describe('When querying influxdb with one target using query editor target spec', function() {
     var query = {
-    rangeRaw: { from: 'now-1h', to: 'now' },
-    targets: [{ target: 'prod1.count' }, {target: 'prod2.count'}],
-    maxDataPoints: 500,
+      panelId: 3,
+      rangeRaw: { from: 'now-1h', to: 'now' },
+      targets: [{ target: 'prod1.count' }, {target: 'prod2.count'}],
+      maxDataPoints: 500,
     };
 
     var results;
@@ -46,6 +47,10 @@ describe('graphiteDatasource', function() {
       expect(requestOptions.url).to.be('/render');
     });
 
+    it('should set unique requestId', function() {
+      expect(requestOptions.requestId).to.be('graphiteProd.panelId.3');
+    });
+
     it('should query correctly', function() {
       var params = requestOptions.data.split('&');
       expect(params).to.contain('target=prod1.count');