Skip to content

Commit

Permalink
use human formats
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Jun 7, 2021
1 parent f5dc9d1 commit 0cdf5a5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
LCP_FIELD,
TBT_FIELD,
TRANSACTION_DURATION,
TRANSACTION_TIME_TO_FIRST_BYTE,
} from '../constants/elasticsearch_fieldnames';

export const rumFieldFormats: FieldFormat[] = [
Expand All @@ -24,6 +25,7 @@ export const rumFieldFormats: FieldFormat[] = [
outputFormat: 'asSeconds',
showSuffix: true,
outputPrecision: 1,
useShortSuffix: true,
},
},
},
Expand All @@ -33,8 +35,9 @@ export const rumFieldFormats: FieldFormat[] = [
id: 'duration',
params: {
inputFormat: 'milliseconds',
outputFormat: 'asSeconds',
outputFormat: 'humanizePrecise',
showSuffix: true,
useShortSuffix: true,
},
},
},
Expand All @@ -44,8 +47,9 @@ export const rumFieldFormats: FieldFormat[] = [
id: 'duration',
params: {
inputFormat: 'milliseconds',
outputFormat: 'asSeconds',
outputFormat: 'humanizePrecise',
showSuffix: true,
useShortSuffix: true,
},
},
},
Expand All @@ -55,8 +59,9 @@ export const rumFieldFormats: FieldFormat[] = [
id: 'duration',
params: {
inputFormat: 'milliseconds',
outputFormat: 'asSeconds',
outputFormat: 'humanizePrecise',
showSuffix: true,
useShortSuffix: true,
},
},
},
Expand All @@ -66,8 +71,21 @@ export const rumFieldFormats: FieldFormat[] = [
id: 'duration',
params: {
inputFormat: 'milliseconds',
outputFormat: 'asSeconds',
outputFormat: 'humanizePrecise',
showSuffix: true,
useShortSuffix: true,
},
},
},
{
field: TRANSACTION_TIME_TO_FIRST_BYTE,
format: {
id: 'duration',
params: {
inputFormat: 'milliseconds',
outputFormat: 'humanizePrecise',
showSuffix: true,
useShortSuffix: true,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function getKPITrendsLensConfig({ seriesId, indexPattern }: ConfigProps):
id: seriesId,
defaultSeriesType: 'bar_stacked',
reportType: 'kpi-trends',
seriesTypes: ['bar', 'bar_stacked'],
seriesTypes: [],
xAxisColumn: {
sourceField: '@timestamp',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function getPerformanceDistLensConfig({ seriesId, indexPattern }: ConfigP
id: seriesId ?? 'unique-key',
reportType: 'page-load-dist',
defaultSeriesType: 'line',
seriesTypes: ['line', 'bar'],
seriesTypes: [],
xAxisColumn: {
sourceField: 'performance.metric',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export const syntheticsFieldFormats: FieldFormat[] = [
id: 'duration',
params: {
inputFormat: 'microseconds',
outputFormat: 'asMilliseconds',
outputPrecision: 0,
outputFormat: 'humanizePrecise',
outputPrecision: 1,
showSuffix: true,
useShortSuffix: true,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getMonitorDurationConfig({ seriesId, indexPattern }: ConfigProps
id: seriesId,
reportType: 'uptime-duration',
defaultSeriesType: 'line',
seriesTypes: ['line', 'bar_stacked'],
seriesTypes: [],
xAxisColumn: {
sourceField: '@timestamp',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getMonitorPingsConfig({ seriesId, indexPattern }: ConfigProps):
id: seriesId,
reportType: 'uptime-pings',
defaultSeriesType: 'bar_stacked',
seriesTypes: ['bar_stacked', 'bar'],
seriesTypes: [],
xAxisColumn: {
sourceField: '@timestamp',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,14 @@ export type AppDataType = 'synthetics' | 'ux' | 'infra_logs' | 'infra_metrics' |

type FormatType = 'duration' | 'number';
type InputFormat = 'microseconds' | 'milliseconds' | 'seconds';
type OutputFormat = 'asSeconds' | 'asMilliseconds' | 'humanize';
type OutputFormat = 'asSeconds' | 'asMilliseconds' | 'humanize' | 'humanizePrecise';

export interface FieldFormatParams {
inputFormat: InputFormat;
outputFormat: OutputFormat;
outputPrecision?: number;
showSuffix?: boolean;
useShortSuffix?: boolean;
}

export interface FieldFormat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function isParamsSame(param1: IFieldFormat['_params'], param2: FieldForma
const isSame =
param1?.inputFormat === param2?.inputFormat &&
param1?.outputFormat === param2?.outputFormat &&
param1?.useShortSuffix === param2?.useShortSuffix &&
param1?.showSuffix === param2?.showSuffix;

if (param2.outputPrecision !== undefined) {
Expand Down

0 comments on commit 0cdf5a5

Please sign in to comment.