Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make traceID, startTime, endTime, duration and traceName available for Link Patterns #1178

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix lint errors
Signed-off-by: Kanahathi Mohideen <kpmfazal@gmail.com>
  • Loading branch information
MUI-Pop committed Feb 6, 2023
commit 4b74c6dd6964d38d0ea8bf814c77f9f174cdf96b
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export class VirtualizedTraceViewImpl extends React.Component<VirtualizedTraceVi
linksGetter = (span: Span, items: KeyValuePair[], itemIndex: number) => {
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
const { trace } = this.props;
return getLinks(span, items, itemIndex, trace);
}
};

renderRow = (key: string, style: React.CSSProperties, index: number, attrs: {}) => {
const { isDetail, span, spanIndex } = this.getRowStates()[index];
Expand Down
19 changes: 15 additions & 4 deletions packages/jaeger-ui/src/model/link-patterns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ describe('getParameterInTrace()', () => {
it('returns undefined when there is no trace', () => {
expect(getParameterInTrace('traceID')).toBeUndefined();
});

});

describe('computeTraceLink()', () => {
Expand Down Expand Up @@ -384,14 +383,26 @@ describe('computeLinks()', () => {
{
type: 'logs',
key: 'myThirdKey',
url: 'http://example.com/?myKey1=#{myKey}&myKey=#{myThirdKey}&traceID=#{trace.traceID}&startTime=#{trace.startTime}',
url:
'http://example.com/?myKey1=#{myKey}&myKey=#{myThirdKey}&traceID=#{trace.traceID}&startTime=#{trace.startTime}',
text: 'third link (#{myThirdKey}) for traceID - #{trace.traceID}',
}
},
].map(processLinkPattern);

const spans = [
{ depth: 0, process: {}, tags: [{ key: 'myKey', value: 'valueOfMyKey' }] },
{ depth: 1, process: {}, logs: [{ fields: [{ key: 'myOtherKey', value: 'valueOfMy+Other+Key' }, { key: 'myThirdKey', value: 'valueOfThirdMyKey' }] }] },
{
depth: 1,
process: {},
logs: [
{
fields: [
{ key: 'myOtherKey', value: 'valueOfMy+Other+Key' },
{ key: 'myThirdKey', value: 'valueOfThirdMyKey' },
],
},
],
},
];
spans[1].references = [
{
Expand Down
26 changes: 11 additions & 15 deletions packages/jaeger-ui/src/model/link-patterns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,19 @@ export function getParameterInAncestor(name: string, span: Span) {
return undefined;
}

const getValidTraceKeys = memoize(10)(
(trace: Trace) => {
const validKeys = (Object.keys(trace) as (keyof Trace)[]).filter(
key => typeof trace[key] === 'string' || typeof trace[key] === 'number'
);
return validKeys;
}
);
const getValidTraceKeys = memoize(10)((trace: Trace) => {
const validKeys = (Object.keys(trace) as (keyof Trace)[]).filter(
key => typeof trace[key] === 'string' || typeof trace[key] === 'number'
);
return validKeys;
});

export function getParameterInTrace(name: string, trace: Trace | undefined) {
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

if(trace) {
if (trace) {
const validTraceKeys = getValidTraceKeys(trace);

const key = name as keyof Trace;
if(validTraceKeys.includes(key)) {
if (validTraceKeys.includes(key)) {
return trace[key];
}
}
Expand Down Expand Up @@ -193,13 +190,12 @@ export function computeLinks(
const allParameters = pattern.parameters.every(parameter => {
let entry;

if(parameter.startsWith('trace.')) {
if (parameter.startsWith('trace.')) {
const traceVal = getParameterInTrace(parameter.split('trace.')[1], trace);
if(traceVal) {
if (traceVal) {
entry = { key: parameter, value: traceVal };
}
}
else {
} else {
entry = getParameterInArray(parameter, items);

if (!entry && !processTags) {
Expand Down