Retrieve an Active Transaction
In cases where you want to attach Spans to an already ongoing transaction, such as when grouping transactions, you can use Sentry.getCurrentHub().getScope().getTransaction()
. This function will return a Transaction
object when there is a running transaction on the scope, otherwise it returns undefined
. If you are using our BrowserTracing integration, by default we attach the transaction to the Scope, so you could do something like this:
Copied
function myJsFunction() {
const transaction = Sentry.getCurrentHub()
.getScope()
.getTransaction();
if (transaction) {
let span = transaction.startChild({
op: "encode",
description: "parseAvatarImages",
});
// Do something
span.finish();
}
}
You can edit this page on GitHub.
- Package:
- npm:@sentry/electron
- Version:
- 2.0.4
- Repository:
- https://github.com/getsentry/sentry-electron