mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 10:53:50 +08:00
Build URL params and include requestId (#65742)
* add requestId and ds_type to datasource request url
This commit is contained in:
@ -8,7 +8,11 @@ e2e.scenario({
|
|||||||
skipScenario: false,
|
skipScenario: false,
|
||||||
scenario: () => {
|
scenario: () => {
|
||||||
// Opening a dashboard without template variables
|
// Opening a dashboard without template variables
|
||||||
e2e().intercept('POST', '/api/ds/query').as('query');
|
e2e()
|
||||||
|
.intercept({
|
||||||
|
pathname: '/api/ds/query',
|
||||||
|
})
|
||||||
|
.as('query');
|
||||||
e2e.flows.openDashboard({ uid: 'ZqZnVvFZz' });
|
e2e.flows.openDashboard({ uid: 'ZqZnVvFZz' });
|
||||||
e2e().wait('@query');
|
e2e().wait('@query');
|
||||||
|
|
||||||
@ -65,7 +69,12 @@ e2e.scenario({
|
|||||||
skipScenario: false,
|
skipScenario: false,
|
||||||
scenario: () => {
|
scenario: () => {
|
||||||
// Opening a dashboard without template variables
|
// Opening a dashboard without template variables
|
||||||
e2e().intercept('POST', '/api/ds/query').as('query');
|
e2e()
|
||||||
|
.intercept({
|
||||||
|
method: 'POST',
|
||||||
|
pathname: '/api/ds/query',
|
||||||
|
})
|
||||||
|
.as('query');
|
||||||
e2e.flows.openDashboard({ uid: 'ZqZnVvFZz' });
|
e2e.flows.openDashboard({ uid: 'ZqZnVvFZz' });
|
||||||
e2e().wait('@query');
|
e2e().wait('@query');
|
||||||
|
|
||||||
@ -109,7 +118,12 @@ e2e.scenario({
|
|||||||
skipScenario: false,
|
skipScenario: false,
|
||||||
scenario: () => {
|
scenario: () => {
|
||||||
// Opening a dashboard without template variables
|
// Opening a dashboard without template variables
|
||||||
e2e().intercept('/api/ds/query').as('query');
|
e2e()
|
||||||
|
.intercept({
|
||||||
|
method: 'POST',
|
||||||
|
pathname: '/api/ds/query',
|
||||||
|
})
|
||||||
|
.as('query');
|
||||||
e2e.flows.openDashboard({ uid: 'ZqZnVvFZz' });
|
e2e.flows.openDashboard({ uid: 'ZqZnVvFZz' });
|
||||||
e2e().wait('@query');
|
e2e().wait('@query');
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ describe('Variables - Load options from Url', () => {
|
|||||||
e2e()
|
e2e()
|
||||||
.intercept({
|
.intercept({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/ds/query',
|
pathname: '/api/ds/query*',
|
||||||
})
|
})
|
||||||
.as('query');
|
.as('query');
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ describe('Variables - Load options from Url', () => {
|
|||||||
e2e()
|
e2e()
|
||||||
.intercept({
|
.intercept({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/ds/query',
|
pathname: '/api/ds/query',
|
||||||
})
|
})
|
||||||
.as('query');
|
.as('query');
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ describe('Variables - Load options from Url', () => {
|
|||||||
e2e()
|
e2e()
|
||||||
.intercept({
|
.intercept({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/ds/query',
|
pathname: '/api/ds/query',
|
||||||
})
|
})
|
||||||
.as('query');
|
.as('query');
|
||||||
|
|
||||||
|
@ -61,7 +61,11 @@ describe('Variables - Set options from ui', () => {
|
|||||||
it('adding a value that is not part of dependents options should add the new values dependant options', () => {
|
it('adding a value that is not part of dependents options should add the new values dependant options', () => {
|
||||||
e2e.flows.login('admin', 'admin');
|
e2e.flows.login('admin', 'admin');
|
||||||
e2e.flows.openDashboard({ uid: `${PAGE_UNDER_TEST}?orgId=1&var-datacenter=A&var-server=AA&var-pod=AAA` });
|
e2e.flows.openDashboard({ uid: `${PAGE_UNDER_TEST}?orgId=1&var-datacenter=A&var-server=AA&var-pod=AAA` });
|
||||||
e2e().intercept('/api/ds/query').as('query');
|
e2e()
|
||||||
|
.intercept({
|
||||||
|
pathname: '/api/ds/query',
|
||||||
|
})
|
||||||
|
.as('query');
|
||||||
|
|
||||||
e2e().wait('@query');
|
e2e().wait('@query');
|
||||||
|
|
||||||
@ -119,7 +123,7 @@ describe('Variables - Set options from ui', () => {
|
|||||||
e2e.flows.openDashboard({
|
e2e.flows.openDashboard({
|
||||||
uid: `${PAGE_UNDER_TEST}?orgId=1&var-datacenter=A&var-datacenter=B&var-server=AA&var-server=BB&var-pod=AAA&var-pod=BBB`,
|
uid: `${PAGE_UNDER_TEST}?orgId=1&var-datacenter=A&var-datacenter=B&var-server=AA&var-server=BB&var-pod=AAA&var-pod=BBB`,
|
||||||
});
|
});
|
||||||
e2e().intercept('/api/ds/query').as('query');
|
e2e().intercept({ pathname: '/api/ds/query' }).as('query');
|
||||||
|
|
||||||
e2e().wait('@query');
|
e2e().wait('@query');
|
||||||
|
|
||||||
|
@ -9,7 +9,11 @@ e2e.scenario({
|
|||||||
addScenarioDashBoard: false,
|
addScenarioDashBoard: false,
|
||||||
skipScenario: false,
|
skipScenario: false,
|
||||||
scenario: () => {
|
scenario: () => {
|
||||||
e2e().intercept('/api/ds/query').as('query');
|
e2e()
|
||||||
|
.intercept({
|
||||||
|
pathname: '/api/ds/query',
|
||||||
|
})
|
||||||
|
.as('query');
|
||||||
e2e.flows.openDashboard({ uid: 'TkZXxlNG3' });
|
e2e.flows.openDashboard({ uid: 'TkZXxlNG3' });
|
||||||
e2e().wait('@query');
|
e2e().wait('@query');
|
||||||
|
|
||||||
|
@ -11,24 +11,30 @@ describe('MySQL datasource', () => {
|
|||||||
it('code editor autocomplete should handle table name escaping/quoting', () => {
|
it('code editor autocomplete should handle table name escaping/quoting', () => {
|
||||||
e2e.flows.login('admin', 'admin');
|
e2e.flows.login('admin', 'admin');
|
||||||
|
|
||||||
e2e().intercept('POST', '**/api/ds/query', (req) => {
|
e2e().intercept(
|
||||||
if (req.body.queries[0].refId === 'datasets') {
|
'POST',
|
||||||
req.alias = 'datasets';
|
{
|
||||||
req.reply({
|
pathname: '/api/ds/query',
|
||||||
body: datasetResponse,
|
},
|
||||||
});
|
(req) => {
|
||||||
} else if (req.body.queries[0].refId === 'tables') {
|
if (req.body.queries[0].refId === 'datasets') {
|
||||||
req.alias = 'tables';
|
req.alias = 'datasets';
|
||||||
req.reply({
|
req.reply({
|
||||||
body: tablesResponse,
|
body: datasetResponse,
|
||||||
});
|
});
|
||||||
} else if (req.body.queries[0].refId === 'fields') {
|
} else if (req.body.queries[0].refId === 'tables') {
|
||||||
req.alias = 'fields';
|
req.alias = 'tables';
|
||||||
req.reply({
|
req.reply({
|
||||||
body: fieldsResponse,
|
body: tablesResponse,
|
||||||
});
|
});
|
||||||
|
} else if (req.body.queries[0].refId === 'fields') {
|
||||||
|
req.alias = 'fields';
|
||||||
|
req.reply({
|
||||||
|
body: fieldsResponse,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
e2e.pages.Explore.visit();
|
e2e.pages.Explore.visit();
|
||||||
|
|
||||||
|
@ -32,16 +32,21 @@ describe('Exemplars', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to navigate to configured data source', () => {
|
it('should be able to navigate to configured data source', () => {
|
||||||
e2e().intercept('/api/ds/query', (req) => {
|
e2e().intercept(
|
||||||
const datasourceType = req.body.queries[0].datasource.type;
|
{
|
||||||
if (datasourceType === 'prometheus') {
|
pathname: '/api/ds/query',
|
||||||
req.reply({ fixture: 'exemplars-query-response.json' });
|
},
|
||||||
} else if (datasourceType === 'tempo') {
|
(req) => {
|
||||||
req.reply({ fixture: 'tempo-response.json' });
|
const datasourceType = req.body.queries[0].datasource.type;
|
||||||
} else {
|
if (datasourceType === 'prometheus') {
|
||||||
req.reply({});
|
req.reply({ fixture: 'exemplars-query-response.json' });
|
||||||
|
} else if (datasourceType === 'tempo') {
|
||||||
|
req.reply({ fixture: 'tempo-response.json' });
|
||||||
|
} else {
|
||||||
|
req.reply({});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
e2e.pages.Explore.visit();
|
e2e.pages.Explore.visit();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ describe('DataSourceWithBackend', () => {
|
|||||||
"hideFromInspector": false,
|
"hideFromInspector": false,
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"requestId": undefined,
|
"requestId": undefined,
|
||||||
"url": "/api/ds/query",
|
"url": "/api/ds/query?ds_type=dummy",
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
@ -153,7 +153,7 @@ describe('DataSourceWithBackend', () => {
|
|||||||
"hideFromInspector": false,
|
"hideFromInspector": false,
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"requestId": undefined,
|
"requestId": undefined,
|
||||||
"url": "/api/ds/query?expression=true",
|
"url": "/api/ds/query?ds_type=dummy&expression=true",
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
@ -222,7 +222,7 @@ describe('DataSourceWithBackend', () => {
|
|||||||
"hideFromInspector": true,
|
"hideFromInspector": true,
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"requestId": undefined,
|
"requestId": undefined,
|
||||||
"url": "/api/ds/query",
|
"url": "/api/ds/query?ds_type=dummy",
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
@ -202,10 +202,16 @@ class DataSourceWithBackend<
|
|||||||
headers[PluginRequestHeaders.PluginID] = Array.from(pluginIDs).join(', ');
|
headers[PluginRequestHeaders.PluginID] = Array.from(pluginIDs).join(', ');
|
||||||
headers[PluginRequestHeaders.DatasourceUID] = Array.from(dsUIDs).join(', ');
|
headers[PluginRequestHeaders.DatasourceUID] = Array.from(dsUIDs).join(', ');
|
||||||
|
|
||||||
let url = '/api/ds/query';
|
let url = '/api/ds/query?ds_type=' + this.type;
|
||||||
|
|
||||||
if (hasExpr) {
|
if (hasExpr) {
|
||||||
headers[PluginRequestHeaders.FromExpression] = 'true';
|
headers[PluginRequestHeaders.FromExpression] = 'true';
|
||||||
url += '?expression=true';
|
url += '&expression=true';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Appending request ID to url to facilitate client-side performance metrics. See #65244 for more context.
|
||||||
|
if (requestId) {
|
||||||
|
url += `&requestId=${requestId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.dashboardUID) {
|
if (request.dashboardUID) {
|
||||||
|
Reference in New Issue
Block a user