-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ruben Vargas <[email protected]>
- Loading branch information
1 parent
6f78c8d
commit 53e1635
Showing
7 changed files
with
373 additions
and
22 deletions.
There are no files selected for viewing
154 changes: 154 additions & 0 deletions
154
packages/jaeger-ui/src/components/DeepDependencies/traces.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
// Copyright (c) 2019 Uber Technologies, Inc. | ||
// | ||
// 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 { History as RouterHistory, Location } from 'history'; | ||
import _get from 'lodash/get'; | ||
import { connect } from 'react-redux'; | ||
import { getUrlState } from './url'; | ||
import { getUrl } from '../SearchTracePage/url'; | ||
|
||
import Graph from './Graph'; | ||
import { extractUiFindFromState, TExtractUiFindFromStateReturn } from '../common/UiFindInput'; | ||
import { EDirection, TDdgModel, TDdgModelParams, TDdgSparseUrlState } from '../../model/ddg/types'; | ||
import TGraph, { makeGraph } from '../../model/ddg/Graph'; | ||
import { encodeDistance } from '../../model/ddg/visibility-codec'; | ||
import { ReduxState } from '../../types'; | ||
|
||
import './index.css'; | ||
import transformDdgData from '../../model/ddg/transformDdgData'; | ||
import transformTracesToPaths from '../../model/ddg/transformTracesToPaths'; | ||
import HopsSelector from './Header/HopsSelector'; | ||
|
||
type TDispatchProps = { | ||
fetchDeepDependencyGraph: (query: TDdgModelParams) => void; | ||
fetchServices: () => void; | ||
fetchServiceOperations: (service: string) => void; | ||
transformTracesToDDG: (trace: any) => void; | ||
}; | ||
|
||
type TReduxProps = TExtractUiFindFromStateReturn & { | ||
graph: TGraph | undefined; | ||
services?: string[] | null; | ||
urlState: TDdgSparseUrlState; | ||
trace: any; | ||
model: TDdgModel | undefined; | ||
}; | ||
|
||
type TOwnProps = { | ||
history: RouterHistory; | ||
location: Location; | ||
}; | ||
|
||
type TProps = TDispatchProps & TReduxProps & TOwnProps; | ||
|
||
// export for tests | ||
export class SearchResultsDDG extends Component<TProps> { | ||
// shouldComponentUpdate is necessary as we don't want the plexus graph to re-render due to a uxStatus change | ||
shouldComponentUpdate(nextProps: TProps) { | ||
const updateCauses = [ | ||
'uiFind', | ||
'trace', | ||
'services', | ||
'urlState.service', | ||
'urlState.operation', | ||
'urlState.start', | ||
'urlState.end', | ||
'urlState.visEncoding', | ||
]; | ||
return updateCauses.some(cause => _get(nextProps, cause) !== _get(this.props, cause)); | ||
} | ||
|
||
setDistance = (distance: number, direction: EDirection) => { | ||
const { visEncoding } = this.props.urlState; | ||
const { model } = this.props; | ||
if (model) { | ||
this.updateUrlState({ | ||
visEncoding: encodeDistance({ | ||
ddgModel: model, | ||
direction, | ||
distance, | ||
prevVisEncoding: visEncoding, | ||
}), | ||
}); | ||
} | ||
}; | ||
|
||
updateUrlState = (newValues: Partial<TDdgSparseUrlState>) => { | ||
const { uiFind, urlState, history } = this.props; | ||
history.push(getUrl({ uiFind, ...urlState, ...newValues })); | ||
}; | ||
|
||
render() { | ||
const { graph, uiFind, urlState, model } = this.props; | ||
const { visEncoding } = urlState; | ||
const uiFindMatches = graph && graph.getVisibleUiFindMatches(uiFind, visEncoding); | ||
|
||
let content = ( | ||
<div> | ||
<h1>Unknown graphState:</h1> | ||
<p>${JSON.stringify(graph)}</p> | ||
</div> | ||
); | ||
if (graph && model) { | ||
const { edges, vertices } = graph.getVisible(visEncoding); | ||
const distanceToPathElems = model.distanceToPathElems; | ||
content = ( | ||
<div> | ||
<HopsSelector | ||
distanceToPathElems={distanceToPathElems} | ||
handleClick={this.setDistance} | ||
visEncoding={visEncoding} | ||
/> | ||
<div className="Ddg--graphWrapper"> | ||
<Graph | ||
edges={edges} | ||
getVisiblePathElems={(key: string) => graph.getVisiblePathElems(key, visEncoding)} | ||
uiFindMatches={uiFindMatches} | ||
vertices={vertices} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
return content; | ||
} | ||
} | ||
|
||
// export for tests | ||
export function mapStateToProps(state: ReduxState, ownProps: TOwnProps): TReduxProps { | ||
const { trace } = state; | ||
const urlState = getUrlState(ownProps.location.search); | ||
const { density, operation, service, showOp } = urlState; | ||
let graph: TGraph | undefined; | ||
let model: TDdgModel | undefined; | ||
|
||
if (service) { | ||
const paths = transformTracesToPaths(trace.traces, service, operation); | ||
model = transformDdgData(paths, { service, operation }); | ||
graph = makeGraph(model, showOp, density); | ||
} else { | ||
graph = undefined; | ||
} | ||
|
||
return { | ||
model, | ||
trace, | ||
graph, | ||
urlState, | ||
...extractUiFindFromState(state), | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(SearchResultsDDG); |
30 changes: 30 additions & 0 deletions
30
packages/jaeger-ui/src/components/SearchTracePage/SearchResults/AltViewOptions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) 2018 Uber Technologies, Inc. | ||
// | ||
// 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 React from 'react'; | ||
import { Button } from 'antd'; | ||
|
||
type Props = { | ||
traceResultsView: boolean; | ||
onTraceGraphViewClicked: () => void; | ||
}; | ||
|
||
export default function AltViewOptions(props: Props) { | ||
const { onTraceGraphViewClicked, traceResultsView } = props; | ||
return ( | ||
<Button className="ub-mr2" htmlType="button" onClick={onTraceGraphViewClicked}> | ||
{traceResultsView ? 'Deep dependency graph' : 'Trace Results'} | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.