[Service map] Send name and namespace separately when going to traces explore (#83840)

Send name and namespace separately when going to traces explroe
pull/81730/head
Javier Ruiz 2 years ago committed by GitHub
parent e3314f04e4
commit 5a727a0b41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 50
      public/app/plugins/datasource/tempo/datasource.test.ts
  2. 28
      public/app/plugins/datasource/tempo/datasource.ts

@ -953,12 +953,20 @@ describe('Tempo service graph view', () => {
queryType: 'traceqlSearch',
refId: 'A',
filters: [
{
id: 'service-namespace',
operator: '=',
scope: 'resource',
tag: 'service.namespace',
value: '${__data.fields.targetNamespace}',
valueType: 'string',
},
{
id: 'service-name',
operator: '=',
scope: 'resource',
tag: 'service.name',
value: '${__data.fields.target}',
value: '${__data.fields.targetName}',
valueType: 'string',
},
],
@ -1033,8 +1041,34 @@ describe('Tempo service graph view', () => {
]);
});
it('should make tempo link correctly', () => {
const tempoLink = makeTempoLink('Tempo', '', '"${__data.fields[0]}"', 'gdev-tempo');
it('should make tempo link correctly without namespace', () => {
const tempoLink = makeTempoLink('Tempo', undefined, '', '"${__data.fields[0]}"', 'gdev-tempo');
expect(tempoLink).toEqual({
url: '',
title: 'Tempo',
internal: {
query: {
queryType: 'traceqlSearch',
refId: 'A',
filters: [
{
id: 'span-name',
operator: '=',
scope: 'span',
tag: 'name',
value: '"${__data.fields[0]}"',
valueType: 'string',
},
],
},
datasourceUid: 'gdev-tempo',
datasourceName: 'Tempo',
},
});
});
it('should make tempo link correctly with namespace', () => {
const tempoLink = makeTempoLink('Tempo', '"${__data.fields.subtitle}"', '', '"${__data.fields[0]}"', 'gdev-tempo');
expect(tempoLink).toEqual({
url: '',
title: 'Tempo',
@ -1043,6 +1077,14 @@ describe('Tempo service graph view', () => {
queryType: 'traceqlSearch',
refId: 'A',
filters: [
{
id: 'service-namespace',
operator: '=',
scope: 'resource',
tag: 'service.namespace',
value: '"${__data.fields.subtitle}"',
valueType: 'string',
},
{
id: 'span-name',
operator: '=',
@ -1457,7 +1499,7 @@ const serviceGraphLinks = [
operator: '=',
scope: 'resource',
tag: 'service.name',
value: '${__data.fields[0]}',
value: '${__data.fields.id}',
valueType: 'string',
},
],

@ -1128,13 +1128,35 @@ export function getFieldConfig(
datasourceUid,
false
),
makeTempoLink('View traces', `\${${tempoField}}`, '', tempoDatasourceUid),
makeTempoLink(
'View traces',
namespaceFields !== undefined ? `\${${namespaceFields.targetNamespace}}` : '',
`\${${targetField}}`,
'',
tempoDatasourceUid
),
],
};
}
export function makeTempoLink(title: string, serviceName: string, spanName: string, datasourceUid: string) {
export function makeTempoLink(
title: string,
serviceNamespace: string | undefined,
serviceName: string,
spanName: string,
datasourceUid: string
) {
let query: TempoQuery = { refId: 'A', queryType: 'traceqlSearch', filters: [] };
if (serviceNamespace !== undefined && serviceNamespace !== '') {
query.filters.push({
id: 'service-namespace',
scope: TraceqlSearchScope.Resource,
tag: 'service.namespace',
value: serviceNamespace,
operator: '=',
valueType: 'string',
});
}
if (serviceName !== '') {
query.filters.push({
id: 'service-name',
@ -1338,7 +1360,7 @@ function getServiceGraphView(
return 'Tempo';
}),
config: {
links: [makeTempoLink('Tempo', '', `\${__data.fields[0]}`, tempoDatasourceUid)],
links: [makeTempoLink('Tempo', undefined, '', `\${__data.fields[0]}`, tempoDatasourceUid)],
},
});
}

Loading…
Cancel
Save