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

Adds a configuration option to customize the standard datetime format #403

Closed
wants to merge 6 commits into from
Closed
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
3 changes: 2 additions & 1 deletion packages/jaeger-ui/src/constants/default-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import deepFreeze from 'deep-freeze';

import { FALLBACK_DAG_MAX_NUM_SERVICES } from './index';
import { FALLBACK_DAG_MAX_NUM_SERVICES, FALLBACK_STANDARD_DATETIME_FORMAT } from './index';

export default deepFreeze(
Object.defineProperty(
Expand Down Expand Up @@ -66,6 +66,7 @@ export default deepFreeze(
gaID: null,
trackErrors: true,
},
standardDatetimeFormat: FALLBACK_STANDARD_DATETIME_FORMAT,
Copy link
Member

Choose a reason for hiding this comment

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

Since this is used in only one place, I don't think it's the "standard" date time format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I called it like that, because it overrides the format used by the STANDARD_DATETIME_FORMAT constant. Today, it's only used in one place, but if other bits of the UI start using https://github.com/jaegertracing/jaeger-ui/blob/master/packages/jaeger-ui/src/utils/date.tsx#L64 they will also be affected. I'm fine with calling it "traceStartDateFormat" too :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tiffon What do you suggest? Shall I remove the config option and add the fractional seconds to the format as shown below? Or should I keep the config and just rename the variable to remove the standard_ prefix?

},
// fields that should be individually merged vs wholesale replaced
'__mergeFields',
Expand Down
1 change: 1 addition & 0 deletions packages/jaeger-ui/src/constants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const TOP_NAV_HEIGHT = 47 as 47;

export const FALLBACK_DAG_MAX_NUM_SERVICES = 100 as 100;
export const FALLBACK_TRACE_NAME = '<trace-without-root-span>' as '<trace-without-root-span>';
export const FALLBACK_STANDARD_DATETIME_FORMAT = 'LLL';

export const FETCH_DONE = 'FETCH_DONE' as 'FETCH_DONE';
export const FETCH_ERROR = 'FETCH_ERROR' as 'FETCH_ERROR';
Expand Down
5 changes: 4 additions & 1 deletion packages/jaeger-ui/src/utils/date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ import moment from 'moment';
import _round from 'lodash/round';

import { toFloatPrecision } from './number';
import { getConfigValue } from './config/get-config';
import { FALLBACK_STANDARD_DATETIME_FORMAT } from '../constants';

const TODAY = 'Today';
const YESTERDAY = 'Yesterday';

export const STANDARD_DATE_FORMAT = 'YYYY-MM-DD';
export const STANDARD_TIME_FORMAT = 'HH:mm';
export const STANDARD_DATETIME_FORMAT = 'LLL';
export const STANDARD_DATETIME_FORMAT =
getConfigValue('standardDatetimeFormat') || FALLBACK_STANDARD_DATETIME_FORMAT;
export const ONE_MILLISECOND = 1000;
export const ONE_SECOND = 1000 * ONE_MILLISECOND;
export const DEFAULT_MS_PRECISION = Math.log10(ONE_MILLISECOND);
Expand Down