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

fix(core): Ensure standalone spans are not sent if SDK is disabled #14088

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Oct 28, 2024

Previously, when standalone (most prominently INP) spans would .end(), they'd always be sent to Sentry, even if the SDK was disabled (via Sentry.init({enabled: false}) for example). This was caused by us directly calling transport.send and not checking for the enabled option, instead of using the client to send the span envelope.

This PR now changes the sending logic to use the client's sendEnvelope method which we generally use to send envelopes (sessions, client reports, checkins, metrics (RIP), and also events). This has a minor implication: We will now also emit a beforeEnvelope client hook event for sending standalone spans. I think this is actually more correct than before but could potentially break someone. IMO this is worth the "risk" as it's easily revertible and client hooks are primarily meant for internal use. Happy to adjust the PR though if reviewers have different opinions.

fixes #14082

@Lms24 Lms24 self-assigned this Oct 28, 2024
@Lms24 Lms24 requested review from mydea and chargome October 28, 2024 12:25
@@ -565,7 +565,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {

if (this._isEnabled() && this._transport) {
return this._transport.send(envelope).then(null, reason => {
DEBUG_BUILD && logger.error('Error while sending event:', reason);
DEBUG_BUILD && logger.error('Error while sending envelope:', reason);
Copy link
Member Author

Choose a reason for hiding this comment

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

Given that sendEnvelope is called for multiple envelope item types (not just events), I opted to slightly change the message here to reflect this

Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

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

makes sense to me! 👍

Copy link
Contributor

github-actions bot commented Oct 28, 2024

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.74 KB +0.03% +5 B 🔺
@sentry/browser - with treeshaking flags 21.53 KB - -
@sentry/browser (incl. Tracing) 35.12 KB -0.02% -5 B 🔽
@sentry/browser (incl. Tracing, Replay) 71.85 KB -0.02% -9 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.25 KB -0.02% -8 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 76.21 KB -0.02% -12 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 88.99 KB -0.02% -10 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 90.81 KB -0.02% -12 B 🔽
@sentry/browser (incl. metrics) 26.98 KB -0.06% -14 B 🔽
@sentry/browser (incl. Feedback) 39.88 KB +0.03% +9 B 🔺
@sentry/browser (incl. sendFeedback) 27.38 KB +0.02% +5 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.17 KB +0.02% +5 B 🔺
@sentry/react 25.49 KB +0.02% +5 B 🔺
@sentry/react (incl. Tracing) 38.07 KB -0.05% -16 B 🔽
@sentry/vue 26.88 KB -0.1% -27 B 🔽
@sentry/vue (incl. Tracing) 37 KB -0.05% -17 B 🔽
@sentry/svelte 22.87 KB +0.03% +5 B 🔺
CDN Bundle 24.11 KB - -
CDN Bundle (incl. Tracing) 36.95 KB -0.04% -12 B 🔽
CDN Bundle (incl. Tracing, Replay) 71.64 KB -0.02% -14 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 76.98 KB -0.02% -14 B 🔽
CDN Bundle - uncompressed 70.7 KB - -
CDN Bundle (incl. Tracing) - uncompressed 109.68 KB -0.05% -55 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 222.21 KB -0.03% -55 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 235.42 KB -0.03% -55 B 🔽
@sentry/nextjs (client) 38.16 KB -0.03% -11 B 🔽
@sentry/sveltekit (client) 35.72 KB -0.06% -19 B 🔽
@sentry/node 124.95 KB -0.02% -16 B 🔽
@sentry/node - without tracing 94.02 KB +0.01% +2 B 🔺
@sentry/aws-serverless 103.62 KB +0.01% +2 B 🔺

View base workflow run

@Lms24 Lms24 enabled auto-merge (squash) October 28, 2024 12:48
@Lms24 Lms24 merged commit cc30c14 into develop Oct 28, 2024
148 checks passed
@Lms24 Lms24 deleted the lms/fix-core-standalone-spans-sent-if-sdk-disabled branch October 28, 2024 13:08
alexandresoro pushed a commit to alexandresoro/ouca-backend that referenced this pull request Nov 3, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@sentry/node](https://github.com/getsentry/sentry-javascript/tree/master/packages/node) ([source](https://github.com/getsentry/sentry-javascript)) | dependencies | minor | [`8.35.0` -> `8.36.0`](https://renovatebot.com/diffs/npm/@sentry%2fnode/8.35.0/8.36.0) |
| [@sentry/react](https://github.com/getsentry/sentry-javascript/tree/master/packages/react) ([source](https://github.com/getsentry/sentry-javascript)) | dependencies | minor | [`8.35.0` -> `8.36.0`](https://renovatebot.com/diffs/npm/@sentry%2freact/8.35.0/8.36.0) |

---

### Release Notes

<details>
<summary>getsentry/sentry-javascript (@&#8203;sentry/node)</summary>

### [`v8.36.0`](https://github.com/getsentry/sentry-javascript/blob/HEAD/CHANGELOG.md#8360)

[Compare Source](getsentry/sentry-javascript@8.35.0...8.36.0)

##### Important Changes

-   **feat(nextjs/vercel-edge/cloudflare): Switch to OTEL for performance monitoring ([#&#8203;13889](getsentry/sentry-javascript#13889

With this release, the Sentry Next.js, and Cloudflare SDKs will now capture performance data based on OpenTelemetry.
Some exceptions apply in cases where Next.js captures inaccurate data itself.

NOTE: You may experience minor differences in transaction names in Sentry.
Most importantly transactions for serverside pages router invocations will now be named `GET /[param]/my/route` instead of `/[param]/my/route`.
This means that those transactions are now better aligned with the OpenTelemetry semantic conventions.

##### Other Changes

-   deps: Bump bundler plugins and CLI to 2.22.6 and 2.37.0 respectively ([#&#8203;14050](getsentry/sentry-javascript#14050))
-   feat(deps): bump [@&#8203;opentelemetry/instrumentation-aws-sdk](https://github.com/opentelemetry/instrumentation-aws-sdk) from 0.44.0 to 0.45.0 ([#&#8203;14099](getsentry/sentry-javascript#14099))
-   feat(deps): bump [@&#8203;opentelemetry/instrumentation-connect](https://github.com/opentelemetry/instrumentation-connect) from 0.39.0 to 0.40.0 ([#&#8203;14101](getsentry/sentry-javascript#14101))
-   feat(deps): bump [@&#8203;opentelemetry/instrumentation-express](https://github.com/opentelemetry/instrumentation-express) from 0.43.0 to 0.44.0 ([#&#8203;14102](getsentry/sentry-javascript#14102))
-   feat(deps): bump [@&#8203;opentelemetry/instrumentation-fs](https://github.com/opentelemetry/instrumentation-fs) from 0.15.0 to 0.16.0 ([#&#8203;14098](getsentry/sentry-javascript#14098))
-   feat(deps): bump [@&#8203;opentelemetry/instrumentation-kafkajs](https://github.com/opentelemetry/instrumentation-kafkajs) from 0.3.0 to 0.4.0 ([#&#8203;14100](getsentry/sentry-javascript#14100))
-   feat(nextjs): Add method and url to route handler request data ([#&#8203;14084](getsentry/sentry-javascript#14084))
-   feat(node): Add breadcrumbs for `child_process` and `worker_thread` ([#&#8203;13896](getsentry/sentry-javascript#13896))
-   fix(core): Ensure standalone spans are not sent if SDK is disabled ([#&#8203;14088](getsentry/sentry-javascript#14088))
-   fix(nextjs): Await flush in api handlers ([#&#8203;14023](getsentry/sentry-javascript#14023))
-   fix(nextjs): Don't leak webpack types into exports ([#&#8203;14116](getsentry/sentry-javascript#14116))
-   fix(nextjs): Fix matching logic for file convention type for root level components ([#&#8203;14038](getsentry/sentry-javascript#14038))
-   fix(nextjs): Respect directives in value injection loader ([#&#8203;14083](getsentry/sentry-javascript#14083))
-   fix(nuxt): Only wrap `.mjs` entry files in rollup ([#&#8203;14060](getsentry/sentry-javascript#14060))
-   fix(nuxt): Re-export all exported bindings ([#&#8203;14086](getsentry/sentry-javascript#14086))
-   fix(nuxt): Server-side setup in readme ([#&#8203;14049](getsentry/sentry-javascript#14049))
-   fix(profiling-node): Always warn when running on incompatible major version of Node.js ([#&#8203;14043](getsentry/sentry-javascript#14043))
-   fix(replay): Fix `onError` callback ([#&#8203;14002](getsentry/sentry-javascript#14002))
-   perf(otel): Only calculate current timestamp once ([#&#8203;14094](getsentry/sentry-javascript#14094))
-   test(browser-integration): Add sentry DSN route handler by default ([#&#8203;14095](getsentry/sentry-javascript#14095))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xMzguNiIsInVwZGF0ZWRJblZlciI6IjM4LjEzOC42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->

Reviewed-on: https://git.tristess.app/alexandresoro/ouca/pulls/289
Reviewed-by: Alexandre Soro <code@soro.dev>
Co-authored-by: renovate <renovate@git.tristess.app>
Co-committed-by: renovate <renovate@git.tristess.app>
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.

SDK sends INP spans if enabled: false
3 participants