-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
How to use startSpan with generator functions #16503
-
Our project uses redux-saga and we use generator functions very heavily. We are using @sentry/react v7 which works fine because startTransaction API because it returns a transaction object and doesn't use callback. However, after we upgrade it to v8, startTransaction is gone and there's only startSpan where it takes a callback in which you make changes to the span object.
I find our code is is not compatible with this API at all. For example, we use Sentry to trace a network request in a generator function which looks like this:
function* sendRequestEffect() {
const transaction = Sentry.startTransaction({/*...*/});
const span = transaction.startChild({/*...*/});
// Network stuff...
const response = yield call(sendRequest);
if (response.status == 400) {
span.setStatus(SpanStatus.Ok);
}
}
With v8, it has to be
function* sendRequestEffect() {
yield Sentry.startSpan({/*...*/}, function* (span) {
// Network stuff...
const response = yield call(sendRequest);
if (response.status == 400) {
span.setStatus(SpanStatus.Ok);
}
});
}
I assume it wouldn't work?
Is there any way to make use of the new tracing API with generator functions? If not, can we have a tracing API that doesn't require a callback function? Otherwise we can never upgrade Sentry beyond v8
Thanks
Beta Was this translation helpful? Give feedback.