mirror of
https://github.com/grafana/grafana.git
synced 2025-01-07 22:53:56 -06:00
Elasticsearch: Fix creating of span link with no tags (#61753)
Elasticsearch: Fix create span link if no tags
This commit is contained in:
parent
3b3059c9ce
commit
46722679b5
@ -665,6 +665,34 @@ describe('createSpanLinkFactory', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('formats query correctly if only filterByTraceID is true', () => {
|
||||
const createLink = setupSpanLinkFactory(
|
||||
{
|
||||
datasourceUid: searchUID,
|
||||
filterByTraceID: true,
|
||||
},
|
||||
searchUID
|
||||
);
|
||||
|
||||
expect(createLink).toBeDefined();
|
||||
const links = createLink!(
|
||||
createTraceSpan({
|
||||
process: {
|
||||
serviceName: 'service',
|
||||
tags: [],
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
const linkDef = links?.logLinks?.[0];
|
||||
expect(linkDef).toBeDefined();
|
||||
expect(linkDef!.href).toBe(
|
||||
`/explore?left=${encodeURIComponent(
|
||||
`{"range":{"from":"2020-10-14T01:00:00.000Z","to":"2020-10-14T01:00:01.000Z"},"datasource":"searchUID","queries":[{"query":"\\"7946b05c2e2e4e5a\\"","refId":"","metrics":[{"id":"1","type":"logs"}]}],"panelsState":{}}`
|
||||
)}`
|
||||
);
|
||||
});
|
||||
|
||||
it('should format one tag correctly', () => {
|
||||
const createLink = setupSpanLinkFactory(
|
||||
{
|
||||
|
@ -318,15 +318,19 @@ function getLinkForElasticsearchOrOpensearch(
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
let query = '';
|
||||
if (tags.length > 0) {
|
||||
query += `${tags.join(' AND ')}`;
|
||||
}
|
||||
if (filterByTraceID && span.traceID) {
|
||||
query = `"${span.traceID}" AND ` + query;
|
||||
}
|
||||
let queryArr = [];
|
||||
if (filterBySpanID && span.spanID) {
|
||||
query = `"${span.spanID}" AND ` + query;
|
||||
queryArr.push(`"${span.spanID}"`);
|
||||
}
|
||||
|
||||
if (filterByTraceID && span.traceID) {
|
||||
queryArr.push(`"${span.traceID}"`);
|
||||
}
|
||||
|
||||
if (tags.length > 0) {
|
||||
for (const tag of tags) {
|
||||
queryArr.push(tag);
|
||||
}
|
||||
}
|
||||
|
||||
const dataLink: DataLink<ElasticsearchOrOpensearchQuery> = {
|
||||
@ -336,7 +340,7 @@ function getLinkForElasticsearchOrOpensearch(
|
||||
datasourceUid: dataSourceSettings.uid,
|
||||
datasourceName: dataSourceSettings.name,
|
||||
query: {
|
||||
query: query,
|
||||
query: queryArr.join(' AND '),
|
||||
refId: '',
|
||||
metrics: [
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user