-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Traces: link to related resources (#7700)
## Summary Allow users to see the related session, errors, and logs with a trace from the trace view. These buttons will link the user to the page with the correct filter, but the user can also view errors and logs in the tabs below (for now). These tabs are planned to be removed in exchange for side panel views. ## How did you test this change? 1) View the traces and click on a traces - [ ] View errors button is disabled if no errors - [ ] Clicking view errors button links to errors page with correct filters - [ ] View session button is disabled if no session - [ ] Clicking view session button links to session with correct absolute time - [ ] View logs is enabled - [ ] Clicking on view logs button links to logs page with correct filters https://www.loom.com/share/217973d784c748a198151ff7d0dbfdfa?sid=50831ec3-3e35-43c1-9b71-c59d87a05a92 ## Are there any deployment considerations? N/A ## Does this work require review from our design team? N/A
- Loading branch information
1 parent
9ec938d
commit b96a82d
Showing
9 changed files
with
344 additions
and
58 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
frontend/src/__generated/ve/pages/Traces/RelatedResourceButtons/style.css.js
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,5 @@ | ||
// src/pages/Traces/RelatedResourceButtons/style.css.ts | ||
var tagLink = "_1fmffum0"; | ||
export { | ||
tagLink | ||
}; |
129 changes: 129 additions & 0 deletions
129
frontend/src/pages/Traces/RelatedResourceButtons/index.tsx
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,129 @@ | ||
import { | ||
Box, | ||
IconSolidLightningBolt, | ||
IconSolidLogs, | ||
IconSolidPlayCircle, | ||
Tag, | ||
} from '@highlight-run/ui/components' | ||
import moment from 'moment' | ||
import { createSearchParams } from 'react-router-dom' | ||
|
||
import { Link } from '@/components/Link' | ||
import { useProjectId } from '@/hooks/useProjectId' | ||
|
||
import * as styles from './style.css' | ||
|
||
const TAG_PROPS = { | ||
size: 'medium', | ||
kind: 'secondary', | ||
emphasis: 'medium', | ||
} as const | ||
|
||
type Props = { | ||
traceId?: string | ||
secureSessionId?: string | ||
disableErrors: boolean | ||
startDate: Date | ||
endDate: Date | ||
} | ||
|
||
const getErrorsLink = ( | ||
projectId: string, | ||
traceId: string, | ||
startDate: Date, | ||
endDate: Date, | ||
) => { | ||
const params = createSearchParams({ | ||
query: `and||error-field_trace_id,is,${traceId}`, | ||
start_date: moment(startDate).subtract(5, 'minutes').toISOString(), | ||
end_date: moment(endDate).add(5, 'minutes').toISOString(), | ||
}) | ||
|
||
return `/${projectId}/errors?${params}` | ||
} | ||
|
||
const getSessionLink = ( | ||
projectId: string, | ||
secureSessionId: string, | ||
startDate: Date, | ||
) => { | ||
const params = createSearchParams({ | ||
tsAbs: startDate.toISOString(), | ||
}) | ||
|
||
return `/${projectId}/sessions/${secureSessionId}?${params}` | ||
} | ||
|
||
const getLogsLink = ( | ||
projectId: string, | ||
traceId: string, | ||
startDate: Date, | ||
endDate: Date, | ||
) => { | ||
const params = createSearchParams({ | ||
query: `trace_id=${traceId}`, | ||
start_date: moment(startDate).subtract(5, 'minutes').toISOString(), | ||
end_date: moment(endDate).add(5, 'minutes').toISOString(), | ||
}) | ||
|
||
return `/${projectId}/logs?${params}` | ||
} | ||
|
||
export const RelatedResourceButtons: React.FC<Props> = ({ | ||
traceId, | ||
secureSessionId, | ||
disableErrors, | ||
startDate, | ||
endDate, | ||
}) => { | ||
const { projectId } = useProjectId() | ||
const errorLinkDisabled = !traceId || disableErrors | ||
const sessionLinkDisabled = !traceId || !secureSessionId | ||
const logsLinkDisabled = !traceId | ||
|
||
const errorLink = errorLinkDisabled | ||
? '' | ||
: getErrorsLink(projectId, traceId, startDate, endDate) | ||
const sessionLink = sessionLinkDisabled | ||
? '' | ||
: getSessionLink(projectId, secureSessionId, startDate) | ||
|
||
const logsLink = logsLinkDisabled | ||
? '' | ||
: getLogsLink(projectId, traceId, startDate, endDate) | ||
|
||
return ( | ||
<Box> | ||
<Link to={errorLink} className={styles.tagLink} reloadDocument> | ||
<Tag | ||
{...TAG_PROPS} | ||
shape="leftBasic" | ||
iconLeft={<IconSolidLightningBolt />} | ||
disabled={errorLinkDisabled} | ||
> | ||
View errors | ||
</Tag> | ||
</Link> | ||
<Link to={sessionLink} className={styles.tagLink}> | ||
<Tag | ||
{...TAG_PROPS} | ||
shape="square" | ||
iconLeft={<IconSolidPlayCircle />} | ||
disabled={sessionLinkDisabled} | ||
> | ||
View session | ||
</Tag> | ||
</Link> | ||
<Link to={logsLink} className={styles.tagLink}> | ||
<Tag | ||
{...TAG_PROPS} | ||
shape="rightBasic" | ||
iconLeft={<IconSolidLogs />} | ||
disabled={logsLinkDisabled} | ||
> | ||
View logs | ||
</Tag> | ||
</Link> | ||
</Box> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
frontend/src/pages/Traces/RelatedResourceButtons/style.css.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,11 @@ | ||
import { globalStyle, style } from '@vanilla-extract/css' | ||
|
||
export const tagLink = style({}) | ||
|
||
globalStyle(`${tagLink}:first-of-type > button`, { | ||
borderRight: 'none', | ||
}) | ||
|
||
globalStyle(`${tagLink}:last-of-type > button`, { | ||
borderLeft: 'none', | ||
}) |
Oops, something went wrong.