Skip to content

Commit

Permalink
Merge pull request #407 from bartoval/handle_undefined_trace
Browse files Browse the repository at this point in the history
refactor(General): ♻️ Handle undefined trace inputs
  • Loading branch information
bartoval authored Apr 30, 2024
2 parents e4742a4 + 2408f91 commit d35a5e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/core/utils/formatTrace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export function formatTraceBySites(trace: string) {
// TODO: We don't expect trace = undefined. Remove when BE TCP flowpair API is stabilized
export function formatTraceBySites(trace: string = '') {
const traceSanitized = trace.replace(/\|+$/, '');

if (!traceSanitized) {
Expand Down
8 changes: 5 additions & 3 deletions src/pages/shared/FlowPairs/FlowPair.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ const FlowPair: FC<{ flowPair: FlowPairsResponse }> = function ({ flowPair }) {

const duration = formatTimeInterval(endTimeMicroSeconds || Date.now() * 1000, startTimeMicroSenconds);

const isHtpp = protocol === AvailableProtocols.Http || protocol === AvailableProtocols.Http2;

return (
<Grid hasGutter data-testid={getTestsIds.flowPairsView(identity)}>
<GridItem span={12}>
{protocol === AvailableProtocols.Tcp && (
{!isHtpp && (
<>
<TextContent>
<Text component={TextVariants.h2}>
Expand All @@ -60,7 +62,7 @@ const FlowPair: FC<{ flowPair: FlowPairsResponse }> = function ({ flowPair }) {
<DescriptionList>
<DescriptionListGroup>
<DescriptionListTerm>{FlowPairLabels.Trace}</DescriptionListTerm>
<DescriptionListDescription>{formatTraceBySites(flowTrace)}</DescriptionListDescription>
<DescriptionListDescription>{formatTraceBySites(flowTrace) || '-'}</DescriptionListDescription>
{duration && (
<>
<DescriptionListTerm>{FlowPairLabels.Duration}</DescriptionListTerm>
Expand All @@ -73,7 +75,7 @@ const FlowPair: FC<{ flowPair: FlowPairsResponse }> = function ({ flowPair }) {
</Card>
</>
)}
{protocol !== AvailableProtocols.Tcp && (
{isHtpp && (
<>
<TextContent>
<Text component={TextVariants.h2}>
Expand Down

0 comments on commit d35a5e1

Please sign in to comment.