Skip to content

Commit

Permalink
[APM] Fix for library frames not collapsing (elastic#26827)
Browse files Browse the repository at this point in the history
* [APM] fixes elastic#26525
- simplified the stackframe grouping algorithm
- add support for `stackframe.exclude_from_grouping`
- made the rendering more tolerant of edge cases

* Made improvements to code readability and added more meaningful test cases
  • Loading branch information
ogupte committed Dec 12, 2018
1 parent 86c9a69 commit fd4cb21
Show file tree
Hide file tree
Showing 6 changed files with 1,099 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,52 @@ const LibraryFrameToggle = styled.div`
user-select: none;
`;

interface LibraryStackFrameProps {
codeLanguage?: string;
stackframe: Stackframe;
}

const LibraryStackFrame: React.SFC<LibraryStackFrameProps> = ({
codeLanguage,
stackframe
}) => {
return hasSourceLines(stackframe) ? (
<CodePreview
stackframe={stackframe}
isLibraryFrame
codeLanguage={codeLanguage}
/>
) : (
<FrameHeading stackframe={stackframe} isLibraryFrame />
);
};

interface Props {
visible?: boolean;
stackframes: Stackframe[];
codeLanguage?: string;
onClick: () => void;
}

export const LibraryFrames: React.SFC<Props> = ({
export const LibraryStackFrames: React.SFC<Props> = ({
visible,
stackframes,
codeLanguage,
onClick
}) => {
if (stackframes.length === 0) {
return null;
}

if (stackframes.length === 1) {
return (
<LibraryStackFrame
codeLanguage={codeLanguage}
stackframe={stackframes[0]}
/>
);
}

return (
<div>
<LibraryFrameToggle>
Expand All @@ -44,18 +77,13 @@ export const LibraryFrames: React.SFC<Props> = ({

<div>
{visible &&
stackframes.map((stackframe, i) =>
hasSourceLines(stackframe) ? (
<CodePreview
key={i}
stackframe={stackframe}
isLibraryFrame
codeLanguage={codeLanguage}
/>
) : (
<FrameHeading key={i} stackframe={stackframe} isLibraryFrame />
)
)}
stackframes.map((stackframe, i) => (
<LibraryStackFrame
key={i}
codeLanguage={codeLanguage}
stackframe={stackframe}
/>
))}
</div>
</div>
);
Expand Down
Loading

0 comments on commit fd4cb21

Please sign in to comment.