mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Trace View: Show number of child spans in span details view (#44393)
* package(jaegar): show no of child spans in view Signed-off-by: tharun <rajendrantharun@live.com> Co-authored-by: Connor Lindsey <cblindsey3@gmail.com>
This commit is contained in:
parent
190757b3c6
commit
970dee4199
@ -29,20 +29,21 @@ import { SpanLinkFunc, TNil } from '../../types';
|
|||||||
import { TraceKeyValuePair, TraceLink, TraceLog, TraceSpan, TraceSpanReference } from '../../types/trace';
|
import { TraceKeyValuePair, TraceLink, TraceLog, TraceSpan, TraceSpanReference } from '../../types/trace';
|
||||||
import AccordianReferences from './AccordianReferences';
|
import AccordianReferences from './AccordianReferences';
|
||||||
import { autoColor } from '../../Theme';
|
import { autoColor } from '../../Theme';
|
||||||
|
import { uAlignIcon, ubM0, ubMb1, ubMy1, ubTxRightAlign } from '../../uberUtilityStyles';
|
||||||
import { Divider } from '../../common/Divider';
|
import { Divider } from '../../common/Divider';
|
||||||
import {
|
|
||||||
uAlignIcon,
|
|
||||||
ubFlex,
|
|
||||||
ubFlexAuto,
|
|
||||||
ubItemsCenter,
|
|
||||||
ubM0,
|
|
||||||
ubMb1,
|
|
||||||
ubMy1,
|
|
||||||
ubTxRightAlign,
|
|
||||||
} from '../../uberUtilityStyles';
|
|
||||||
|
|
||||||
const getStyles = (theme: GrafanaTheme2) => {
|
const getStyles = (theme: GrafanaTheme2) => {
|
||||||
return {
|
return {
|
||||||
|
header: css`
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0 1rem;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
`,
|
||||||
|
listWrapper: css`
|
||||||
|
overflow: hidden;
|
||||||
|
`,
|
||||||
debugInfo: css`
|
debugInfo: css`
|
||||||
label: debugInfo;
|
label: debugInfo;
|
||||||
display: block;
|
display: block;
|
||||||
@ -173,6 +174,15 @@ export default function SpanDetail(props: SpanDetailProps) {
|
|||||||
label: 'Start Time:',
|
label: 'Start Time:',
|
||||||
value: formatDuration(relativeStartTime),
|
value: formatDuration(relativeStartTime),
|
||||||
},
|
},
|
||||||
|
...(span.childSpanCount > 0
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
key: 'child_count',
|
||||||
|
label: 'Child Count:',
|
||||||
|
value: span.childSpanCount,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
];
|
];
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
const link = createSpanLink?.(span);
|
const link = createSpanLink?.(span);
|
||||||
@ -180,9 +190,11 @@ export default function SpanDetail(props: SpanDetailProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className={cx(ubFlex, ubItemsCenter, ubMb1)}>
|
<div className={styles.header}>
|
||||||
<h2 className={cx(ubFlexAuto, ubM0)}>{operationName}</h2>
|
<h2 className={cx(ubM0)}>{operationName}</h2>
|
||||||
<LabeledList className={ubTxRightAlign} items={overviewItems} />
|
<div className={styles.listWrapper}>
|
||||||
|
<LabeledList className={ubTxRightAlign} divider={true} items={overviewItems} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{link ? (
|
{link ? (
|
||||||
<DataLinkButton link={{ ...link, title: 'Logs for this span' } as any} buttonProps={{ icon: 'gf-logs' }} />
|
<DataLinkButton link={{ ...link, title: 'Logs for this span' } as any} buttonProps={{ icon: 'gf-logs' }} />
|
||||||
|
@ -20,6 +20,7 @@ import {
|
|||||||
isServerSpan,
|
isServerSpan,
|
||||||
spanContainsErredSpan,
|
spanContainsErredSpan,
|
||||||
spanHasTag,
|
spanHasTag,
|
||||||
|
formatNumber,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
import traceGenerator from '../demo/trace-generators';
|
import traceGenerator from '../demo/trace-generators';
|
||||||
|
@ -17,20 +17,31 @@ import { css } from '@emotion/css';
|
|||||||
import cx from 'classnames';
|
import cx from 'classnames';
|
||||||
import { useStyles2 } from '@grafana/ui';
|
import { useStyles2 } from '@grafana/ui';
|
||||||
import { GrafanaTheme2 } from '@grafana/data';
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
|
import { autoColor } from '../Theme';
|
||||||
|
|
||||||
import { Divider } from './Divider';
|
const getStyles = (divider: boolean) => (theme: GrafanaTheme2) => {
|
||||||
|
|
||||||
const getStyles = (theme: GrafanaTheme2) => {
|
|
||||||
return {
|
return {
|
||||||
LabeledList: css`
|
LabeledList: css`
|
||||||
label: LabeledList;
|
label: LabeledList;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
${divider === true &&
|
||||||
|
`
|
||||||
|
margin-right: -8px;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: flex-end;
|
||||||
|
`}
|
||||||
`,
|
`,
|
||||||
LabeledListItem: css`
|
LabeledListItem: css`
|
||||||
label: LabeledListItem;
|
label: LabeledListItem;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
${divider === true &&
|
||||||
|
`
|
||||||
|
border-right: 1px solid ${autoColor(theme, '#ddd')};
|
||||||
|
padding: 0 8px;
|
||||||
|
`}
|
||||||
`,
|
`,
|
||||||
LabeledListLabel: css`
|
LabeledListLabel: css`
|
||||||
label: LabeledListLabel;
|
label: LabeledListLabel;
|
||||||
@ -42,27 +53,23 @@ const getStyles = (theme: GrafanaTheme2) => {
|
|||||||
|
|
||||||
type LabeledListProps = {
|
type LabeledListProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
divider?: boolean;
|
||||||
items: Array<{ key: string; label: React.ReactNode; value: React.ReactNode }>;
|
items: Array<{ key: string; label: React.ReactNode; value: React.ReactNode }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function LabeledList(props: LabeledListProps) {
|
export default function LabeledList(props: LabeledListProps) {
|
||||||
const { className, items } = props;
|
const { className, divider = false, items } = props;
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles(divider));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className={cx(styles.LabeledList, className)}>
|
<ul className={cx(styles.LabeledList, className)}>
|
||||||
{items.map(({ key, label, value }, i) => {
|
{items.map(({ key, label, value }) => {
|
||||||
const divider = i < items.length - 1 && (
|
return (
|
||||||
<li className={styles.LabeledListItem} key={`${key}--divider`}>
|
<li className={styles.LabeledListItem} key={`${key}`}>
|
||||||
<Divider />
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
return [
|
|
||||||
<li className={styles.LabeledListItem} key={key}>
|
|
||||||
<span className={styles.LabeledListLabel}>{label}</span>
|
<span className={styles.LabeledListLabel}>{label}</span>
|
||||||
<strong>{value}</strong>
|
<strong>{value}</strong>
|
||||||
</li>,
|
</li>
|
||||||
divider,
|
);
|
||||||
];
|
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
|
@ -138,6 +138,7 @@ export default function transformTraceData(data: TraceResponse | undefined): Tra
|
|||||||
span.relativeStartTime = span.startTime - traceStartTime;
|
span.relativeStartTime = span.startTime - traceStartTime;
|
||||||
span.depth = depth - 1;
|
span.depth = depth - 1;
|
||||||
span.hasChildren = node.children.length > 0;
|
span.hasChildren = node.children.length > 0;
|
||||||
|
span.childSpanCount = node.children.length;
|
||||||
span.warnings = span.warnings || [];
|
span.warnings = span.warnings || [];
|
||||||
span.tags = span.tags || [];
|
span.tags = span.tags || [];
|
||||||
span.references = span.references || [];
|
span.references = span.references || [];
|
||||||
|
@ -68,6 +68,7 @@ export type TraceSpanData = {
|
|||||||
export type TraceSpan = TraceSpanData & {
|
export type TraceSpan = TraceSpanData & {
|
||||||
depth: number;
|
depth: number;
|
||||||
hasChildren: boolean;
|
hasChildren: boolean;
|
||||||
|
childSpanCount: number;
|
||||||
process: TraceProcess;
|
process: TraceProcess;
|
||||||
relativeStartTime: number;
|
relativeStartTime: number;
|
||||||
tags: NonNullable<TraceSpanData['tags']>;
|
tags: NonNullable<TraceSpanData['tags']>;
|
||||||
|
@ -34,6 +34,10 @@ export const ubItemsCenter = css`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const ubItemsStart = css`
|
||||||
|
align-items: start;
|
||||||
|
`;
|
||||||
|
|
||||||
export const ubFlexAuto = css`
|
export const ubFlexAuto = css`
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
min-width: 0; /* 1 */
|
min-width: 0; /* 1 */
|
||||||
|
Loading…
Reference in New Issue
Block a user