Skip to content

Commit

Permalink
Fix trace scoped links not supporting numeric fields
Browse files Browse the repository at this point in the history
From https://www.jaegertracing.io/docs/1.17/frontend-ui/#link-patterns

"For traces, the supported template fields are: duration, endTime,
startTime, traceName and traceID."

Fixes #465

Signed-off-by: Will Tran <[email protected]>
  • Loading branch information
Will Tran committed Mar 5, 2020
1 parent d7bbc7b commit b6a70dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions packages/jaeger-ui/src/model/link-patterns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,32 +310,42 @@ describe('computeTraceLink()', () => {
const linkPatterns = [
{
type: 'traces',
url: 'http://example.com/?myKey=#{traceID}',
url: 'http://example.com/?traceID=#{traceID}',
text: 'first link (#{traceID})',
},
{
type: 'traces',
url: 'http://example.com/?myKey=#{traceID}&myKey=#{myKey}',
text: 'second link (#{myKey})',
url: 'http://example.com/?traceID#{traceID}&myKey=#{myKey}',
text: 'second link will not render because myKey is not in the trace',
},
{
type: 'traces',
url: 'http://example.com/?traceID=#{traceID}&traceName=#{traceName}&startTime=#{startTime}&endTime=#{endTime}&duration=#{duration}',
text: 'third link (#{traceID}, #{traceName}, #{startTime}, #{endTime}, #{duration})',
}
].map(processLinkPattern);

const trace = {
processes: [],
traceName: 'theTrace',
traceID: 'trc1',
spans: [],
startTime: 1000,
endTime: 2000,
duration: 1000,
endTime: 3000,
duration: 2000,
services: [],
};

it('correctly computes links', () => {
it('correctly computes trace scoped links', () => {
expect(computeTraceLink(linkPatterns, trace)).toEqual([
{
url: 'http://example.com/?myKey=trc1',
url: 'http://example.com/?traceID=trc1',
text: 'first link (trc1)',
},
{
url: 'http://example.com/?traceID=trc1&traceName=theTrace&startTime=1000&endTime=3000&duration=2000',
text: 'third link (trc1, theTrace, 1000, 3000, 2000)',
},
]);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/model/link-patterns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function callTemplate(template: ProcessedTemplate, data: any) {
export function computeTraceLink(linkPatterns: ProcessedLinkPattern[], trace: Trace) {
const result: TLinksRV = [];
const validKeys = (Object.keys(trace) as (keyof Trace)[]).filter(
key => typeof trace[key] === 'string' || trace[key] === 'number'
key => typeof trace[key] === 'string' || typeof trace[key] === 'number'
);

linkPatterns
Expand Down

0 comments on commit b6a70dc

Please sign in to comment.