diff --git a/src/components/Nav/Navigation.tsx b/src/components/Nav/Navigation.tsx index f0aada3a3a..f6d1dd667b 100644 --- a/src/components/Nav/Navigation.tsx +++ b/src/components/Nav/Navigation.tsx @@ -77,7 +77,7 @@ class Navigation extends React.Component { return isRoute; }); return navItems.map(item => { - if (item.title === 'Distributed Tracing') { + /*if (item.title === 'Distributed Tracing') { return ( { onClick={() => this.goTojaeger()} /> ); - } + }*/ return ( , Ser const parsedSearch = this.parseSearch(); const istioObject = this.searchObject(parsedSearch); const editorVisible = parsedSearch.name && parsedSearch.type; + return ( <> {this.renderBreadcrumbs(parsedSearch, !!(editorVisible && istioObject))} @@ -235,7 +238,7 @@ class ServiceDetails extends React.Component, Ser
Inbound Metrics
- +
Traces
@@ -259,6 +262,12 @@ class ServiceDetails extends React.Component, Ser direction={MetricsDirection.INBOUND} /> + + + @@ -287,18 +296,6 @@ class ServiceDetails extends React.Component, Ser this.props.history.push(this.props.location.pathname + '?' + urlParams.toString()); }; }; - - private navigateToJaeger = () => { - API.getJaegerInfo(authentication()) - .then(response => { - let data = response['data']; - window.open(data.url + `/search?service=${this.props.match.params.service}`, '_blank'); - }) - .catch(error => { - MessageCenter.add(API.getErrorMsg('Could not fetch Jaeger info', error)); - console.log(error); - }); - }; } export default ServiceDetails; diff --git a/src/pages/ServiceDetails/ServiceTraces.tsx b/src/pages/ServiceDetails/ServiceTraces.tsx new file mode 100644 index 0000000000..c0b9d8926e --- /dev/null +++ b/src/pages/ServiceDetails/ServiceTraces.tsx @@ -0,0 +1,91 @@ +import * as React from 'react'; +import { ToolbarDropdown } from '../../components/ToolbarDropdown/ToolbarDropdown'; +import { Toolbar, FormGroup, Checkbox } from 'patternfly-react'; +import ServiceId from '../../types/ServiceId'; +import { HistoryManager, URLParams } from '../../app/History'; +import { config } from '../../config'; +import history from '../../app/History'; +import ServiceTracesJaeger from './ServiceTraces/ServiceTracesJaeger'; + +type ServiceTraceState = { + duration: number; + onlyErrors: boolean; +}; + +class ServiceTraces extends React.Component { + static Durations = config().toolbar.intervalDuration; + static DefaultDuration = config().toolbar.defaultDuration; + + constructor(props: ServiceId) { + super(props); + const urlParams = new URLSearchParams(history.location.search); + this.state = { + duration: this.initialDuration(urlParams), + onlyErrors: true + }; + } + + initialDuration = (urlParams: URLSearchParams): number => { + let d = urlParams.get(URLParams.DURATION); + if (d !== null) { + sessionStorage.setItem(URLParams.DURATION, d); + return Number(d); + } + d = sessionStorage.getItem(URLParams.DURATION); + return d !== null ? Number(d) : ServiceTraces.DefaultDuration; + }; + + onDurationChange = (key: number) => { + sessionStorage.setItem(URLParams.DURATION, String(key)); + HistoryManager.setParam(URLParams.DURATION, String(key)); + this.setState({ duration: key }); + }; + + onErrorsChange = evt => { + this.setState({ onlyErrors: evt.target.checked }); + }; + + render() { + return ( +
+ + + + + + + Only Errors + + + + +
+ ); + } + + /*private navigateToJaeger = () => { + API.getJaegerInfo(authentication()) + .then(response => { + let data = response['data']; + window.open(data.url + `/search?service=${this.props.match.params.service}`, '_blank'); + }) + .catch(error => { + MessageCenter.add(API.getErrorMsg('Could not fetch Jaeger info', error)); + console.log(error); + }); + };*/ +} + +export default ServiceTraces; diff --git a/src/pages/ServiceDetails/ServiceTraces/ServiceTracesJaeger.tsx b/src/pages/ServiceDetails/ServiceTraces/ServiceTracesJaeger.tsx new file mode 100644 index 0000000000..f22dd4fa4f --- /dev/null +++ b/src/pages/ServiceDetails/ServiceTraces/ServiceTracesJaeger.tsx @@ -0,0 +1,73 @@ +import * as React from 'react'; +import Iframe from 'react-iframe'; + +type ServiceTracesJaegerProps = { + service: string; + duration: number; + onlyErrors: boolean; +}; + +type ServiceTracesJaegerState = { + url: string; +}; + +class ServiceTracesJaeger extends React.Component { + constructor(props: ServiceTracesJaegerProps) { + super(props); + this.state = { + url: this.jaegerQuery() + }; + } + + jaegerQuery = () => { + const dateNow = Date.now(); + const start = (dateNow - this.props.duration * 1000) * 1000; + const end = dateNow * 1000; + const errors = this.props.onlyErrors ? `&tags=%7B"error"%3A"true"%7D` : ``; + const service = this.props.service === 'Filter by Service' ? `` : `&service=${this.props.service}`; + console.log( + `http://localhost:3000/search?embed` + + `&limit=20` + + `&start=${start}` + + `&end=${end}` + + `&maxDuration` + + `&minDuration` + + service + + errors + ); + return ( + `http://localhost:3000/search?embed` + + `&limit=20` + + `&start=${start}` + + `&end=${end}` + + `&maxDuration` + + `&minDuration` + + service + + errors + ); + }; + + componentDidUpdate(prevProps: ServiceTracesJaegerProps) { + if (this.props !== prevProps) { + this.setState({ + url: this.jaegerQuery() + }); + } + } + + render() { + return ( +
+