Commit 9d01b216 by Marcus Efraimsson Committed by GitHub

prometheus: fix regression after adding support for tracing headers (#16829)

This fixes a regression introduced by #16724 when datasource is configured
to use HTTP method POST and testing the datasource which results in an
'options.headers is undefined'. Same error probably happens if datasource
is configured to use basic auth and testing datasource.
parent 157f330c
......@@ -72,6 +72,7 @@ export class PrometheusDatasource implements DataSourceApi<PromQuery> {
options = _.defaults(options || {}, {
url: this.url + url,
method: this.httpMethod,
headers: {},
});
if (options.method === 'GET') {
......
......@@ -57,6 +57,7 @@ describe('PrometheusMetricFindQuery', () => {
method: 'GET',
url: 'proxied/api/v1/labels',
silent: true,
headers: {},
});
});
......@@ -75,6 +76,7 @@ describe('PrometheusMetricFindQuery', () => {
method: 'GET',
url: 'proxied/api/v1/label/resource/values',
silent: true,
headers: {},
});
});
......@@ -97,6 +99,7 @@ describe('PrometheusMetricFindQuery', () => {
method: 'GET',
url: `proxied/api/v1/series?match[]=metric&start=${raw.from.unix()}&end=${raw.to.unix()}`,
silent: true,
headers: {},
});
});
......@@ -121,6 +124,7 @@ describe('PrometheusMetricFindQuery', () => {
'metric{label1="foo", label2="bar", label3="baz"}'
)}&start=${raw.from.unix()}&end=${raw.to.unix()}`,
silent: true,
headers: {},
});
});
......@@ -145,6 +149,7 @@ describe('PrometheusMetricFindQuery', () => {
method: 'GET',
url: `proxied/api/v1/series?match[]=metric&start=${raw.from.unix()}&end=${raw.to.unix()}`,
silent: true,
headers: {},
});
});
......@@ -163,6 +168,7 @@ describe('PrometheusMetricFindQuery', () => {
method: 'GET',
url: 'proxied/api/v1/label/__name__/values',
silent: true,
headers: {},
});
});
......@@ -190,6 +196,7 @@ describe('PrometheusMetricFindQuery', () => {
method: 'GET',
url: `proxied/api/v1/query?query=metric&time=${raw.to.unix()}`,
requestId: undefined,
headers: {},
});
});
......@@ -217,6 +224,7 @@ describe('PrometheusMetricFindQuery', () => {
'up{job="job1"}'
)}&start=${raw.from.unix()}&end=${raw.to.unix()}`,
silent: true,
headers: {},
});
});
});
......
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