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

Exposed http client span as transaction #4162

Closed
Lucienzera opened this issue Oct 10, 2024 · 5 comments
Closed

Exposed http client span as transaction #4162

Lucienzera opened this issue Oct 10, 2024 · 5 comments

Comments

@Lucienzera
Copy link

For react-native performance monitoring.

We are trying to capture the api latency for individual API. We notice that the performance are able to capture navigation and ui.load as transaction but not for http.client.

By surfacing the http.client span as transaction, we would be able to create custom widgets that is tied to our product domain within our application. Example: Api latency on /transaction

Image

Thank you

Side note: We only integrate our Expo RN application to Sentry and not our backend. So we are not able to do tracePropagationTargets since we wouldnt have the origin endpoint info? (assumption)

Do push me in the right direction. Thanks!

@krystofwoldrich
Copy link
Member

krystofwoldrich commented Oct 10, 2024

Hi,
thank you for the message,
as you mention these kind of measurements would be visible out of the box when using Sentry on the back end, but no worries you can achieve similar experience using only the RN SDK.

By default the network request are recorded as span in a transaction, this can't be changed.

But you can measure network request you are interested in manually using the Sentry.startInactiveSpan API.

Example:

const span = Sentry.startInactiveSpan({
  name: 'Request to example.request',
  op: 'http.request',
  forceTransaction: true,
});
await fetch('https://example.request');
span?.end();

Let us know if this works for you.

@krystofwoldrich krystofwoldrich moved this from Needs Discussion to Needs More Information in Mobile & Cross Platform SDK Oct 10, 2024
@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 3 Oct 10, 2024
@Lucienzera
Copy link
Author

Lucienzera commented Oct 11, 2024

Hi @krystofwoldrich , Thanks for getting back to me asap.

I can see how that would work. Do you think its advisable if I add this Sentry.startInactiveSpan at our network layer. So these span will get added dynamically for all without specifying manually?

And would this now create duplicates spans of http.client in a single transaction? Or it seperated out creates a new transaction entirely? How would the trace look like.

Thank you

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Oct 11, 2024
@krystofwoldrich
Copy link
Member

Do you think its advisable if I add this Sentry.startInactiveSpan at our network layer. So these span will get added dynamically for all without specifying manually?

Yes, you can do that. That's how our official integration works.

And would this now create duplicates spans of http.client in a single transaction? Or it seperated out creates a new transaction entirely? How would the trace look like.

These new transactions will be standalone and won't show in other transactions. But the original spans will still be created. But you can disable the automatic spans by using https://github.com/getsentry/sentry-react-native/blob/5a5c4b4941fa6e71bf3b449d3bc5b5b6f635fc23/packages/core/src/js/tracing/reactnativetracing.ts#L28C1-L40C21

@Lucienzera
Copy link
Author

@krystofwoldrich Thank you so much! I will try it out!

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Oct 21, 2024
@krystofwoldrich
Copy link
Member

I'll close the issue for now, but feel free to comment here in case of any further related questions, we can reopen it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Archived in project
Development

No branches or pull requests

2 participants