-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring marker component and waterfall helper
- Loading branch information
1 parent
a58e6aa
commit af9e22e
Showing
20 changed files
with
258 additions
and
130 deletions.
There are no files selected for viewing
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
61 changes: 61 additions & 0 deletions
61
...onDetails/WaterfallWithSummmary/WaterfallContainer/Marks/__test__/get_error_marks.test.ts
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,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { IWaterfallItem } from '../../Waterfall/waterfall_helpers/waterfall_helpers'; | ||
import { getErrorMarks } from '../get_error_marks'; | ||
|
||
describe('getErrorMarks', () => { | ||
describe('returns empty array', () => { | ||
it('when items are missing', () => { | ||
expect(getErrorMarks([])).toEqual([]); | ||
}); | ||
it('when any error is available', () => { | ||
const items = [ | ||
{ docType: 'span' }, | ||
{ docType: 'transaction' } | ||
] as IWaterfallItem[]; | ||
expect(getErrorMarks(items)).toEqual([]); | ||
}); | ||
}); | ||
|
||
it('returns error marks', () => { | ||
const items = [ | ||
{ | ||
docType: 'error', | ||
offset: 10, | ||
skew: 5, | ||
custom: { error: { id: 1 } }, | ||
serviceColor: 'blue' | ||
} as unknown, | ||
{ docType: 'transaction' }, | ||
{ | ||
docType: 'error', | ||
offset: 50, | ||
skew: 0, | ||
custom: { error: { id: 2 } }, | ||
serviceColor: 'red' | ||
} as unknown | ||
] as IWaterfallItem[]; | ||
expect(getErrorMarks(items)).toEqual([ | ||
{ | ||
type: 'errorMark', | ||
offset: 15, | ||
verticalLine: false, | ||
id: 1, | ||
error: { error: { id: 1 } }, | ||
serviceColor: 'blue' | ||
}, | ||
{ | ||
type: 'errorMark', | ||
offset: 50, | ||
verticalLine: false, | ||
id: 2, | ||
error: { error: { id: 2 } }, | ||
serviceColor: 'red' | ||
} | ||
]); | ||
}); | ||
}); |
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
35 changes: 35 additions & 0 deletions
35
.../app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/get_error_marks.ts
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,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { isEmpty } from 'lodash'; | ||
import { ErrorRaw } from '../../../../../../../typings/es_schemas/raw/ErrorRaw'; | ||
import { | ||
IWaterfallItem, | ||
IWaterfallError | ||
} from '../Waterfall/waterfall_helpers/waterfall_helpers'; | ||
import { Mark } from '.'; | ||
|
||
export interface ErrorMark extends Mark { | ||
type: 'errorMark'; | ||
error: ErrorRaw; | ||
serviceColor?: string; | ||
} | ||
|
||
export const getErrorMarks = (items: IWaterfallItem[]): ErrorMark[] => { | ||
if (isEmpty(items)) { | ||
return []; | ||
} | ||
|
||
return (items.filter( | ||
item => item.docType === 'error' | ||
) as IWaterfallError[]).map(error => ({ | ||
type: 'errorMark', | ||
offset: error.offset + error.skew, | ||
verticalLine: false, | ||
id: error.doc.error.id, | ||
error: error.doc, | ||
serviceColor: error.serviceColor | ||
})); | ||
}; |
12 changes: 12 additions & 0 deletions
12
...components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Marks/index.ts
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,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export interface Mark { | ||
type: string; | ||
offset: number; | ||
verticalLine: boolean; | ||
id: string; | ||
} |
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.