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): Emit hooks for transaction start/finish #7387

Merged
merged 2 commits into from Mar 9, 2023

Conversation

AbhiPrasad
Copy link
Member

Builds on top of #7370

For now closes #7262 (but we still need to add replay hooks).

@AbhiPrasad AbhiPrasad requested review from JonasBa, a team, mydea and Lms24 and removed request for a team March 8, 2023 17:38
Base automatically changed from abhi-hooks to develop March 8, 2023 19:16
@AbhiPrasad AbhiPrasad mentioned this pull request Mar 8, 2023
2 tasks
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.21 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 62.89 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.85 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 55.8 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.6 KB (0%)
@sentry/browser - Webpack (minified) 67.32 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.62 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 48.39 KB (+0.08% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 27.39 KB (+0.16% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.65 KB (+0.13% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.15 KB (0%)
@sentry/replay - Webpack (gzipped + minified) 37.16 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.05 KB (+0.07% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 54.31 KB (+0.01% 🔺)

Copy link
Member

@JonasBa JonasBa left a comment

Choose a reason for hiding this comment

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

Thank you @AbhiPrasad!

@AbhiPrasad AbhiPrasad enabled auto-merge (squash) March 9, 2023 08:37
@AbhiPrasad AbhiPrasad self-assigned this Mar 9, 2023
@AbhiPrasad AbhiPrasad merged commit 295ea3d into develop Mar 9, 2023
@AbhiPrasad AbhiPrasad deleted the abhi-transaction-hooks branch March 9, 2023 08:44
@Mr0grog
Copy link

Mr0grog commented Mar 13, 2023

Apologies if this is the wrong place to ask (LMK where is better!), but I saw this in the release notes and started to use it to clean up some messy code I have around spans. However, the issue this is based on says:

This is special case - but we need this to unblock profiling so let's :shipit:. We keep these APIs completely internal, we can change it later on.

…so I’m wondering if I should actually avoid using these events. (Side note: it would be really helpful to not include private APIs in release notes, or at least call out what things are not for public use. 🙏 )

@AbhiPrasad
Copy link
Member Author

@Mr0grog we need to include some stuff about internals because we have downstream SDK consumers (https://github.com/getsentry/sentry-electron and https://github.com/getsentry/sentry-react-native for example).

Curious about your use case - maybe we do end up documenting this properly. What are you doing exactly with hooks?

We only recommend only using the API that is directly referenced via our documentation, but anything exposed as public API (class methods, exports) will not break until the next major version.

@Mr0grog
Copy link

Mr0grog commented Mar 14, 2023

Oh, we have some terrifyingly horrible hacks to try and make adding spans work well: https://gist.github.com/Mr0grog/bf88c0e003fc07cb2ca6271f426ba65e

The transaction finishing event is useful because we want most spans that never finished to get included in the transaction (probably an exception occurred that prevented us from getting to the span.finish() call), so the helpers patch Transaction to get notified and close the span unless you specifically opt out. BUT while I poking at the events added here I realized they probably aren’t a good solution anyway (it seems like both the hub is not guaranteed to be present on the transaction and a client is not guaranteed to be on the hub, so for something totally focused on the transaction/span world, a hook on the client is probably the wrong place). 🤷

@AbhiPrasad
Copy link
Member Author

it seems like both the hub is not guaranteed to be present on the transaction and a client is not guaranteed to be on the hub

This is typed this way because JavaScript lol, but for for standard use you can pretty much always consider a hub/client to exist on a transaction that has been sampled.

@AbhiPrasad
Copy link
Member Author

Oh, we have some terrifyingly horrible hacks to try and make adding spans work well

We need to make this better, let me take this back to the team.

@Mr0grog
Copy link

Mr0grog commented Mar 14, 2023

This is typed this way because JavaScript lol, but for for standard use you can pretty much always consider a hub/client to exist on a transaction that has been sampled.

Ah, good to know! So we could check transaction.sampled, and generally assume those should be present. 👍

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 lifecycle hooks
3 participants