import './SpanDetailsDrawer.styles.scss'; import { Button, Tabs, TabsProps, Tooltip, Typography } from 'antd'; import cx from 'classnames'; import { getYAxisFormattedValue } from 'components/Graph/yAxisConfig'; import { QueryParams } from 'constants/query'; import ROUTES from 'constants/routes'; import { themeColors } from 'constants/theme'; import { getTraceToLogsQuery } from 'container/TraceDetail/SelectedSpanDetails/config'; import createQueryParams from 'lib/createQueryParams'; import history from 'lib/history'; import { generateColor } from 'lib/uPlotLib/utils/generateColor'; import { Anvil, Bookmark, Link2, PanelRight, Search } from 'lucide-react'; import { Dispatch, SetStateAction, useState } from 'react'; import { Span } from 'types/api/trace/getTraceV2'; import { formatEpochTimestamp } from 'utils/timeUtils'; import Attributes from './Attributes/Attributes'; import Events from './Events/Events'; import LinkedSpans from './LinkedSpans/LinkedSpans'; const FIVE_MINUTES_IN_MS = 5 * 60 * 1000; interface ISpanDetailsDrawerProps { isSpanDetailsDocked: boolean; setIsSpanDetailsDocked: Dispatch>; selectedSpan: Span | undefined; traceID: string; traceStartTime: number; traceEndTime: number; } function SpanDetailsDrawer(props: ISpanDetailsDrawerProps): JSX.Element { const { isSpanDetailsDocked, setIsSpanDetailsDocked, selectedSpan, traceStartTime, traceID, traceEndTime, } = props; const [isSearchVisible, setIsSearchVisible] = useState(false); const color = generateColor( selectedSpan?.serviceName || '', themeColors.traceDetailColors, ); function getItems(span: Span, startTime: number): TabsProps['items'] { return [ { label: ( ), key: 'attributes', children: , }, { label: ( ), key: 'events', children: ( ), }, { label: ( ), key: 'linked-spans', children: , }, ]; } const onLogsHandler = (): void => { const query = getTraceToLogsQuery(traceID, traceStartTime, traceEndTime); history.push( `${ROUTES.LOGS_EXPLORER}?${createQueryParams({ [QueryParams.compositeQuery]: JSON.stringify(query), // we subtract 5 minutes from the start time to handle the cases when the trace duration is in nanoseconds [QueryParams.startTime]: traceStartTime - FIVE_MINUTES_IN_MS, // we add 5 minutes to the end time for nano second duration traces [QueryParams.endTime]: traceEndTime + FIVE_MINUTES_IN_MS, })}`, ); }; return (
{!isSpanDetailsDocked && (
Span Details
)} setIsSpanDetailsDocked((prev) => !prev)} />
{selectedSpan && !isSpanDetailsDocked && ( <>
span name
{selectedSpan.name}
span id
{selectedSpan.spanId}
start time
{formatEpochTimestamp(selectedSpan.timestamp)}
duration
{getYAxisFormattedValue(`${selectedSpan.durationNano}`, 'ns')}
service
{selectedSpan.serviceName}
span kind
{selectedSpan.spanKind}
status code string
{selectedSpan.statusCodeString}
setIsSearchVisible((prev) => !prev)} /> } />
)}
); } export default SpanDetailsDrawer;