René's URL Explorer Experiment


Title: Expose API to generate active root spans in Browser SDKs · Issue #13495 · getsentry/sentry-javascript · GitHub

Open Graph Title: Expose API to generate active root spans in Browser SDKs · Issue #13495 · getsentry/sentry-javascript

X Title: Expose API to generate active root spans in Browser SDKs · Issue #13495 · getsentry/sentry-javascript

Description: Description Today, we have isomorphic APIs to start spans, which can be active or inactive. Active spans can only be made active in a callback. This makes sense and works well for Node, but in the browser it can be tricky and really does...

Open Graph Description: Description Today, we have isomorphic APIs to start spans, which can be active or inactive. Active spans can only be made active in a callback. This makes sense and works well for Node, but in the ...

X Description: Description Today, we have isomorphic APIs to start spans, which can be active or inactive. Active spans can only be made active in a callback. This makes sense and works well for Node, but in the ...

Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/13495

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Expose API to generate active root spans in Browser SDKs","articleBody":"### Description\n\nToday, we have isomorphic APIs to start spans, which can be active or inactive.\n\nActive spans can only be made active in a callback. This makes sense and works well for Node, but in the browser it can be tricky and really does not work well in many cases. For the most common use case, we automatically generate active root spans for pageloads and navigations, which are idle spans. However, outside of these, it is not really possible to start generically active root spans in the Browser, that encapsulate anything that happens while the root span is active. Think this:\n\n```js\n// navigation is over, I want to encompass a certain user flow with a transaction\nfunction startObserving() {\n  // start root span...\n}\n\nfunction endObserving() {\n  // end root span...\n}\n\nonUserClickedButtonA(startObserving);\nonUserClickedButtonB(endObserving);\n```\n\n(for example see https://github.com/getsentry/sentry-javascript/issues/13470)\n\nIn the browser, it is usually not possible to wrap such things in a callback - and, additionally, the isolation does not work anyhow at all in the browser, so it wouldn't _really_ help anyhow.\n\nWe should offer a way to do such things in the browser. There are a few options here:\n\n1. We could expose `startIdleSpan` from the SDKs. Today, this is only exported from `@sentry/core`, but not from e.g. `@sentry/browser`. This is a somewhat stable API that also makes the resulting span active. However, it has a bunch of baggage around it, and may or may not be what users actually want.\n2. We could expose the currently private/unexported `_setSpanOnScope(span, scope)` API, or something like it. However, this will only work in browser, not in Node. It may be confusing for users, or may not be.\n3. Add a new (?) API to browser only to start an active span outside of a callback. E.g. `startActiveDetachedSpan` (naming is hard...). This again could not work on Node, we'd need to think about if this should simply not exist in Node, or be a noop (or start an inactive span there...)\n4. Add an option (maybe just in browser?) to `startInactiveSpan` to make it active. This will obviously be a confusing naming 😅 `startInactiveSpan({ forceActive: true })` lol.\n5. Users _can_ somehow do this manually, kind of, by passing an async function that is ended on-demand. e.g.:\n\n```js\nlet resolve;\nSentry.startSpan({ name: 'my span' }, async () => {\n  await new Promise((_resolve) => {\n    resolve = _resolve;\n  });\n});\n\n// When done, call` resolve()` to end the span (and stop making it active).\n```\n\nHowever this is _very_ intimate in the sense of that this relies on the fact that we don't _actually_ keep the active scope isolated per callback, plus requires some mental gymnastics from users to understand why this is even working. But it _is_ possible.\n\nSo TLDR the options I see are:\n\n1. Export `startIdleSpan` - this is either not exported from node, or starts an inactive span there\n2. Export e.g. `setSpanForScope(span, getCurrentScope())` API - this either is not exported from node or noops there\n3. Export e.g. `const span = startActiveDetachedSpan()` API - this either is not exported from node or starts an inactive span there\n4. Add option like `forceActive: true` to existing `startInactiveSpan()` API - this could noop in Node (?)\n5. Do nothing, forcing users to somehow hack this behavior themselves","author":{"url":"https://github.com/mydea","@type":"Person","name":"mydea"},"datePublished":"2024-08-28T09:46:57Z","url":"https://github.com/getsentry/sentry-javascript/issues/13495"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:18ca1999-c847-e221-86b5-0c235be47530
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD6C2:1A88D4:9A671C:C70E5F:6B051196
html-safe-nonce094a1c2daa62f3ad6859cf2601e5434a861a9df3bdd67cda19994cf95a32ea5b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkMyOjFBODhENDo5QTY3MUM6QzcwRTVGOjZCMDUxMTk2IiwidmlzaXRvcl9pZCI6IjQ5NTY5NDA3NDE1ODgwOTUzODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacef9e6e7b063ef33f03a7293651f1afc46a11c44a951279c91e40f205514a4dd2
hovercard-subject-tagissue:2491600375
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/13495/issue_layout
twitter:imagehttps://opengraph.githubassets.com/fc305b2a3d88349cbd46fc0f3cb4fb12483fad87ab42a6d914d6b6051f407840/getsentry/sentry-javascript/issues/13495
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/fc305b2a3d88349cbd46fc0f3cb4fb12483fad87ab42a6d914d6b6051f407840/getsentry/sentry-javascript/issues/13495
og:image:altDescription Today, we have isomorphic APIs to start spans, which can be active or inactive. Active spans can only be made active in a callback. This makes sense and works well for Node, but in the ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemydea
hostnamegithub.com
expected-hostnamegithub.com
None854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id3328572
octolytics-dimension-repository_nwogetsentry/sentry-javascript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3328572
octolytics-dimension-repository_network_root_nwogetsentry/sentry-javascript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release220e980097d94ce616d5d11fbd5316d208e3fc93
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-javascript/issues/13495#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F13495
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F13495
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-javascript
Reloadhttps://github.com/getsentry/sentry-javascript/issues/13495
Reloadhttps://github.com/getsentry/sentry-javascript/issues/13495
Reloadhttps://github.com/getsentry/sentry-javascript/issues/13495
getsentryhttps://github.com/getsentry
sentry-javascripthttps://github.com/getsentry/sentry-javascript
Codehttps://github.com/getsentry/sentry-javascript
Issues334 (334)https://github.com/getsentry/sentry-javascript/issues
Pull requests51 (51)https://github.com/getsentry/sentry-javascript/pulls
Discussionshttps://github.com/getsentry/sentry-javascript/discussions
Actionshttps://github.com/getsentry/sentry-javascript/actions
Security and quality7 (7)https://github.com/getsentry/sentry-javascript/security
Insightshttps://github.com/getsentry/sentry-javascript/insights
https://github.com/getsentry/sentry-javascript
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/13495
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/13495
#17714https://github.com/getsentry/sentry-javascript/pull/17714
Expose API to generate active root spans in Browser SDKshttps://github.com/getsentry/sentry-javascript/issues/13495#top
#17714https://github.com/getsentry/sentry-javascript/pull/17714
https://github.com/Lms24
Browserhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Browser%22
Featurehttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Feature%22
Spanshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Spans%22
https://github.com/mydea
mydeahttps://github.com/mydea
on Aug 28, 2024https://github.com/getsentry/sentry-javascript/issues/13495#issue-2491600375
#13470https://github.com/getsentry/sentry-javascript/issues/13470
AbhiPrasadhttps://github.com/AbhiPrasad
Feature: Spanshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Feature%3A%20Spans%22
Package: browserhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Package%3A%20browser%22
on Nov 1, 2024https://github.com/getsentry/sentry-javascript/issues/13495#event-15072420488
linearhttps://github.com/apps/linear
Migratedhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Migrated%22
on Jan 9, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-15872435039
stephanie-andersonhttps://github.com/stephanie-anderson
Migratedhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Migrated%22
on Mar 13, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-16743587548
getsentry/sentry-javascripthttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22getsentry%2Fsentry-javascript%22
on Apr 7, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-17159553547
linearhttps://github.com/apps/linear
SDKs (New)https://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22SDKs%20(New)%22
Taskhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Task%22
on Apr 7, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-17159840626
stephanie-andersonhttps://github.com/stephanie-anderson
SDKs (New)https://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22SDKs%20(New)%22
getsentry/sentry-javascripthttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22getsentry%2Fsentry-javascript%22
on Apr 8, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-17167316963
mydeahttps://github.com/mydea
Taskhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Task%22
on Apr 14, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-17250190907
stephanie-andersonhttps://github.com/stephanie-anderson
Spanshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Spans%22
Feature: Spanshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Feature%3A%20Spans%22
on Apr 30, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-17471443477
AbhiPrasadhttps://github.com/AbhiPrasad
Add API to browser SDKs to set span active on scope #13807https://github.com/getsentry/sentry-javascript/issues/13807
on Jun 17, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-18193714648
stephanie-andersonhttps://github.com/stephanie-anderson
Taskhttps://github.com/getsentry/sentry-javascript/issues?q=type:"Task"
on Aug 12, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-19106371393
Lms24https://github.com/Lms24
on Sep 19, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-19800345161
Lms24https://github.com/Lms24
completedhttps://github.com/getsentry/sentry-javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#17714https://github.com/getsentry/sentry-javascript/pull/17714
on Sep 23, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-19864754172
s1gr1dhttps://github.com/s1gr1d
on Sep 23, 2025https://github.com/getsentry/sentry-javascript/issues/13495#event-19866931067
feat(browser): Add `setActiveSpanInBrowser` to set an active span in …https://github.com/getsentry/sentry-javascript/commit/73f356d87db02a1cad0c7ab25702146f64128380
73f356dhttps://github.com/getsentry/sentry-javascript/commit/73f356d87db02a1cad0c7ab25702146f64128380
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Sep 24, 2025https://github.com/getsentry/sentry-javascript/issues/13495#issuecomment-3329638515
GitHub Actionshttps://help.github.com/en/actions
#17714https://github.com/getsentry/sentry-javascript/pull/17714
10.15.0 releasehttps://github.com/getsentry/sentry-javascript/releases/tag/10.15.0
chargomehttps://github.com/chargome
Browserhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Browser%22
Package: browserhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Package%3A%20browser%22
on Mar 20, 2026https://github.com/getsentry/sentry-javascript/issues/13495#event-23747856427
stephanie-andersonhttps://github.com/stephanie-anderson
Featurehttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Feature%22
on Mar 24, 2026https://github.com/getsentry/sentry-javascript/issues/13495#event-23840817764
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-javascript/issues/13495
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/13495
Lms24https://github.com/Lms24
Browserhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Browser%22
Featurehttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Feature%22
Spanshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Spans%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.