Tempo: Update service graph linked queries from totals to rates (#43866)

* Tempo: Update service graph linked queries from totals to rates

* Interpolate server name and interval
This commit is contained in:
Connor Lindsey 2022-01-13 08:28:20 -07:00 committed by GitHub
parent 55ec05b560
commit 17f7f0dc93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 2 deletions

View File

@ -106,7 +106,10 @@ describe('Tempo data source', () => {
expect(response.data).toHaveLength(2);
expect(response.data[0].name).toBe('Nodes');
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).toEqual(serviceGraphLinks);
expect(response.data[1].name).toBe('Edges');
expect(response.data[1].fields[0].values.length).toBe(2);
@ -337,3 +340,28 @@ const mockInvalidJson = {
},
],
};
const serviceGraphLinks = [
{
url: '',
title: 'Request rate',
internal: {
query: {
expr: 'rate(traces_service_graph_request_total{server="${__data.fields.id}"}[$__interval])',
},
datasourceUid: 'prom',
datasourceName: 'Prometheus',
},
},
{
url: '',
title: 'Failed request rate',
internal: {
query: {
expr: 'rate(traces_service_graph_request_failed_total{server="${__data.fields.id}"}[$__interval])',
},
datasourceUid: 'prom',
datasourceName: 'Prometheus',
},
},
];

View File

@ -313,8 +313,16 @@ function serviceMapQuery(request: DataQueryRequest<TempoQuery>, datasourceUid: s
const { nodes, edges } = mapPromMetricsToServiceMap(responses, request.range);
nodes.fields[0].config = {
links: [
makePromLink('Total requests', totalsMetric, datasourceUid),
makePromLink('Failed requests', failedMetric, datasourceUid),
makePromLink(
'Request rate',
`rate(${totalsMetric}{server="\${__data.fields.id}"}[$__interval])`,
datasourceUid
),
makePromLink(
'Failed request rate',
`rate(${failedMetric}{server="\${__data.fields.id}"}[$__interval])`,
datasourceUid
),
],
};