Skip to content

Commit dab431e

Browse files
authored
feat: Start using profile information in span tree (#692)
First phase of #565.
1 parent 1ffe90f commit dab431e

File tree

22 files changed

+508
-62
lines changed

22 files changed

+508
-62
lines changed

.changeset/few-points-rush.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@spotlightjs/tsconfig': major
3+
'@spotlightjs/spotlight': minor
4+
'@spotlightjs/electron': minor
5+
'@spotlightjs/overlay': minor
6+
'@spotlightjs/astro': minor
7+
---
8+
9+
# Add profile grafting into traces
10+
11+
With this change, Spotlight can now ingest v1 profiles and graft profiling
12+
data into the trace view to fill in the gaps where span/trace instrumentation
13+
falls short.
14+
15+
This feature is experimental.
16+
17+
Breaking change for `tsconfig`: It now targets ES2023 as we needed `Array.findLastIndex()`

.github/workflows/build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ jobs:
169169

170170
- name: Run tests
171171
run: pnpm test:e2e
172+
173+
- name: Test results
174+
if: always()
175+
uses: actions/upload-artifact@v4
176+
with:
177+
name: test-results
178+
path: e2e-tests/**/test-results/**
172179
docker:
173180
name: Docker Image
174181
needs: build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dist-bin
1414
node
1515
dist-ssr
1616
*.local
17+
test-results
1718

1819
.eslintcache
1920

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"Astro",
77
"Astro's",
88
"astrojs",
9+
"backto",
910
"buildx",
1011
"codesign",
1112
"contextlines",

demos/astro-playground/astro.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export default defineConfig({
1919
adapter: node({
2020
mode: 'standalone',
2121
}),
22+
server: {
23+
headers: {
24+
'Document-Policy': 'js-profiling',
25+
},
26+
},
2227
integrations: [
2328
svelte({ include: ['**/svelte/*'] }),
2429
react({ include: ['**/react/*'] }),

demos/astro-playground/sentry.client.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ import * as Sentry from '@sentry/astro';
22

33
Sentry.init({
44
debug: true,
5+
integrations: [Sentry.browserProfilingIntegration()],
6+
profilesSampleRate: 1.0,
57
});

packages/overlay/src/integrations/sentry/components/events/EventList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function EventList({ traceId }: { traceId?: string }) {
1616
const helpers = useSentryHelpers();
1717
const context = useSpotlightContext();
1818

19-
const matchingEvents = events.filter(e => e.type !== 'transaction');
19+
const matchingEvents = events.filter(e => e.type !== 'transaction' && e.type !== 'profile');
2020

2121
const [showAll, setShowAll] = useState(!context.experiments['sentry:focus-local-events']);
2222
const filteredEvents = showAll

packages/overlay/src/integrations/sentry/components/explore/traces/TraceDetails/components/TraceTreeview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function TraceTreeview({ traceId }: TraceTreeViewProps) {
1515

1616
const [spanNodeWidth, setSpanNodeWidth] = useState<number>(DEFAULT_SPAN_NODE_WIDTH);
1717

18-
const trace = sentryDataCache.getTraceById(traceId);
18+
const trace = sentryDataCache.getTraceById(traceId)!;
1919
const span = spanId ? sentryDataCache.getSpanById(traceId, spanId) : undefined;
2020
const startTimestamp = trace.start_timestamp;
2121
const totalDuration = trace.timestamp - startTimestamp;

packages/overlay/src/integrations/sentry/components/explore/traces/TraceDetails/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default function TraceDetails() {
3535
const errorCount = events.filter(
3636
e =>
3737
e.type !== 'transaction' &&
38+
e.type !== 'profile' &&
3839
(e.contexts?.trace?.trace_id ? helpers.isLocalToSession(e.contexts?.trace?.trace_id) : null) !== false,
3940
).length;
4041

packages/overlay/src/integrations/sentry/components/explore/traces/TraceList.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ import TimeSince from '../../../../../components/TimeSince';
66
import classNames from '../../../../../lib/classNames';
77
import { useSpotlightContext } from '../../../../../lib/useSpotlightContext';
88
import { useSentryHelpers } from '../../../data/useSentryHelpers';
9-
import { useSentryTraces } from '../../../data/useSentryTraces';
9+
import { useSentryTraces } from '../../../data/useSentrySpans';
1010
import { getFormattedSpanDuration } from '../../../utils/duration';
1111
import { truncateId } from '../../../utils/text';
1212
import HiddenItemsButton from '../../HiddenItemsButton';
1313
import { TraceRootTxnName } from './TraceDetails/components/TraceRootTxnName';
1414
import TraceIcon from './TraceIcon';
1515

1616
export default function TraceList() {
17-
const traceList = useSentryTraces();
17+
const { allTraces, localTraces } = useSentryTraces();
1818
const helpers = useSentryHelpers();
1919
const context = useSpotlightContext();
2020

2121
const [showAll, setShowAll] = useState(!context.experiments['sentry:focus-local-events']);
22-
const filteredTraces = showAll ? traceList : traceList.filter(t => helpers.isLocalToSession(t.trace_id) !== false);
23-
const hiddenItemCount = traceList.length - filteredTraces.length;
22+
const filteredTraces = showAll ? allTraces : localTraces;
23+
const hiddenItemCount = allTraces.length - filteredTraces.length;
2424

2525
return (
2626
<>
27-
{traceList.length !== 0 ? (
27+
{allTraces.length !== 0 ? (
2828
<CardList>
2929
{hiddenItemCount > 0 && (
3030
<HiddenItemsButton

0 commit comments

Comments
 (0)