mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 11:02:13 +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,
|
||||
scenario: () => {
|
||||
// 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().wait('@query');
|
||||
|
||||
@ -65,7 +69,12 @@ e2e.scenario({
|
||||
skipScenario: false,
|
||||
scenario: () => {
|
||||
// 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().wait('@query');
|
||||
|
||||
@ -109,7 +118,12 @@ e2e.scenario({
|
||||
skipScenario: false,
|
||||
scenario: () => {
|
||||
// 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().wait('@query');
|
||||
|
||||
|
@ -9,7 +9,7 @@ describe('Variables - Load options from Url', () => {
|
||||
e2e()
|
||||
.intercept({
|
||||
method: 'POST',
|
||||
url: '/api/ds/query',
|
||||
pathname: '/api/ds/query*',
|
||||
})
|
||||
.as('query');
|
||||
|
||||
@ -61,7 +61,7 @@ describe('Variables - Load options from Url', () => {
|
||||
e2e()
|
||||
.intercept({
|
||||
method: 'POST',
|
||||
url: '/api/ds/query',
|
||||
pathname: '/api/ds/query',
|
||||
})
|
||||
.as('query');
|
||||
|
||||
@ -124,7 +124,7 @@ describe('Variables - Load options from Url', () => {
|
||||
e2e()
|
||||
.intercept({
|
||||
method: 'POST',
|
||||
url: '/api/ds/query',
|
||||
pathname: '/api/ds/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', () => {
|
||||
e2e.flows.login('admin', 'admin');
|
||||
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');
|
||||
|
||||
@ -119,7 +123,7 @@ describe('Variables - Set options from ui', () => {
|
||||
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`,
|
||||
});
|
||||
e2e().intercept('/api/ds/query').as('query');
|
||||
e2e().intercept({ pathname: '/api/ds/query' }).as('query');
|
||||
|
||||
e2e().wait('@query');
|
||||
|
||||
|
@ -9,7 +9,11 @@ e2e.scenario({
|
||||
addScenarioDashBoard: false,
|
||||
skipScenario: false,
|
||||
scenario: () => {
|
||||
e2e().intercept('/api/ds/query').as('query');
|
||||
e2e()
|
||||
.intercept({
|
||||
pathname: '/api/ds/query',
|
||||
})
|
||||
.as('query');
|
||||
e2e.flows.openDashboard({ uid: 'TkZXxlNG3' });
|
||||
e2e().wait('@query');
|
||||
|
||||
|
@ -11,7 +11,12 @@ describe('MySQL datasource', () => {
|
||||
it('code editor autocomplete should handle table name escaping/quoting', () => {
|
||||
e2e.flows.login('admin', 'admin');
|
||||
|
||||
e2e().intercept('POST', '**/api/ds/query', (req) => {
|
||||
e2e().intercept(
|
||||
'POST',
|
||||
{
|
||||
pathname: '/api/ds/query',
|
||||
},
|
||||
(req) => {
|
||||
if (req.body.queries[0].refId === 'datasets') {
|
||||
req.alias = 'datasets';
|
||||
req.reply({
|
||||
@ -28,7 +33,8 @@ describe('MySQL datasource', () => {
|
||||
body: fieldsResponse,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
e2e.pages.Explore.visit();
|
||||
|
||||
|
@ -32,7 +32,11 @@ describe('Exemplars', () => {
|
||||
});
|
||||
|
||||
it('should be able to navigate to configured data source', () => {
|
||||
e2e().intercept('/api/ds/query', (req) => {
|
||||
e2e().intercept(
|
||||
{
|
||||
pathname: '/api/ds/query',
|
||||
},
|
||||
(req) => {
|
||||
const datasourceType = req.body.queries[0].datasource.type;
|
||||
if (datasourceType === 'prometheus') {
|
||||
req.reply({ fixture: 'exemplars-query-response.json' });
|
||||
@ -41,7 +45,8 @@ describe('Exemplars', () => {
|
||||
} else {
|
||||
req.reply({});
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
e2e.pages.Explore.visit();
|
||||
|
||||
|
@ -98,7 +98,7 @@ describe('DataSourceWithBackend', () => {
|
||||
"hideFromInspector": false,
|
||||
"method": "POST",
|
||||
"requestId": undefined,
|
||||
"url": "/api/ds/query",
|
||||
"url": "/api/ds/query?ds_type=dummy",
|
||||
}
|
||||
`);
|
||||
});
|
||||
@ -153,7 +153,7 @@ describe('DataSourceWithBackend', () => {
|
||||
"hideFromInspector": false,
|
||||
"method": "POST",
|
||||
"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,
|
||||
"method": "POST",
|
||||
"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.DatasourceUID] = Array.from(dsUIDs).join(', ');
|
||||
|
||||
let url = '/api/ds/query';
|
||||
let url = '/api/ds/query?ds_type=' + this.type;
|
||||
|
||||
if (hasExpr) {
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user