Skip to content

Commit

Permalink
Merge branch 'main' into priyanshu-kun/jaegertracing#1723
Browse files Browse the repository at this point in the history
Signed-off-by: priyanshu-kun <[email protected]>
  • Loading branch information
priyanshu-kun committed Sep 24, 2023
2 parents 2bb0915 + 574ffe0 commit 38c28d6
Show file tree
Hide file tree
Showing 33 changed files with 490 additions and 267 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"eslint-plugin-react": "7.33.2",
"husky": "8.0.3",
"jsdom": "22.1.0",
"lerna": "7.2.0",
"lerna": "7.3.0",
"npm-run-all": "4.1.5",
"prettier": "3.0.3",
"rxjs-compat": "6.6.7",
Expand Down
12 changes: 6 additions & 6 deletions packages/jaeger-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@types/lodash": "^4.14.123",
"@types/object-hash": "^3.0.2",
"@types/react-helmet": "^6.1.5",
"@types/react-redux": "^5.0.6",
"@types/react-redux": "^7.1.26",
"@types/react-router-dom": "^4.3.1",
"@types/redux-actions": "2.2.1",
"antd": "4.24.13",
Expand All @@ -60,6 +60,7 @@
"cytoscape": "^3.2.1",
"cytoscape-dagre": "^2.0.0",
"dagre": "^0.8.5",
"dayjs": "^1.11.9",
"deep-freeze": "^0.0.1",
"drange": "^2.0.0",
"global": "^4.3.2",
Expand All @@ -71,7 +72,6 @@
"lru-memoize": "^1.1.0",
"match-sorter": "^6.3.1",
"memoize-one": "^6.0.0",
"moment": "^2.18.1",
"object-hash": "^3.0.0",
"prop-types": "^15.5.10",
"query-string": "^8.1.0",
Expand All @@ -83,15 +83,15 @@
"react-helmet": "^6.1.0",
"react-icons": "^4.10.1",
"react-is": "^18.2.0",
"react-json-view-lite": "^0.9.8",
"react-redux": "^5.0.6",
"react-json-view-lite": "1.0.0",
"react-redux": "^8.1.2",
"react-router-dom": "4.3.1",
"react-router-redux": "5.0.0-alpha.8",
"react-vis": "^1.7.2",
"react-vis-force": "^0.3.1",
"react-window": "^1.8.3",
"redux": "^3.7.2",
"redux-actions": "^2.2.1",
"redux": "^4.2.1",
"redux-actions": "2.6.5",
"redux-form": "^8.3.10",
"redux-promise-middleware": "^5.1.1",
"reselect": "^4.1.6",
Expand Down
7 changes: 5 additions & 2 deletions packages/jaeger-ui/src/api/jaeger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
// limitations under the License.

import fetch from 'isomorphic-fetch';
import moment from 'moment';
import dayjs from 'dayjs';
import _duration from 'dayjs/plugin/duration';
import queryString from 'query-string';

import prefixUrl from '../utils/prefix-url';

dayjs.extend(_duration);

