mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 01:41:24 -06:00
Tempo: Fix service graph when tempoApmTable is enabled (#60975)
Fix query variables breaking the generated query for the APM service graph
This commit is contained in:
parent
1381fb6dfc
commit
298576c6a1
@ -567,6 +567,16 @@ describe('Tempo apm table', () => {
|
||||
expect(builtQuery).toBe(
|
||||
'topk(5, sum(rate(traces_spanmetrics_calls_total{service="app",service="app"}[$__range])) by (span_name))'
|
||||
);
|
||||
|
||||
targets = { targets: [{ queryType: 'serviceMap', serviceMapQuery: '{client="${app}",service="$app"}' }] } as any;
|
||||
builtQuery = buildExpr(
|
||||
{ expr: 'topk(5, sum(rate(traces_spanmetrics_calls_total{}[$__range])) by (span_name))', params: [] },
|
||||
'',
|
||||
targets
|
||||
);
|
||||
expect(builtQuery).toBe(
|
||||
'topk(5, sum(rate(traces_spanmetrics_calls_total{service="${app}",service="$app"}[$__range])) by (span_name))'
|
||||
);
|
||||
});
|
||||
|
||||
it('should build link expr correctly', () => {
|
||||
@ -669,17 +679,17 @@ describe('Tempo apm table', () => {
|
||||
];
|
||||
const objToAlign = {
|
||||
'HTTP GET - root': {
|
||||
value: 0.1234,
|
||||
value: '0.1234',
|
||||
},
|
||||
'HTTP GET': {
|
||||
value: 0.6789,
|
||||
value: '0.6789',
|
||||
},
|
||||
'HTTP POST - post': {
|
||||
value: 0.4321,
|
||||
value: '0.4321',
|
||||
},
|
||||
};
|
||||
|
||||
let value = getRateAlignedValues(resp, objToAlign as any);
|
||||
let value = getRateAlignedValues(resp, objToAlign);
|
||||
expect(value.toString()).toBe('0,0.6789,0.1234,0,0.4321');
|
||||
});
|
||||
|
||||
|
@ -820,7 +820,11 @@ export function buildExpr(
|
||||
extraParams: string,
|
||||
request: DataQueryRequest<TempoQuery>
|
||||
) {
|
||||
let serviceMapQuery = request.targets[0]?.serviceMapQuery?.replace('{', '').replace('}', '') ?? '';
|
||||
let serviceMapQuery = request.targets[0]?.serviceMapQuery ?? '';
|
||||
const serviceMapQueryMatch = serviceMapQuery.match(/^{(.*)}$/);
|
||||
if (serviceMapQueryMatch?.length) {
|
||||
serviceMapQuery = serviceMapQueryMatch[1];
|
||||
}
|
||||
// map serviceGraph metric tags to APM metric tags
|
||||
serviceMapQuery = serviceMapQuery.replace('client', 'service').replace('server', 'service');
|
||||
const metricParams = serviceMapQuery.includes('span_name')
|
||||
|
Loading…
Reference in New Issue
Block a user