Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core)!: Pass root spans to beforeSendSpan and disallow returning null #14831

Merged
merged 13 commits into from
Jan 8, 2025

Conversation

chargome
Copy link
Member

@chargome chargome commented Dec 23, 2024

  • Disallows returning null from beforeSendSpan
  • Passes root spans to beforeSendSpan
  • Adds entry to migration guide and changelog

Looked at two options for passing the root span:

  1. Within the SentrySpan class, before converting the root span into a transaction.
  2. Parsing a SpanJSON out of an event and then writing back the updated values into the event.

Went with (2), passing the root span within processBeforeSend to have all processing hooks centrally in one place and because the other approach would have been too messy.

closes #14336

Sorry, something went wrong.

@chargome chargome self-assigned this Dec 23, 2024
Copy link
Contributor

github-actions bot commented Dec 23, 2024

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 23.01 KB +1.22% +282 B 🔺
@sentry/browser - with treeshaking flags 21.72 KB +1% +219 B 🔺
@sentry/browser (incl. Tracing) 35.58 KB +0.55% +197 B 🔺
@sentry/browser (incl. Tracing, Replay) 72.3 KB +0.3% +217 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.82 KB +0.32% +203 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 76.56 KB +0.27% +211 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 88.58 KB +0.24% +209 B 🔺
@sentry/browser (incl. Feedback) 39.32 KB +0.63% +251 B 🔺
@sentry/browser (incl. sendFeedback) 27.67 KB +0.92% +256 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.5 KB +0.79% +260 B 🔺
@sentry/react 25.72 KB +0.91% +237 B 🔺
@sentry/react (incl. Tracing) 38.35 KB +0.53% +206 B 🔺
@sentry/vue 27.25 KB +0.64% +176 B 🔺
@sentry/vue (incl. Tracing) 37.4 KB +0.45% +169 B 🔺
@sentry/svelte 23.14 KB +1.23% +287 B 🔺
CDN Bundle 24.32 KB +0.86% +210 B 🔺
CDN Bundle (incl. Tracing) 35.87 KB +0.49% +178 B 🔺
CDN Bundle (incl. Tracing, Replay) 70.44 KB +0.28% +198 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 75.64 KB +0.25% +187 B 🔺
CDN Bundle - uncompressed 71.15 KB +0.97% +696 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 106.67 KB +0.6% +648 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 217.55 KB +0.3% +648 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 230.3 KB +0.28% +648 B 🔺
@sentry/nextjs (client) 38.49 KB +0.56% +219 B 🔺
@sentry/sveltekit (client) 36.11 KB +0.58% +211 B 🔺
@sentry/node 161.75 KB +0.18% +295 B 🔺
@sentry/node - without tracing 97.54 KB +0.27% +266 B 🔺
@sentry/aws-serverless 127.39 KB +0.22% +281 B 🔺

View base workflow run

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@chargome chargome marked this pull request as ready for review December 31, 2024 11:55
@chargome chargome requested review from mydea and Lms24 January 2, 2025 12:14
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally looks good to me and I think the conversion is correct. Before we merge this, let's please add a sentence to the PR description why we went with this approach instead of calling beforeSendSpan earlier for posterity.

...event.sdkProcessingMetadata,
spanCountBeforeProcessing: spanCountBefore,
};
}
return beforeSendTransaction(event, hint);
return beforeSendTransaction(processedEvent as TransactionEvent, hint);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l (not blocking): Is there a way we can get rid of this type cast? No worries if not, just curious since there's the isTransactionEvent check above 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah somehow no matter what I do, after the merge call ts thinks it's an event again, even if I do

processedEvent = merge<TransactionEvent>(
  processedEvent,
  convertSpanJsonToTransactionEvent(processedRootSpanJson),
);

@chargome chargome merged commit d4e94fe into develop Jan 8, 2025
153 checks passed
@chargome chargome deleted the cg/disallow-dropping-in-beforesendspan branch January 8, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v9] Disallow returning null from beforeSendSpan and also pass root spans
2 participants