-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref: Add hub.startTransaction extension #2626
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
Conversation
Moving the check to the func where it matters eliminates the need for the internal field _isTransaction and the downstream logic in startSpan.
Shorter message equals smaller bundle size. Limit ourselves to a single warning line. The fix to eliminate the warning is to call startTransaction({name: "some name"}) so the setName advice is misplaced.
Extract code that starts transactions from startSpan and deprecate startSpan. Move check of empty transaction name to right before sending the transaction, because it is valid to start the transaction without a name and set the name later with Transaction.setName().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing the point of the previous PR https://github.com/getsentry/sentry-javascript/pull/2625/files#diff-8ae4c12e7fb40f73c4ff34d16c2d0ed3R34-R39
packages/apm/src/hubextensions.ts
Outdated
logger.warn('Will fall back to <unlabeled transaction>, use `transaction.setName()` to change it.'); | ||
(context as TransactionContext).name = '<unlabeled transaction>'; | ||
} | ||
logger.warn('Deprecated: Use startTransaction to start transactions and Transaction.startChild to start spans.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only log this in case of an transaction
* with the transaction poperty set. | ||
*/ | ||
if ((context as any).transaction !== undefined) { | ||
logger.warn(`Use \`Sentry.startTransaction({name: ${(context as any).transaction}})\` to start a Transaction.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a confusing syntax :3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y? ^^
Follow up on #2626. Now that startTransaction exists, replace usages of startSpan where the intention is to create a transaction. Additionally, documentation updates and some refactoring to minimize type castings and linter flag usage.
This probably replaces #2625.
Transaction._isTransaction
because the only way this was used is equivalent to callingHub.startTransaction
.Sentry.startTransaction
orHub.startTransaction
, and to start spans callTransaction.startChild
.