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

Calculate frame delay on a span level #3197

Merged
merged 11 commits into from
Feb 16, 2024
Merged

Conversation

markushi
Copy link
Member

@markushi markushi commented Feb 7, 2024

📜 Description

Fixes #3183

💡 Motivation and Context

Screen_recording_20240208_093207.mp4

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Copy link
Contributor

github-actions bot commented Feb 7, 2024

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

Generated by 🚫 dangerJS against 02befdc

Copy link
Contributor

github-actions bot commented Feb 7, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 422.46 ms 528.46 ms 106.00 ms
Size 1.70 MiB 2.27 MiB 586.31 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
93a76ca 377.96 ms 447.52 ms 69.56 ms
baaf637 462.32 ms 579.22 ms 116.90 ms
2465853 411.39 ms 461.10 ms 49.72 ms
c3f503e 360.41 ms 434.67 ms 74.27 ms
93a76ca 381.08 ms 459.22 ms 78.14 ms
c7e2fbc 393.98 ms 478.24 ms 84.27 ms
2465853 422.61 ms 491.20 ms 68.58 ms
5e04ee8 302.68 ms 343.36 ms 40.68 ms
283d83e 416.81 ms 497.22 ms 80.41 ms
d6d2b2e 413.20 ms 486.76 ms 73.56 ms

App size

Revision Plain With Sentry Diff
93a76ca 1.72 MiB 2.29 MiB 576.75 KiB
baaf637 1.72 MiB 2.27 MiB 558.42 KiB
2465853 1.70 MiB 2.27 MiB 583.82 KiB
c3f503e 1.72 MiB 2.29 MiB 577.04 KiB
93a76ca 1.72 MiB 2.29 MiB 576.75 KiB
c7e2fbc 1.72 MiB 2.29 MiB 576.40 KiB
2465853 1.70 MiB 2.27 MiB 583.82 KiB
5e04ee8 1.70 MiB 2.27 MiB 584.64 KiB
283d83e 1.72 MiB 2.29 MiB 577.69 KiB
d6d2b2e 1.72 MiB 2.27 MiB 555.05 KiB

Previous results on branch: feat/frame-delay-per-span

Startup times

Revision Plain With Sentry Diff
cd12d56 391.75 ms 461.53 ms 69.78 ms
af827fa 439.17 ms 516.45 ms 77.28 ms
2d2263f 348.71 ms 388.90 ms 40.18 ms
2248393 448.29 ms 525.46 ms 77.17 ms
d9a60b1 405.83 ms 465.22 ms 59.39 ms
8dff466 390.89 ms 469.38 ms 78.49 ms

App size

Revision Plain With Sentry Diff
cd12d56 1.70 MiB 2.27 MiB 586.08 KiB
af827fa 1.70 MiB 2.27 MiB 586.30 KiB
2d2263f 1.70 MiB 2.27 MiB 586.22 KiB
2248393 1.70 MiB 2.27 MiB 586.38 KiB
d9a60b1 1.70 MiB 2.27 MiB 586.30 KiB
8dff466 1.70 MiB 2.27 MiB 586.42 KiB

@markushi markushi marked this pull request as ready for review February 8, 2024 15:32
Copy link
Member

@stefanosiano stefanosiano left a comment

Choose a reason for hiding this comment

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

It looks good overall.
I guess we have to revisit the SpanFrameMetricsCollector, as it doesn't work correctly for multiple spans at the same time.
Maybe there is also a way to get rid of those intermediate classes (SpanStart and NanoTimeStamp), too?

@markushi
Copy link
Member Author

It looks good overall. I guess we have to revisit the SpanFrameMetricsCollector, as it doesn't work correctly for multiple spans at the same time. Maybe there is also a way to get rid of those intermediate classes (SpanStart and NanoTimeStamp), too?

I've resolved the issue for multi-spans, mixed up head/tailSet APIs 🙈
I'd love to get rid of SpanStart and NanoTimeStamp, I'll have a look and provide a follow up PR if something more elegant would work here.

return;
}

final long spanDurationNanos = spanEndNanos - spanStartNanos;
Copy link
Member

Choose a reason for hiding this comment

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

just trying to wrap my head around - why this wasn't working and why do we need a separate collection to track start timestamps?

 final long spanDurationNanos = spanFinishDate.diff(span.getStartDate());

Copy link
Member

Choose a reason for hiding this comment

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

in this case it should work fine

Copy link
Member Author

Choose a reason for hiding this comment

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

Because our ISpans only have SentryDate, which itself has no guarantees around precision - it could be e.g. a time synced unix timestamp. SentryDate is also not Comparable, so it can't be saved in an ordered set.
I'd be happy to change this within the whole SDK though. Maybe an extra one, to not blow this PR up too much 😅

Copy link
Member

Choose a reason for hiding this comment

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

but SentryDate is an abstract class, in the end it'll be either SentryNanotimeDate or SentryInstantDate which both have the nanoseconds precision. And it's actually Comparable ;)

@Override
public int compareTo(@NotNull SentryDate otherDate) {
return Long.valueOf(nanoTimestamp()).compareTo(otherDate.nanoTimestamp());
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, I've looked into it and got it working by applying a little trick

Copy link
Member

Choose a reason for hiding this comment

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

you can remove that trick if you use the SentryNanotimeDate in the Frame object, instead of nanoseconds

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

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

Great stuff overall, I just have a couple of questions to clarify. Great work with the new sample screen for testing this stuff, looks really helpful 🚀

}

@ApiStatus.Internal
public static class Frame implements Comparable<Frame> {
Copy link
Member

Choose a reason for hiding this comment

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

this class can be private

Copy link
Member

@stefanosiano stefanosiano left a comment

Choose a reason for hiding this comment

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

just make Frame class private and we're good to go.
Your call if you want to change the nanoseconds to SentryNanotimeDate (or evaluate to do it in another PR)
very nice!

@markushi markushi merged commit 95a98b5 into main Feb 16, 2024
24 checks passed
@markushi markushi deleted the feat/frame-delay-per-span branch February 16, 2024 19:37
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.

Attach frame delay to spans
3 participants