Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to use startSpan with generator functions #16503

Unanswered
PRESIDENT810 asked this question in Q&A
Discussion options

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

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /