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

feat: UI events transactions #1975

Merged
merged 54 commits into from
May 13, 2022
Merged

feat: UI events transactions #1975

merged 54 commits into from
May 13, 2022

Conversation

romtsn
Copy link
Member

@romtsn romtsn commented Apr 5, 2022

📜 Description

  • Adds idleTimeout to SentryTracer to finish idled transaction
  • Creates a new transaction whenever a UI action is performed (click, swipe, scroll).

💡 Motivation and Context

Q1 Goal
Closes #1811

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

🔮 Next steps

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2022

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 0161bd7

@marandaneto
Copy link
Contributor

@romtsn This should target 6.x.x

@romtsn
Copy link
Member Author

romtsn commented Apr 5, 2022

@romtsn This should target 6.x.x

Why?

@marandaneto
Copy link
Contributor

@romtsn This should target 6.x.x

Why?

Hub interface is a public API and it has changed.

@romtsn
Copy link
Member Author

romtsn commented Apr 6, 2022

@marandaneto mm, but only methods marked as Internal have changed. Only if we care about ABI, then it makes sense.

@marandaneto
Copy link
Contributor

@marandaneto mm, but only methods marked as Internal have changed. Only if we care about ABI, then it makes sense.

Indeed, but I'd rather point to v6 to speed up this major release, by that I mean more people working on the new code base and testing out all the changes.
Unless @bruno-garcia says otherwise.

@romtsn
Copy link
Member Author

romtsn commented Apr 11, 2022

@marandaneto mm, but only methods marked as Internal have changed. Only if we care about ABI, then it makes sense.

Indeed, but I'd rather point to v6 to speed up this major release, by that I mean more people working on the new code base and testing out all the changes. Unless @bruno-garcia says otherwise.

sounds good, have no problem with targeting 6.x.x actually!

@romtsn romtsn changed the base branch from main to 6.x.x April 12, 2022 14:16
@romtsn romtsn changed the base branch from 6.x.x to main April 12, 2022 14:16
@romtsn
Copy link
Member Author

romtsn commented Apr 28, 2022

@marandaneto @philipphofmann @adinauer this is ready for review PTAL

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the PR looks great. Thanks for all the effort. Maybe I missed it, but I'm not sure if the code handles the following scenario:

Scenario: Ongoing UI event transaction
   Given an ongoing UI event transaction
   When the SDK creates a new screen load transaction
   Then the SDK finishes the previous transactions
   And removes it from the scope
   And sets the status to canceled
   And waits for its children to finish

CHANGELOG.md Outdated Show resolved Hide resolved
sentry/src/test/java/io/sentry/SentryTracerTest.kt Outdated Show resolved Hide resolved
@@ -562,4 +566,102 @@ class SentryTracerTest {
anyOrNull()
)
}

@Test
fun `when initialized without idleTimeout, does not schedule finish timer`() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: Can we also add a test for when the idle timeout expires, but the transaction has still an unfinished child. I think we should then wait for the child to finish.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we said we cancel the timer when a new child is added and reset it when the last child is finished, so there's technically no idle timeout while there's an ongoing child span.

Even though, this has been missing in my code, so I'll update that, thanks for the point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense. Thanks for the clarification.

@marandaneto
Copy link
Contributor

@romtsn please update the PR Checklist

CHANGELOG.md Outdated Show resolved Hide resolved
@romtsn
Copy link
Member Author

romtsn commented May 5, 2022

Overall the PR looks great. Thanks for all the effort. Maybe I missed it, but I'm not sure if the code handles the following scenario:

Scenario: Ongoing UI event transaction
   Given an ongoing UI event transaction
   When the SDK creates a new screen load transaction
   Then the SDK finishes the previous transactions
   And removes it from the scope
   And sets the status to canceled
   And waits for its children to finish

Yeah, this is done here ->

void stopTracing(final @NotNull SpanStatus status) {
if (activeTransaction != null) {
activeTransaction.finish(status);
}
hub.configureScope(
scope -> {
clearScope(scope);
});
activeTransaction = null;
activeView.clear();
activeEventType = null;
}

With the only difference that we do this when the current screen goes inactive (onPause). This makes sense for us, because we use android's WindowCallback, which will get detached as soon as the activity/screen goes inactive, therefore it wouldn't make sense for us to wait until the new screen transaction, but rather finish it here.

@codecov-commenter
Copy link

Codecov Report

Merging #1975 (bdcd818) into 6.x.x (d1c8c4d) will increase coverage by 0.07%.
The diff coverage is 85.05%.

@@             Coverage Diff              @@
##              6.x.x    #1975      +/-   ##
============================================
+ Coverage     80.79%   80.86%   +0.07%     
- Complexity     3146     3169      +23     
============================================
  Files           228      228              
  Lines         11645    11714      +69     
  Branches       1565     1577      +12     
============================================
+ Hits           9409     9473      +64     
- Misses         1649     1650       +1     
- Partials        587      591       +4     
Impacted Files Coverage Δ
sentry/src/main/java/io/sentry/Hub.java 75.72% <ø> (ø)
sentry/src/main/java/io/sentry/HubAdapter.java 8.19% <ø> (ø)
sentry/src/main/java/io/sentry/IHub.java 87.50% <0.00%> (-3.81%) ⬇️
sentry/src/main/java/io/sentry/NoOpHub.java 48.78% <ø> (ø)
...entry/src/main/java/io/sentry/NoOpTransaction.java 25.80% <0.00%> (-0.87%) ⬇️
sentry/src/main/java/io/sentry/Sentry.java 45.06% <ø> (ø)
sentry/src/main/java/io/sentry/SentryTracer.java 91.17% <83.01%> (+0.37%) ⬆️
...main/java/io/sentry/config/PropertiesProvider.java 90.00% <85.71%> (-10.00%) ⬇️
...entry/src/main/java/io/sentry/ExternalOptions.java 100.00% <100.00%> (ø)
sentry/src/main/java/io/sentry/SentryOptions.java 81.74% <100.00%> (+0.85%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1c8c4d...bdcd818. Read the comment docs.

@romtsn
Copy link
Member Author

romtsn commented May 13, 2022

Reverted frame metrics as we'll do it as part of #2101

@romtsn romtsn merged commit 840fc7e into 6.x.x May 13, 2022
@romtsn romtsn deleted the feat/ui-transactions branch May 13, 2022 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timeout for waitForChildren feature
6 participants