// export for tests
export function getMessageFromError(errData, status) {
if (errData.code != null && errData.msg != null) {
Expand Down Expand Up @@ -78,7 +81,7 @@ function getJSON(url, options = {}) {

export const DEFAULT_API_ROOT = prefixUrl('/api/');
export const ANALYTICS_ROOT = prefixUrl('/analytics/');
export const DEFAULT_DEPENDENCY_LOOKBACK = moment.duration(1, 'weeks').asMilliseconds();
export const DEFAULT_DEPENDENCY_LOOKBACK = dayjs.duration(1, 'weeks').asMilliseconds();

const JaegerAPI = {
apiRoot: DEFAULT_API_ROOT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ exports[`JaegerUIApp does not explode 1`] = `
<Provider
store={
Object {
"@@observable": [Function],
"dispatch": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
Symbol(observable): [Function],
}
}
>
Expand All @@ -33,31 +33,82 @@ exports[`JaegerUIApp does not explode 1`] = `
"replace": [Function],
}
}
store={
Object {
"@@observable": [Function],
"dispatch": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
}
}
>
<withRouter(Connect(PageImpl))>
<Switch>
<Route
component={[Function]}
component={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
path="/search"
/>
<Route
component={[Function]}
component={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
path="/trace/:a?\\\\.\\\\.\\\\.:b?"
/>
<Route
component={[Function]}
component={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
path="/trace/:id"
/>
<Route
component={[Function]}
component={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
path="/dependencies"
/>
<Route
component={[Function]}
component={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
path="/deep-dependencies"
/>
<Route
component={[Function]}
component={
Object {
"$$typeof": Symbol(react.memo),
"WrappedComponent": [Function],
"compare": null,
"type": [Function],
}
}
path="/quality-metrics"
/>
<Route
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/components/App/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class JaegerUIApp extends Component {
render() {
return (
<Provider store={this.store}>
<ConnectedRouter history={history}>
<ConnectedRouter store={this.store} history={history}>
<Page>
<Switch>
<Route path={searchPath} component={SearchTracePage} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,10 @@ export function mapStateToProps(state: ReduxState): TReduxProps {
}

export function mapDispatchToProps(dispatch: Dispatch<ReduxState>): TDispatchProps {
const { fetchServices, fetchAllServiceMetrics, fetchAggregatedServiceMetrics } = bindActionCreators<any>(
jaegerApiActions,
dispatch
);
const { fetchServices, fetchAllServiceMetrics, fetchAggregatedServiceMetrics } = bindActionCreators<
{},
any
>(jaegerApiActions, dispatch);

return {
fetchServices,
Expand Down
10 changes: 5 additions & 5 deletions packages/jaeger-ui/src/components/SearchTracePage/SearchForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Input, Button, Popover, Select, Row, Col } from 'antd';
import _get from 'lodash/get';
import logfmtParser from 'logfmt/lib/logfmt_parser';
import { stringify as logfmtStringify } from 'logfmt/lib/stringify';
import moment from 'moment';
import dayjs from 'dayjs';
import memoizeOne from 'memoize-one';
import PropTypes from 'prop-types';
import queryString from 'query-string';
Expand Down Expand Up @@ -50,8 +50,8 @@ export function getUnixTimeStampInMSFromForm({ startDate, startDateTime, endDate
const start = `${startDate} ${startDateTime}`;
const end = `${endDate} ${endDateTime}`;
return {
start: `${moment(start, 'YYYY-MM-DD HH:mm').valueOf()}000`,
end: `${moment(end, 'YYYY-MM-DD HH:mm').valueOf()}000`,
start: `${dayjs(start, 'YYYY-MM-DD HH:mm').valueOf()}000`,
end: `${dayjs(end, 'YYYY-MM-DD HH:mm').valueOf()}000`,
};
}

Expand All @@ -73,7 +73,7 @@ export function convTagsLogfmt(tags) {

export function lookbackToTimestamp(lookback, from) {
const unit = lookback.substr(-1);
return moment(from).subtract(parseInt(lookback, 10), unit).valueOf() * 1000;
return dayjs(from).subtract(parseInt(lookback, 10), unit).valueOf() * 1000;
}

const lookbackOptions = [
Expand Down Expand Up @@ -538,7 +538,7 @@ export function mapStateToProps(state) {
traceID: traceIDParams,
} = queryString.parse(state.router.location.search);

const nowInMicroseconds = moment().valueOf() * 1000;
const nowInMicroseconds = dayjs().valueOf() * 1000;
const today = formatDate(nowInMicroseconds);
const currentTime = formatTime(nowInMicroseconds);
const lastSearch = store.get('lastSearch');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jest.mock('store');

import React from 'react';
import { shallow } from 'enzyme';
import moment from 'moment';
import dayjs from 'dayjs';
import queryString from 'query-string';
import store from 'store';

Expand Down Expand Up @@ -87,19 +87,16 @@ describe('conversion utils', () => {

describe('convertQueryParamsToFormDates()', () => {
it('converts correctly', () => {
const startMoment = moment().subtract(1, 'day');
const endMoment = moment();
const params = {
start: `${startMoment.valueOf()}000`,
end: `${endMoment.valueOf()}000`,
};

const { queryStartDate, queryStartDateTime, queryEndDate, queryEndDateTime } =
convertQueryParamsToFormDates(params);
expect(queryStartDate).toBe(startMoment.format(DATE_FORMAT));
expect(queryStartDateTime).toBe(startMoment.format(TIME_FORMAT));
expect(queryEndDate).toBe(endMoment.format(DATE_FORMAT));
expect(queryEndDateTime).toBe(endMoment.format(TIME_FORMAT));
convertQueryParamsToFormDates({
start: '946720800000000', // Jan 1, 2000 10:00 AM
end: '946807200000000', // Jan 2, 2000 10:00 AM
});

expect(queryStartDate).toBe('2000-01-01');
expect(queryStartDateTime).toBe('10:00');
expect(queryEndDate).toBe('2000-01-02');
expect(queryEndDateTime).toBe('10:00');
});
});

Expand Down Expand Up @@ -298,7 +295,7 @@ describe('submitForm()', () => {
function getCalledDuration(mock) {
const { start, end } = mock.calls[0][0];
const diffMs = (Number(end) - Number(start)) / 1000;
return moment.duration(diffMs);
return dayjs.duration(diffMs);
}

it('subtracts `lookback` from `fields.end`', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import { LocationDescriptor } from 'history';
import { Link } from 'react-router-dom';

import { sortBy } from 'lodash';
import moment from 'moment';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';

import { IoAlert } from 'react-icons/io5';

Expand All @@ -32,6 +33,8 @@ import { KeyValuePair, Trace } from '../../../types/trace';

import './ResultItem.css';

dayjs.extend(relativeTime);

type Props = {
durationPercent: number;
isInDiffCohort: boolean;
Expand All @@ -57,7 +60,7 @@ export default class ResultItem extends React.PureComponent<Props, State> {
super(props, state);
const { startTime, spans } = props.trace;

const mDate = moment(startTime / 1000);
const startTimeDayjs = dayjs(startTime / 1000);

const erroredServices: Set<string> = new Set<string>();

Expand All @@ -71,8 +74,8 @@ export default class ResultItem extends React.PureComponent<Props, State> {

this.state = {
numSpans: spans.length,
timeStr: mDate.format('h:mm:ss a'),
fromNow: mDate.fromNow(),
timeStr: startTimeDayjs.format('h:mm:ss a'),
fromNow: startTimeDayjs.fromNow(),
numErredSpans,
erroredServices,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import React, { useRef, useState, useLayoutEffect } from 'react';
import moment from 'moment';
import dayjs from 'dayjs';
import PropTypes from 'prop-types';
import { XYPlot, XAxis, YAxis, MarkSeries, Hint } from 'react-vis';

Expand Down Expand Up @@ -68,7 +68,7 @@ export default function ScatterPlot(props) {
<XAxis
title="Time"
tickTotal={4}
tickFormat={t => moment(t / ONE_MILLISECOND).format('hh:mm:ss a')}
tickFormat={t => dayjs(t / ONE_MILLISECOND).format('hh:mm:ss a')}
/>
<YAxis title="Duration" tickTotal={3} tickFormat={t => formatDuration(t)} />
<MarkSeries
Expand Down
1 change: 0 additions & 1 deletion packages/jaeger-ui/src/components/TraceDiff/TraceDiff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import * as React from 'react';
import { History as RouterHistory } from 'history';
import queryString from 'query-string';
import { connect } from 'react-redux';
import { match } from 'react-router-dom';
import { bindActionCreators, Dispatch } from 'redux';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import React, { Component } from 'react';
import { Row, Col, Table, Button, Select } from 'antd';
import moment from 'moment';
import dayjs from 'dayjs';
import { ColumnProps } from 'antd/es/table';
import { Form } from '@ant-design/compatible';
import './index.css';
Expand Down Expand Up @@ -172,7 +172,7 @@ export default class TraceSpanView extends Component<Props, State> {
dataIndex: 'startTime',
sorter: (a, b) => a.startTime - b.startTime,
render: (cell: number) => {
return moment(cell / 1000).format('DD MMM YYYY hh:mm A');
return dayjs(cell / 1000).format('DD MMM YYYY hh:mm A');
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,19 @@ function formatValue(key: string, value: any) {
content = (
<JsonView
data={parsed}
shouldInitiallyExpand={shouldJsonTreeExpand ? allExpanded : collapseAllNested}
shouldExpandNode={shouldJsonTreeExpand ? allExpanded : collapseAllNested}
style={{
...defaultStyles,
container: 'json-markup',
label: 'json-markup-key',
stringValue: 'json-markup-string',
collapseIcon: 'json-markup-icon-collapse',
collapsedContent: 'json-markup-collapse-content',
expandIcon: 'json-markup-icon-expand',
numberValue: 'json-markup-number',
booleanValue: 'json-markup-bool',
nullValue: 'json-markup-null',
undefinedValue: 'json-markup-undefined',
expander: 'json-markup-expander',
basicChildStyle: 'json-markup-child',
punctuation: 'json-markup-puncuation',
otherValue: 'json-markup-other',
Expand Down
Loading

0 comments on commit 38c28d6

Please sign in to comment.