Skip to content

Commit 28c386a

Browse files
committed
Add support for Trace
Signed-off-by: Shweta Padubidri <spadubid@redhat.com>
1 parent d46809e commit 28c386a

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

web/src/__tests__/trace-node.spec.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import { TraceNode } from '../korrel8r/trace';
22

33
const roundtrip = [
44
{
5-
url: `observe/traces?tempostack=NAME&namespace=NAMESPACE&tenant=TENANT&q=${encodeURIComponent(
6-
'{resource.service.name = "article-service"}',
7-
)}`,
5+
url: `observe/traces?name=platform&namespace=openshift-tracing&tenant=platform&
6+
q=${encodeURIComponent('{resource.service.name = "article-service"}')}`,
87
query: `trace:trace:{resource.service.name = "article-service"}`,
98
},
109
];
@@ -19,4 +18,13 @@ describe('TraceNode.fromQuery', () => {
1918
it.each(roundtrip)('$query', ({ query, url }) =>
2019
expect(TraceNode.fromQuery(query)?.toURL()).toEqual(url),
2120
);
21+
22+
it('Query => URL => Query', () => {
23+
const query = 'trace:trace:{resource.service.name="shop-backend"}';
24+
const expectedKorrel8rURL =
25+
'observe/traces?name=platform&namespace=openshift-tracing&tenant=platform&q=%7Bresource.service.name%3D%22shop-backend%22%7D';
26+
const actualKorrel8rURL = TraceNode.fromQuery(query)?.toURL();
27+
expect(actualKorrel8rURL).toEqual(expectedKorrel8rURL);
28+
expect(TraceNode.fromURL(actualKorrel8rURL)?.toQuery()).toEqual(query);
29+
});
2230
});

web/src/korrel8r-utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const nodeToLabel = (node: QueryNode): string => {
2323
return `${nodeClass} (${node.count})`;
2424
case Korrel8rDomain.Netflow:
2525
return `Network (${node.count})`;
26+
case Korrel8rDomain.Trace:
27+
return `Trace (${node.count})`;
2628
default:
2729
// eslint-disable-next-line no-console
2830
console.warn(`Unknown node type: ${node.class}`);

web/src/korrel8r/trace.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Korrel8rNode } from './korrel8r.types';
22
import { parseQuery, parseURL } from './query-url';
33

4-
// URL format: `observe/traces?namespace=<tempoNamespace>&name=<tempoName>&tenant=<tempoTenant>&q=<traceQL>` +
4+
// URL format:
5+
// `observe/traces?namespace=<tempoNamespace>&name=<tempoName>&tenant=<tempoTenant>&q=<traceQL>`
56

6-
// FIXME hard-coded tempo location, need to make this configurable/agreed between console & korrel8r.
7+
// FIXME hard-coded tempo location, need to make this configurable between console & korrel8r.
78
// Get from the console page environment (change from using URL as context?)
8-
const [tempoNamespace, tempoName, tempoTenant] = ['NAMESPACE', 'NAME', 'TENANT'];
9+
const [tempoNamespace, tempoName, tempoTenant] = ['openshift-tracing', 'platform', 'platform'];
910

1011
export class TraceNode extends Korrel8rNode {
1112
query: string;
@@ -28,7 +29,7 @@ export class TraceNode extends Korrel8rNode {
2829
const [, traceQL] = parseQuery('trace', query);
2930
// FIME get variable tempo address info from query or config...
3031
return new TraceNode(
31-
`observe/traces?tempostack=${tempoName}&namespace=${tempoNamespace}&tenant=${tempoTenant}&` +
32+
`observe/traces?name=${tempoName}&namespace=${tempoNamespace}&tenant=${tempoTenant}&` +
3233
`q=${encodeURIComponent(traceQL)}`,
3334
query,
3435
);

0 commit comments

Comments
 (0)