Skip to content

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

.changeset/plenty-foxes-destroy.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@spotlightjs/spotlight': minor
3+
'@spotlightjs/electron': minor
4+
'@spotlightjs/overlay': minor
5+
'@spotlightjs/astro': minor
6+
---
7+
8+
Flatter tree view for deeply nested traces with 1 child at each level

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"TEAMID",
3232
"treeshake",
3333
"ttfb",
34+
"txns",
3435
"unsign",
3536
"uuidv",
3637
"VITE",

packages/overlay/src/index.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ ul.tree ul {
4444
margin: 0;
4545
padding: 0;
4646
}
47-
ul.tree ul {
47+
ul.tree.deep > li > ul {
4848
margin-left: 8px;
4949
}
50-
ul.tree li {
50+
ul.tree.deep > li {
5151
@apply border-primary-400 border-l;
52+
padding-left: 1rem;
53+
margin-left: 1rem;
5254
}
5355

5456
ul.tree li:last-child {
@@ -59,11 +61,10 @@ ul.tree > li:first-child:before {
5961
display: none;
6062
}
6163

62-
ul.tree > li:before,
64+
ul.tree.deep > li:before,
6365
ul.tree ul.tree > li:before {
6466
@apply border-primary-400 border-b;
6567
position: absolute;
66-
margin-top: -2px;
6768
height: 15px;
6869
width: 12px;
6970
content: '';

packages/overlay/src/integrations/sentry/components/explore/traces/spans/SpanItem.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ const SpanItem = ({
3131
}) => {
3232
const { spanId } = useParams();
3333
const containerRef = useRef<HTMLLIElement>(null);
34+
const childrenCount = span.children ? span.children.length : 0;
3435
const [isItemCollapsed, setIsItemCollapsed] = useState(
35-
(span.transaction && totalTransactions > 1 && depth !== 1) || depth >= 15,
36+
(span.transaction && totalTransactions > 1 && depth !== 1) || depth >= 15 || childrenCount > 10,
3637
);
3738
const [isResizing, setIsResizing] = useState(false);
3839

@@ -51,7 +52,7 @@ const SpanItem = ({
5152
: false;
5253

5354
return (
54-
<li key={span.span_id} className="pl-4" ref={containerRef}>
55+
<li key={span.span_id} ref={containerRef}>
5556
<Link
5657
className={classNames(
5758
'hover:bg-primary-900 group flex text-sm',
@@ -74,15 +75,15 @@ const SpanItem = ({
7475
width: `${spanNodeWidth}%`,
7576
}}
7677
>
77-
{(span.children || []).length > 0 && (
78+
{childrenCount > 0 && (
7879
<div
7980
className="bg-primary-600 z-10 mr-1 flex items-center gap-1 rounded-lg px-1 text-xs font-bold text-white"
8081
onClick={e => {
8182
e.preventDefault();
8283
setIsItemCollapsed(prev => !prev);
8384
}}
8485
>
85-
{(span.children || []).length}
86+
{childrenCount}
8687
<ChevronIcon
8788
width={12}
8889
height={12}
@@ -128,7 +129,7 @@ const SpanItem = ({
128129
tree={span.children || []}
129130
startTimestamp={startTimestamp}
130131
totalDuration={totalDuration}
131-
depth={depth + 1}
132+
depth={childrenCount > 1 ? depth + 1 : depth}
132133
totalTransactions={totalTransactions}
133134
spanNodeWidth={spanNodeWidth}
134135
setSpanNodeWidth={setSpanNodeWidth}

packages/overlay/src/integrations/sentry/components/explore/traces/spans/SpanTree.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import classNames from '../../../../../../lib/classNames';
12
import { Span, TraceContext } from '../../../../types';
23
import SpanItem from './SpanItem';
34

@@ -25,7 +26,7 @@ export default function SpanTree({
2526
if (!tree || !tree.length) return null;
2627

2728
return (
28-
<ul className="tree">
29+
<ul className={classNames(tree.length > 1 && 'deep', 'tree')}>
2930
{tree.map(span => {
3031
return (
3132
<SpanItem

0 commit comments

Comments
 (0)