Skip to content

Commit

Permalink
Added view for showing detailed trace statistics
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Dengler <philip.dengler@novatec-gmbh.de>
  • Loading branch information
Philip committed Jan 7, 2020
1 parent 537bbe2 commit fb61183
Show file tree
Hide file tree
Showing 21 changed files with 2,279 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,27 @@ import { trackAltViewOpen } from './TracePageHeader.track';
import prefixUrl from '../../../utils/prefix-url';

type Props = {
onTraceGraphViewClicked: () => void;
traceGraphView: boolean;
onTraceGraphViewClicked: (index: number) => void;
traceID: string;
selectedTraceView: number;
};

export default function AltViewOptions(props: Props) {
const { onTraceGraphViewClicked, traceGraphView, traceID } = props;
const { onTraceGraphViewClicked, traceID, selectedTraceView } = props;

const menuItems = ['Trace Timeline', 'Trace Graph', 'Trace Overview'];

const menu = (
<Menu>
<Menu.Item>
<a onClick={onTraceGraphViewClicked} role="button">
{traceGraphView ? 'Trace Timeline' : 'Trace Graph'}
</a>
</Menu.Item>
{menuItems.map((item, index) =>
index === selectedTraceView ? null : (
<Menu.Item key={item}>
<a onClick={() => onTraceGraphViewClicked(index)} role="button">
{item}
</a>
</Menu.Item>
)
)}
<Menu.Item>
<Link
to={prefixUrl(`/api/traces/${traceID}?prettyPrint=true`)}
Expand All @@ -58,8 +65,12 @@ export default function AltViewOptions(props: Props) {
);
return (
<Dropdown overlay={menu}>
<Button className="ub-mr2" htmlType="button" onClick={onTraceGraphViewClicked}>
{traceGraphView ? 'Trace Graph' : 'Trace Timeline'} <Icon type="down" />
<Button
className="ub-mr2"
htmlType="button"
onClick={() => onTraceGraphViewClicked(selectedTraceView + 1)}
>
{menuItems[selectedTraceView]} <Icon type="down" />
</Button>
</Dropdown>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type TracePageHeaderEmbedProps = {
nextResult: () => void;
onArchiveClicked: () => void;
onSlimViewClicked: () => void;
onTraceGraphViewClicked: () => void;
onTraceGraphViewClicked: (index: number) => void;
prevResult: () => void;
resultCount: number;
showArchiveButton: boolean;
Expand All @@ -60,7 +60,7 @@ type TracePageHeaderEmbedProps = {
textFilter: string | TNil;
toSearch: string | null;
trace: Trace;
traceGraphView: boolean;
selectedTraceView: number;
updateNextViewRangeTime: (update: ViewRangeTimeUpdate) => void;
updateViewRangeTime: TUpdateViewRangeTimeFunction;
viewRange: IViewRange;
Expand Down Expand Up @@ -128,7 +128,8 @@ export function TracePageHeaderFn(props: TracePageHeaderEmbedProps & { forwarded
textFilter,
toSearch,
trace,
traceGraphView,

selectedTraceView,
updateNextViewRangeTime,
updateViewRangeTime,
viewRange,
Expand Down Expand Up @@ -187,14 +188,14 @@ export function TracePageHeaderFn(props: TracePageHeaderEmbedProps & { forwarded
ref={forwardedRef}
resultCount={resultCount}
textFilter={textFilter}
navigable={!traceGraphView}
navigable={!(selectedTraceView !== 0)}
/>
{showShortcutsHelp && <KeyboardShortcutsHelp className="ub-m2" />}
{showViewOptions && (
<AltViewOptions
onTraceGraphViewClicked={onTraceGraphViewClicked}
traceGraphView={traceGraphView}
traceID={trace.traceID}
selectedTraceView={selectedTraceView}
/>
)}
{showArchiveButton && (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright (c) 2018 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.
*/

.DetailTableData--tr {
border-top: 1px solid #ececec;
}

.DetailTableData--tr:hover {
background: #fafafa;
color: black;
}

.DetailTableData--child--td {
border-left: 1px solid rgb(204, 204, 204);
border-right: 1px solid rgb(204, 204, 204);
border-top: 1px solid rgb(230, 230, 230);
border-bottom: 1px solid rgb(230, 230, 230);
width: 10%;
padding-left: 2em;

max-width: 25em;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

td {
max-width: 25em;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.DetailTableData--serviceBorder {
border-left: 4px solid transparent;
padding-left: 0.6em;
}

.DetailTableData--td {
border-left: 1px solid rgb(204, 204, 204);
border-right: 1px solid rgb(204, 204, 204);
border-top: 1px solid rgb(230, 230, 230);
border-bottom: 1px solid rgb(230, 230, 230);
width: 9.09%;
padding-left: 1em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright (c) 2018 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 * as _ from 'lodash';
import React, { Component } from 'react';
import './DetailTableData.css';

type Props = {
name: string;
searchColor: string;
values: any[];
columnsArray: any[];
color: string;
togglePopup: (name: string) => void;
secondTagDropdownTitle: string;
colorToPercent: string;
};

type State = {
element: any;
};

/**
* Used to render the detail column.
*/
export default class DetailTableData extends Component<Props, State> {
componentWillMount() {
const element = this.props.values.map(item => {
return { uid: _.uniqueId('id'), value: item };
});

this.setState(prevState => {
return {
...prevState,
element,
};
});
}

render() {
const styleOption1 = {
background: 'rgb(248,248,248)',
color: 'rgb(153,153,153)',
fontStyle: 'italic',
};

const styleOption2 = {
background: this.props.colorToPercent,
borderColor: this.props.colorToPercent,
};

const styleOption3 = {
background: this.props.searchColor,
borderColor: this.props.searchColor,
};
const others = 'Others';
let styleCondition;
if (this.props.name === others) {
styleCondition = styleOption1;
} else if (this.props.searchColor === 'rgb(248,248,248)') {
styleCondition = styleOption2;
} else {
styleCondition = styleOption3;
}
const onClickOption =
this.props.secondTagDropdownTitle === 'sql' && this.props.name !== others
? () => this.props.togglePopup(this.props.name)
: undefined;
return (
<tr className="DetailTableData--tr" style={styleCondition}>
<td className="DetailTableData--child--td">
<a role="button" onClick={onClickOption} style={{ color: 'inherit' }}>
<label
title={this.props.name}
className="DetailTableData--serviceBorder"
style={{ borderColor: this.props.color }}
>
{this.props.name}
</label>
</a>
</td>
{this.state.element.map((element: any, index: number) => (
<td key={element.uid} className="DetailTableData--td">
{this.props.columnsArray[index + 1].isDecimal ? Number(element.value).toFixed(2) : element.value}
{this.props.columnsArray[index + 1].suffix}
</td>
))}
</tr>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright (c) 2018 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.
*/

.DropDown {
padding-top: 0.6em;
padding-bottom: 0.6em;
padding-left: 0.6em;
position: relative;
display: inline-block;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright (c) 2018 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, { Component } from 'react';
import { Button, Dropdown, Icon, Menu } from 'antd';
import './Dropdown.css';
import { Trace } from '../../../types/trace';
import { getColumnValues, getColumnValuesSecondDropdown } from './tableValues';
import { ITableSpan } from './types';

type Props = {
position: number;
trace: Trace;
tableValue: ITableSpan[];
content: string[];
setDropDownTitle: (title: string) => void;
title: string;
firstDropdownTitle: string;
handler: (tableSpan: ITableSpan[]) => void;
};

const serviceName = 'Service Name';
const operationName = 'Operation Name';
const noItemSelected = 'No Item selected';

/**
* Used to build the Dropdown.
*/
export default class DropDown extends Component<Props> {
constructor(props: any) {
super(props);

if (this.props.position === 1) {
this.props.handler(getColumnValues(serviceName, this.props.trace));
}
}

/**
* Is called if a tag is clicked.
* @param title name of the clicked tag
*/
tagIsClicked(title: string) {
this.props.setDropDownTitle(title);
if (this.props.position === 1) {
this.props.handler(getColumnValues(title, this.props.trace));
} else {
this.props.handler(
getColumnValuesSecondDropdown(
this.props.tableValue,
this.props.firstDropdownTitle,
title,
this.props.trace
)
);
}
}

render() {
const menu = (
<Menu>
{this.props.content.map((title: any) => (
<Menu.Item key={title}>
<a onClick={() => this.tagIsClicked(title)} role="button">
{title !== serviceName && title !== operationName ? `Tag: ${title}` : `${title}`}
</a>
</Menu.Item>
))}
</Menu>
);
const buttonTitleTag =
this.props.title !== serviceName &&
this.props.title !== operationName &&
this.props.title !== noItemSelected
? `Tag: ${this.props.title}`
: `${this.props.title}`;
return (
<div className="DropDown">
<Dropdown overlay={menu}>
<Button>
{buttonTitleTag} <Icon type="down" />
</Button>
</Dropdown>
</div>
);
}
}
Loading

0 comments on commit fb61183

Please sign in to comment.