mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Jaeger: Add support for traceID field to accept variables. (#45559)
This commit is contained in:
@@ -159,6 +159,32 @@ describe('JaegerDatasource', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should resolve templates in traceID', async () => {
|
||||||
|
const mock = setupFetchMock({ data: [testResponse] });
|
||||||
|
const ds = new JaegerDatasource(defaultSettings, timeSrvStub);
|
||||||
|
|
||||||
|
await lastValueFrom(
|
||||||
|
ds.query({
|
||||||
|
...defaultQuery,
|
||||||
|
scopedVars: {
|
||||||
|
$traceid: {
|
||||||
|
text: 'traceid',
|
||||||
|
value: '5311b0dd0ca8df3463df93c99cb805a6',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
targets: [
|
||||||
|
{
|
||||||
|
query: '$traceid',
|
||||||
|
refId: '1',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(mock).toBeCalledWith({
|
||||||
|
url: `${defaultSettings.url}/api/traces/5311b0dd0ca8df3463df93c99cb805a6`,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should resolve templates in tags', async () => {
|
it('should resolve templates in tags', async () => {
|
||||||
const mock = setupFetchMock({ data: [testResponse] });
|
const mock = setupFetchMock({ data: [testResponse] });
|
||||||
const ds = new JaegerDatasource(defaultSettings, timeSrvStub);
|
const ds = new JaegerDatasource(defaultSettings, timeSrvStub);
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ export class JaegerDatasource extends DataSourceApi<JaegerQuery, JaegerJsonData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target.queryType !== 'search' && target.query) {
|
if (target.queryType !== 'search' && target.query) {
|
||||||
return this._request(`/api/traces/${encodeURIComponent(target.query)}`).pipe(
|
return this._request(
|
||||||
|
`/api/traces/${encodeURIComponent(getTemplateSrv().replace(target.query, options.scopedVars))}`
|
||||||
|
).pipe(
|
||||||
map((response) => {
|
map((response) => {
|
||||||
const traceData = response?.data?.data?.[0];
|
const traceData = response?.data?.data?.[0];
|
||||||
if (!traceData) {
|
if (!traceData) {
|
||||||
|
|||||||
Reference in New Issue
Block a user