@@ -73,8 +55,6 @@ export default function TraceDetails() {
totalTransactions={(trace.transactions || []).length}
/>
) : null}
-
- {isTraceInfo &&
}
>
);
}
diff --git a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx
new file mode 100644
index 00000000..a68f347d
--- /dev/null
+++ b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx
@@ -0,0 +1,71 @@
+import { Link, Navigate, Route, Routes, useParams } from 'react-router-dom';
+import Tabs from '~/components/Tabs';
+import { default as dataCache, default as sentryDataCache } from '../../../data/sentryDataCache';
+import TraceContext from './components/TraceContext';
+import TraceDetailHeader from './components/TraceDetailHeader';
+import TraceErrors from './components/TraceErrors';
+import TraceTreeview from './components/TraceTreeview';
+
+export default function TraceDetails() {
+ const { traceId } = useParams();
+
+ if (!traceId) {
+ return
Unknown trace id
;
+ }
+
+ const trace = dataCache.getTraceById(traceId);
+
+ if (!trace) {
+ return (
+
+ Trace not found. Check for more{' '}
+
+ traces
+
+
+ );
+ }
+
+ const errorCount = sentryDataCache
+ .getEventsByTrace(traceId)
+ .filter(
+ e =>
+ e.type != 'transaction' &&
+ (e.contexts?.trace?.trace_id ? sentryDataCache.isTraceLocal(e.contexts?.trace?.trace_id) : null) !== false,
+ ).length;
+
+ const tabs = [
+ {
+ id: 'details',
+ title: 'Details',
+ },
+ {
+ id: 'context',
+ title: 'Context',
+ },
+ {
+ id: 'errors',
+ title: 'Errors',
+ notificationCount: {
+ count: errorCount,
+ severe: errorCount > 0,
+ },
+ },
+ ];
+
+ return (
+ <>
+
+
+
+
+ } />
+ } />
+ } />
+ } />
+ {/* Default tab */}
+ } />
+
+ >
+ );
+}
diff --git a/packages/overlay/src/integrations/sentry/components/traces/spans/SpanDetails.tsx b/packages/overlay/src/integrations/sentry/components/traces/spans/SpanDetails.tsx
index a60ef4ad..d03697fa 100644
--- a/packages/overlay/src/integrations/sentry/components/traces/spans/SpanDetails.tsx
+++ b/packages/overlay/src/integrations/sentry/components/traces/spans/SpanDetails.tsx
@@ -159,7 +159,7 @@ export default function SpanDetails({
span.parent_span_id ? (
{span.parent_span_id}
diff --git a/packages/overlay/src/integrations/sentry/components/traces/spans/SpanItem.tsx b/packages/overlay/src/integrations/sentry/components/traces/spans/SpanItem.tsx
index 8c03d8a8..43838b83 100644
--- a/packages/overlay/src/integrations/sentry/components/traces/spans/SpanItem.tsx
+++ b/packages/overlay/src/integrations/sentry/components/traces/spans/SpanItem.tsx
@@ -61,7 +61,7 @@ const SpanItem = ({
style={{
pointerEvents: isResizing ? 'none' : 'auto',
}}
- to={`/traces/${span.trace_id}/${span.span_id}`}
+ to={`/traces/${span.trace_id}/spans/${span.span_id}`}
>
-
-
{trace.rootTransactionName}
-
-
- T:{' '}
-
- {trace.trace_id}
-
-
-
- S:{' '}
-
- {trace.span_id}
-
-
-
-
- );
-}
diff --git a/packages/overlay/src/integrations/sentry/components/traces/traceInfo/TraceGeneralInfo.tsx b/packages/overlay/src/integrations/sentry/components/traces/traceInfo/TraceGeneralInfo.tsx
deleted file mode 100644
index 18cd2c73..00000000
--- a/packages/overlay/src/integrations/sentry/components/traces/traceInfo/TraceGeneralInfo.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import type { Trace } from '~/integrations/sentry/types';
-import { getDuration } from '~/integrations/sentry/utils/duration';
-import DateTime from '../../DateTime';
-
-type TraceGeneralInfoProps = {
- trace: Trace;
-};
-
-export default function TraceGeneralInfo({ trace }: TraceGeneralInfoProps) {
- const traceId = trace.trace_id;
- return (
-
-
General
-
-
- {[
- ['Trace Id', traceId || '-'],
- ['Spans', trace.spans.length || '-'],
- ['Transactions', trace.transactions.length || '-'],
- ['Errors', trace.errors || '-'],
- ['Start Timestamp', trace.start_timestamp ? : '-'],
- ['Total Duration', `${getDuration(trace.start_timestamp, trace.timestamp).toLocaleString()} ms`],
- ].map(([key, value]) => (
-
-
- {key}
-
-
- {value}
-
-
- ))}
-
-
-
- );
-}
diff --git a/packages/overlay/src/integrations/sentry/components/traces/traceInfo/TraceTags.tsx b/packages/overlay/src/integrations/sentry/components/traces/traceInfo/TraceTags.tsx
deleted file mode 100644
index d7571dfb..00000000
--- a/packages/overlay/src/integrations/sentry/components/traces/traceInfo/TraceTags.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import type { Trace } from '~/integrations/sentry/types';
-
-type TraceTagsProps = {
- trace: Trace;
-};
-
-export default function TraceTags({ trace }: TraceTagsProps) {
- const tags = trace.transactions
- .map(tsx => tsx.tags)
- .reduce((prev, current) => {
- return Object.assign(prev!, current);
- }, {});
-
- return (
-
-
Tags
- {tags && Object.keys(tags).length ? (
-
-
- {Object.entries(tags).map(([key, value]) => (
-
-
- {key}
-
-
- {JSON.stringify(value, undefined, 2)}
-
-
- ))}
-
-
- ) : (
-
No tags recorded for this Trace.
- )}
-
- );
-}
diff --git a/packages/overlay/src/integrations/sentry/components/traces/traceInfo/index.tsx b/packages/overlay/src/integrations/sentry/components/traces/traceInfo/index.tsx
deleted file mode 100644
index b85dd445..00000000
--- a/packages/overlay/src/integrations/sentry/components/traces/traceInfo/index.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import SidePanel, { SidePanelHeader } from '~/ui/SidePanel';
-import dataCache from '../../../data/sentryDataCache';
-import type { TraceContext } from '../../../types';
-import TraceGeneralInfo from './TraceGeneralInfo';
-import TraceTags from './TraceTags';
-
-type TraceInfoProps = {
- traceContext: TraceContext;
-};
-
-export default function TraceInfo({ traceContext }: TraceInfoProps) {
- const traceId = traceContext.trace_id;
- const trace = dataCache.getTraceById(traceId);
-
- return (
-
-
- Trace Id — {traceId}
- >
- }
- backto={`/traces/${traceId}`}
- />
-
-
-
-
-
-
-
- );
-}
diff --git a/packages/overlay/src/integrations/sentry/tabs/TracesTab.tsx b/packages/overlay/src/integrations/sentry/tabs/TracesTab.tsx
index 4047ec27..6d96f9da 100644
--- a/packages/overlay/src/integrations/sentry/tabs/TracesTab.tsx
+++ b/packages/overlay/src/integrations/sentry/tabs/TracesTab.tsx
@@ -1,15 +1,13 @@
import { Route, Routes } from 'react-router-dom';
+import TraceDetails from '../components/traces/TraceDetails';
import TraceList from '../components/traces/TraceList';
-import TraceDetails from '../components/traces/traceDetail';
import { SentryEventsContextProvider } from '../data/sentryEventsContext';
export default function TracesTab() {
return (
- } />
- } />
- } />
+ } />
} />
From 93f31c47a57478372e4558c7ab57ec31d663c672 Mon Sep 17 00:00:00 2001
From: Burak Yigit Kaya
Date: Fri, 8 Nov 2024 15:54:53 +0000
Subject: [PATCH 2/5] small refactor regarding traceId filtering
---
.../src/integrations/sentry/components/events/EventList.tsx | 6 +-----
.../src/integrations/sentry/data/useSentryEvents.tsx | 4 ++--
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/packages/overlay/src/integrations/sentry/components/events/EventList.tsx b/packages/overlay/src/integrations/sentry/components/events/EventList.tsx
index 2be49fb6..cd47ddfe 100644
--- a/packages/overlay/src/integrations/sentry/components/events/EventList.tsx
+++ b/packages/overlay/src/integrations/sentry/components/events/EventList.tsx
@@ -4,7 +4,6 @@ import { useSpotlightContext } from '~/lib/useSpotlightContext';
import Badge from '~/ui/Badge';
import CardList from '../../../../components/CardList';
import TimeSince from '../../../../components/TimeSince';
-import sentryDataCache from '../../data/sentryDataCache';
import { useSentryEvents } from '../../data/useSentryEvents';
import { useSentryHelpers } from '../../data/useSentryHelpers';
import type { SentryEvent } from '../../types';
@@ -17,13 +16,10 @@ function renderEvent(event: SentryEvent) {
}
export default function EventList({ traceId }: { traceId?: string }) {
- let events = useSentryEvents();
+ const events = useSentryEvents(traceId);
const helpers = useSentryHelpers();
const context = useSpotlightContext();
- if (traceId) {
- events = sentryDataCache.getEventsByTrace(traceId);
- }
const matchingEvents = events.filter(e => e.type !== 'transaction');
const [showAll, setShowAll] = useState(!context.experiments['sentry:focus-local-events']);
diff --git a/packages/overlay/src/integrations/sentry/data/useSentryEvents.tsx b/packages/overlay/src/integrations/sentry/data/useSentryEvents.tsx
index a5a890cd..871e1e91 100644
--- a/packages/overlay/src/integrations/sentry/data/useSentryEvents.tsx
+++ b/packages/overlay/src/integrations/sentry/data/useSentryEvents.tsx
@@ -2,7 +2,7 @@ import { useContext } from 'react';
import sentryDataCache from './sentryDataCache';
import { SentryEventsContext } from './sentryEventsContext';
-export const useSentryEvents = () => {
+export const useSentryEvents = (traceId?: string) => {
useContext(SentryEventsContext);
- return sentryDataCache.getEvents();
+ return traceId ? sentryDataCache.getEventsByTrace(traceId) : sentryDataCache.getEvents();
};
From 875f26c1a0b72bce457749a1412d3c2639c14e6b Mon Sep 17 00:00:00 2001
From: Burak Yigit Kaya
Date: Fri, 8 Nov 2024 16:02:33 +0000
Subject: [PATCH 3/5] tags refactor
---
.../TraceDetails/components/TraceContext.tsx | 23 ++++++++-----------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceContext.tsx b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceContext.tsx
index 493c8d20..621a0723 100644
--- a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceContext.tsx
+++ b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceContext.tsx
@@ -1,5 +1,5 @@
import sentryDataCache from '~/integrations/sentry/data/sentryDataCache';
-import { Tags as TagsType, Trace } from '~/integrations/sentry/types';
+import type { Tags as TagsType, Trace } from '~/integrations/sentry/types';
import { getDuration } from '~/integrations/sentry/utils/duration';
import DateTime from '../../../DateTime';
import Tags from '../../../Tags';
@@ -46,20 +46,17 @@ type TraceTagsProps = {
};
function TraceTags({ trace }: TraceTagsProps) {
- const tags: TagsType | undefined = trace.transactions
- .map(tsx => tsx.tags)
- .reduce((prev, current) => {
- return Object.assign(prev!, current);
- }, {});
+ const tags: TagsType = trace.transactions
+ .map(tsx => tsx.tags || {})
+ .reduce((prev, current) => Object.assign(prev, current), {} as TagsType);
- if (!tags) {
- return null;
- }
return (
-
-
Tags
-
-
+ Object.keys(tags).length > 0 && (
+
+
Tags
+
+
+ )
);
}
From 902128278cae64683f097244a96ea0b1de39ef2b Mon Sep 17 00:00:00 2001
From: Burak Yigit Kaya
Date: Fri, 8 Nov 2024 16:04:52 +0000
Subject: [PATCH 4/5] remove unnecessary abstraction
---
.../traces/TraceDetails/components/TraceDetailHeader.tsx | 2 +-
.../traces/TraceDetails/components/TraceErrors.tsx | 7 -------
.../sentry/components/traces/TraceDetails/index.tsx | 4 ++--
3 files changed, 3 insertions(+), 10 deletions(-)
delete mode 100644 packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceErrors.tsx
diff --git a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceDetailHeader.tsx b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceDetailHeader.tsx
index 7c314594..b1bc3de8 100644
--- a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceDetailHeader.tsx
+++ b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceDetailHeader.tsx
@@ -1,4 +1,4 @@
-import { Trace } from '~/integrations/sentry/types';
+import type { Trace } from '../../../../types';
import TraceIcon from '../../TraceIcon';
type TraceDetailHeaderProps = {
diff --git a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceErrors.tsx b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceErrors.tsx
deleted file mode 100644
index 7581d086..00000000
--- a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceErrors.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import EventList from '../../../events/EventList';
-
-type TraceErrorsProps = { traceId: string };
-
-export default function TraceErrors({ traceId }: TraceErrorsProps) {
- return ;
-}
diff --git a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx
index a68f347d..1a13db3a 100644
--- a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx
+++ b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx
@@ -1,9 +1,9 @@
import { Link, Navigate, Route, Routes, useParams } from 'react-router-dom';
import Tabs from '~/components/Tabs';
import { default as dataCache, default as sentryDataCache } from '../../../data/sentryDataCache';
+import EventList from '../../events/EventList';
import TraceContext from './components/TraceContext';
import TraceDetailHeader from './components/TraceDetailHeader';
-import TraceErrors from './components/TraceErrors';
import TraceTreeview from './components/TraceTreeview';
export default function TraceDetails() {
@@ -62,7 +62,7 @@ export default function TraceDetails() {
} />
} />
} />
- } />
+ } />
{/* Default tab */}
} />
From e8b0e8ac35e4b37d2fd5129c73fd662fa56daf6e Mon Sep 17 00:00:00 2001
From: Burak Yigit Kaya
Date: Fri, 8 Nov 2024 16:10:13 +0000
Subject: [PATCH 5/5] some more minor refactors
---
.../traces/TraceDetails/components/TraceTreeview.tsx | 8 +++++---
.../sentry/components/traces/TraceDetails/index.tsx | 4 ++--
.../sentry/components/traces/spans/SpanDetails.tsx | 4 ++--
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceTreeview.tsx b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceTreeview.tsx
index 7629007d..ed4864ec 100644
--- a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceTreeview.tsx
+++ b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/components/TraceTreeview.tsx
@@ -1,17 +1,19 @@
import { useState } from 'react';
import { useParams } from 'react-router-dom';
-import sentryDataCache from '~/integrations/sentry/data/sentryDataCache';
-import { getDuration } from '~/integrations/sentry/utils/duration';
+import sentryDataCache from '../../../../data/sentryDataCache';
+import { getDuration } from '../../../../utils/duration';
import DateTime from '../../../DateTime';
import SpanDetails from '../../spans/SpanDetails';
import SpanTree from '../../spans/SpanTree';
type TraceTreeViewProps = { traceId: string };
+export const DEFAULT_SPAN_NODE_WIDTH = 50;
+
export default function TraceTreeview({ traceId }: TraceTreeViewProps) {
const { spanId } = useParams();
- const [spanNodeWidth, setSpanNodeWidth] = useState(50);
+ const [spanNodeWidth, setSpanNodeWidth] = useState(DEFAULT_SPAN_NODE_WIDTH);
const trace = sentryDataCache.getTraceById(traceId);
const span = spanId ? sentryDataCache.getSpanById(traceId, spanId) : undefined;
diff --git a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx
index 1a13db3a..45ba0688 100644
--- a/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx
+++ b/packages/overlay/src/integrations/sentry/components/traces/TraceDetails/index.tsx
@@ -1,5 +1,5 @@
import { Link, Navigate, Route, Routes, useParams } from 'react-router-dom';
-import Tabs from '~/components/Tabs';
+import Tabs from '../../../../../components/Tabs';
import { default as dataCache, default as sentryDataCache } from '../../../data/sentryDataCache';
import EventList from '../../events/EventList';
import TraceContext from './components/TraceContext';
@@ -30,7 +30,7 @@ export default function TraceDetails() {
.getEventsByTrace(traceId)
.filter(
e =>
- e.type != 'transaction' &&
+ e.type !== 'transaction' &&
(e.contexts?.trace?.trace_id ? sentryDataCache.isTraceLocal(e.contexts?.trace?.trace_id) : null) !== false,
).length;
diff --git a/packages/overlay/src/integrations/sentry/components/traces/spans/SpanDetails.tsx b/packages/overlay/src/integrations/sentry/components/traces/spans/SpanDetails.tsx
index d03697fa..52394ced 100644
--- a/packages/overlay/src/integrations/sentry/components/traces/spans/SpanDetails.tsx
+++ b/packages/overlay/src/integrations/sentry/components/traces/spans/SpanDetails.tsx
@@ -1,9 +1,9 @@
import { useState, type ReactNode } from 'react';
import { Link } from 'react-router-dom';
import { format as formatSQL } from 'sql-formatter';
-import SidePanel, { SidePanelHeader } from '~/ui/SidePanel';
+import SidePanel, { SidePanelHeader } from '../../../../../ui/SidePanel';
import dataCache from '../../../data/sentryDataCache';
-import { SentryErrorEvent, Span, TraceContext } from '../../../types';
+import type { SentryErrorEvent, Span, TraceContext } from '../../../types';
import { formatBytes } from '../../../utils/bytes';
import { getDuration } from '../../../utils/duration';
import DateTime from '../../DateTime';