mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Tempo: Add link to Tempo Search with node service selected (#49776)
* Node to tempo search with service selected * Tests * Update link text * Update test
This commit is contained in:
@@ -174,7 +174,7 @@ describe('Tempo data source', () => {
|
||||
expect(response.data[0].fields[0].values.length).toBe(3);
|
||||
|
||||
// Test Links
|
||||
expect(response.data[0].fields[0].config.links.length).toBeGreaterThan(0);
|
||||
expect(response.data[0].fields[0].config.links.length).toBe(4);
|
||||
expect(response.data[0].fields[0].config.links).toEqual(serviceGraphLinks);
|
||||
|
||||
expect(response.data[1].name).toBe('Edges');
|
||||
@@ -493,4 +493,16 @@ const serviceGraphLinks = [
|
||||
datasourceName: 'Prometheus',
|
||||
},
|
||||
},
|
||||
{
|
||||
url: '',
|
||||
title: 'View traces',
|
||||
internal: {
|
||||
query: {
|
||||
queryType: 'nativeSearch',
|
||||
serviceName: '${__data.fields[0]}',
|
||||
} as TempoQuery,
|
||||
datasourceUid: 'tempo',
|
||||
datasourceName: 'Tempo',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -202,7 +202,7 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
|
||||
}
|
||||
|
||||
if (this.serviceMap?.datasourceUid && targets.serviceMap?.length > 0) {
|
||||
subQueries.push(serviceMapQuery(options, this.serviceMap.datasourceUid));
|
||||
subQueries.push(serviceMapQuery(options, this.serviceMap.datasourceUid, this.name));
|
||||
}
|
||||
|
||||
if (targets.traceId?.length > 0) {
|
||||
@@ -396,7 +396,7 @@ function queryServiceMapPrometheus(request: DataQueryRequest<PromQuery>, datasou
|
||||
);
|
||||
}
|
||||
|
||||
function serviceMapQuery(request: DataQueryRequest<TempoQuery>, datasourceUid: string) {
|
||||
function serviceMapQuery(request: DataQueryRequest<TempoQuery>, datasourceUid: string, tempoDatasourceUid: string) {
|
||||
return queryServiceMapPrometheus(makePromServiceMapRequest(request), datasourceUid).pipe(
|
||||
// Just collect all the responses first before processing into node graph data
|
||||
toArray(),
|
||||
@@ -424,6 +424,7 @@ function serviceMapQuery(request: DataQueryRequest<TempoQuery>, datasourceUid: s
|
||||
`rate(${failedMetric}{server="\${__data.fields.id}"}[$__rate_interval])`,
|
||||
datasourceUid
|
||||
),
|
||||
makeTempoLink('View traces', `\${__data.fields[0]}`, tempoDatasourceUid),
|
||||
],
|
||||
};
|
||||
|
||||
@@ -449,6 +450,21 @@ function makePromLink(title: string, metric: string, datasourceUid: string) {
|
||||
};
|
||||
}
|
||||
|
||||
function makeTempoLink(title: string, serviceName: string, datasourceUid: string) {
|
||||
return {
|
||||
url: '',
|
||||
title,
|
||||
internal: {
|
||||
query: {
|
||||
queryType: 'nativeSearch',
|
||||
serviceName: serviceName,
|
||||
} as TempoQuery,
|
||||
datasourceUid: datasourceUid,
|
||||
datasourceName: 'Tempo',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function makePromServiceMapRequest(options: DataQueryRequest<TempoQuery>): DataQueryRequest<PromQuery> {
|
||||
return {
|
||||
...options,
|
||||
|
||||
Reference in New Issue
Block a user