Tempo: Set APM table default span kind (#52851)

* Add span kind server to query

* Updated test
This commit is contained in:
Joey Tawadrous 2022-07-27 15:48:09 +01:00 committed by GitHub
parent e2258120e7
commit dc0ef2913e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -487,7 +487,7 @@ describe('Tempo apm table', () => {
expect(builtQuery).toBe('sum(rate(traces_spanmetrics_calls_total{}[$__rate_interval]))');
});
it('should build link expr correctly', () => {
it('should get field config correctly', () => {
let datasourceUid = 's4Jvz8Qnk';
let tempoDatasourceUid = 'EbPO1fYnz';
let targetField = '__data.fields.target';
@ -694,12 +694,12 @@ const defaultSettings: DataSourceInstanceSettings<TempoJsonData> = {
};
const rateMetric = new MutableDataFrame({
refId: 'topk(5, sum(rate(traces_spanmetrics_calls_total{}[$__range])) by (span_name))',
refId: 'topk(5, sum(rate(traces_spanmetrics_calls_total{span_kind="SPAN_KIND_SERVER"}[$__range])) by (span_name))',
fields: [
{ name: 'Time', values: [1653725618609, 1653725618609] },
{ name: 'span_name', values: ['HTTP Client', 'HTTP GET - root'] },
{
name: 'Value #topk(5, sum(rate(traces_spanmetrics_calls_total{}[$__range])) by (span_name))',
name: 'Value #topk(5, sum(rate(traces_spanmetrics_calls_total{span_kind="SPAN_KIND_SERVER"}[$__range])) by (span_name))',
values: [12.75164671814457, 12.121331111401608],
},
],

View File

@ -43,6 +43,7 @@ import {
rateMetric,
durationMetric,
errorRateMetric,
defaultTableFilter,
} from './graphTransform';
import {
transformTrace,
@ -487,7 +488,7 @@ function rateQuery(
datasourceUid: string
) {
const serviceMapRequest = makePromServiceMapRequest(request);
serviceMapRequest.targets = makeApmRequest([buildExpr(rateMetric, '', request)]);
serviceMapRequest.targets = makeApmRequest([buildExpr(rateMetric, defaultTableFilter, request)]);
return queryPrometheus(serviceMapRequest, datasourceUid).pipe(
toArray(),
@ -660,7 +661,7 @@ function getApmTable(
) {
let df: any = { fields: [] };
const rate = rateResponse.data[0]?.filter((x: { refId: string }) => {
return x.refId === buildExpr(rateMetric, '', request);
return x.refId === buildExpr(rateMetric, defaultTableFilter, request);
});
const errorRate = secondResponse.data.filter((x) => {
return x.refId === errorRateBySpanName;

View File

@ -148,6 +148,7 @@ export const durationMetric = {
expr: 'histogram_quantile(.9, sum(rate(traces_spanmetrics_latency_bucket{}[$__range])) by (le))',
params: [],
};
export const defaultTableFilter = 'span_kind="SPAN_KIND_SERVER"';
export const serviceMapMetrics = [
secondsMetric,