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

Update to Sentry v8 SDKs #234

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

timfish
Copy link
Contributor

@timfish timfish commented May 10, 2024

Closes #232 and closes #221

This PR updates the Sentry SDKs to v8.0.0-rc.2 which involves some breaking changes:

  • Converts integrations to the newer functional API and naming convention
    • Removes the Transaction integration since it's no longer required
  • Sentry have removed the hub concept entirely so Toucan now extends Scope
  • To isolate scope changes, withScope now clones the Toucan class which is passed as the callback parameter
    • Sentry's withScope handling is a lot more complex because it has to consider isolation
    • I changed the withScope tests to use toStrictEqual on extra because they were passing when they should have been failing

The main thing I'm not that happy with is that Toucan holds a reference to ToucanClient (due to Sentry's own client ref in Scope) and ToucanClient holds a reference to Toucan (#sdk) . This circular reference is unfortunate and there may be a way to improve this but I haven't put much thought into it yet and it might not be a massive issue 🙂

It should be relatively easy to get Sentry Metrics working too but they do use a global to store a metrics aggregator per client (WeakMap<Client, MetricsAggregatorInterface>). I can't imagine this would be too much of an issue since it stores a unique metrics aggregator per client and toucan-js has a unique client per request.

Copy link

changeset-bot bot commented May 10, 2024

⚠️ No Changeset found

Latest commit: 800b56e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@timfish
Copy link
Contributor Author

timfish commented May 13, 2024

Just updated this to v8.0.0 stable!

@cjlawson02
Copy link

Hi @robertcepa, I would love to get this reviewed to update my project. Thanks!

@robertcepa
Copy link
Owner

Thank you @timfish for contributing! I took the first pass and left some comments for you.

The main thing I'm not that happy with is that Toucan holds a reference to ToucanClient (due to Sentry's own client ref in Scope) and ToucanClient holds a reference to Toucan (#sdk) . This circular reference is unfortunate and there may be a way to improve this but I haven't put much thought into it yet and it might not be a massive issue 🙂

Not a new issue. I think it's fine to roll with this for now.

It should be relatively easy to get Sentry Metrics working too but they do use a global to store a metrics aggregator per client (WeakMap<Client, MetricsAggregatorInterface>). I can't imagine this would be too much of an issue since it stores a unique metrics aggregator per client and toucan-js has a unique client per request.

Seems WeakMap has built-in garbage collection for expired keys so no concerns in terms of ever-growing memory as well, but would be cool to test how it does at scale. For now we don't officially support

@timfish
Copy link
Contributor Author

timfish commented May 26, 2024

Seems WeakMap has built-in garbage collection for expired keys so no concerns in terms of ever-growing memory as well, but would be cool to test how it does at scale

Sentry ideally want to keep the metrics aggregator instance count to a minimum so metrics are actually aggregated between requests. I think to make it scale you'd want a single aggregator per "worker instance" but you'd need a way to flush/send metrics before the worker instance exits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants