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

Add trace visualization as a FlameGraph #976

Merged
merged 3 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions packages/jaeger-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
},
"dependencies": {
"@jaegertracing/plexus": "0.2.0",
"@pyroscope/flamegraph": "0.17.2",
"@types/classnames": "^2.2.7",
"@types/deep-freeze": "^0.1.1",
"@types/history": "^4.7.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright (c) 2022 The Jaeger Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.Flamegraph-wrapper {
padding: 0 calc(1rem - 5px);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2022 The Jaeger Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import React from 'react';
import { FlamegraphRenderer, convertJaegerTraceToProfile } from '@pyroscope/flamegraph';

import '@pyroscope/flamegraph/dist/index.css';
import './index.css';

const TraceFlamegraph = ({ trace }: any) => {
const convertedProfile = convertJaegerTraceToProfile(trace.data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe, kinda nasty having this circular dependency on the internal data model, but ok.

Is it possible to add some basic test for this function in jaeger-ui project? The scenario I am worried about is if we decide to make changes to the trace data model (e.g. by switching to working with OTEL model natively), I would like that test to fail and flag the dependency issue. If convertJaegerTraceToProfile function was implemented right here it would be less of a problem (I assume you have internal unit tests for it).


return (
<div className="Flamegraph-wrapper">
<FlamegraphRenderer colorMode="light" profile={convertedProfile} />
</div>
);
};

export default TraceFlamegraph;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add some basic tests like "does not explode" and snapshot?

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const MENU_ITEMS = [
viewType: ETraceViewType.TraceSpansView,
label: 'Trace Spans Table',
},
{
viewType: ETraceViewType.TraceFlamegraph,
label: 'Trace Flamegraph',
},
];

export default function AltViewOptions(props: Props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ exports[`AltViewOptions renders correctly 1`] = `
Trace Spans Table
</a>
</MenuItem>
<MenuItem>
<a
onClick={[Function]}
role="button"
>
Trace Flamegraph
</a>
</MenuItem>
<MenuItem>
<Link
onClick={[MockFunction]}
Expand Down
3 changes: 3 additions & 0 deletions packages/jaeger-ui/src/components/TracePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import filterSpans from '../../utils/filter-spans';
import updateUiFind from '../../utils/update-ui-find';
import TraceStatistics from './TraceStatistics/index';
import TraceSpanView from './TraceSpanView/index';
import TraceFlamegraph from './TraceFlamegraph/index';

import './index.css';

Expand Down Expand Up @@ -410,6 +411,8 @@ export class TracePageImpl extends React.PureComponent<TProps, TState> {
view = <TraceStatistics trace={data} uiFindVertexKeys={spanFindMatches} uiFind={uiFind} />;
} else if (ETraceViewType.TraceSpansView === viewType && headerHeight) {
view = <TraceSpanView trace={data} uiFindVertexKeys={spanFindMatches} uiFind={uiFind} />;
} else if (ETraceViewType.TraceFlamegraph === viewType && headerHeight) {
view = <TraceFlamegraph trace={trace} />;
}

return (
Expand Down
1 change: 1 addition & 0 deletions packages/jaeger-ui/src/components/TracePage/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ export enum ETraceViewType {
TraceGraph = 'TraceGraph',
TraceStatistics = 'TraceStatistics',
TraceSpansView = 'TraceSpansView',
TraceFlamegraph = 'TraceFlamegraph',
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,11 @@
universal-user-agent "^2.0.0"
url-template "^2.0.8"

"@pyroscope/flamegraph@0.17.2":
version "0.17.2"
resolved "https://registry.yarnpkg.com/@pyroscope/flamegraph/-/flamegraph-0.17.2.tgz#b8d95e9d8de9526fa79339690869e8c2c1c5e75e"
integrity sha512-dS4yvX9n61f7SqXhsZnkl7SM03d6DtXy1KRnlHbiLb1IwyiV9iHazQdkaTcQHOu90go2I2JkxCJlT+/O9kyz0A==

"@sinonjs/commons@^1", "@sinonjs/commons@^1.0.2", "@sinonjs/commons@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.4.0.tgz#7b3ec2d96af481d7a0321252e7b1c94724ec5a78"
Expand Down