-
Notifications
You must be signed in to change notification settings - Fork 10
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
Improving instrumentation around UIViewController
#126
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files |
Tests/EmbraceCoreTests/Capture/UX/View/CaptureServicesUIViewControllerTests.swift
Show resolved
Hide resolved
Tests/EmbraceCoreTests/Capture/UX/View/CaptureServicesUIViewControllerTests.swift
Show resolved
Hide resolved
Tests/EmbraceCoreTests/Capture/UX/View/CaptureServicesUIViewControllerTests.swift
Show resolved
Hide resolved
Tests/EmbraceCoreTests/Capture/UX/View/CaptureServicesUIViewControllerTests.swift
Show resolved
Hide resolved
Tests/EmbraceCoreTests/Capture/UX/View/UIViewControllerHandlerTests.swift
Show resolved
Hide resolved
Generated by 🚫 Danger Swift against 0bba885 |
Comment on lines
123
to
129
guard let id = vc.emb_identifier, | ||
let span = self.viewDidLoadSpans[id] else { | ||
return | ||
} | ||
|
||
span.end() | ||
self.viewDidLoadSpans[id] = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: to prevent from accessing twice the dictionary (which also has the locking mechanism) maybe you can do something like:
Suggested change
guard let id = vc.emb_identifier, | |
let span = self.viewDidLoadSpans[id] else { | |
return | |
} | |
span.end() | |
self.viewDidLoadSpans[id] = nil | |
guard let id = vc.emb_identifier, | |
let span = self.viewDidLoadSpans.removeValue(forKey: id) else { | |
return | |
} | |
span.end() |
ArielDemarco
approved these changes
Nov 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a refactor on
ViewCaptureService
.It still retains the old functionality: It creates
emb-screen-view
spans whenviewDidAppear
is called on aUIViewController
. These spans are ended whenviewDidDisappear
is called.This feature can be enabled/disabled through
ViewCaptureService.Options.instrumentVisibility
.Added a new feature to automatically instrument the time-to-render on
UIViewControllers
.This will create a parent span starting from
viewDidLoad
and ending onviewDidAppear
.The parent span will contain child spans for each step of the loading process (
viewDidLoad
.viewWillAppear
andviewDidAppear
).The user can enable/disable this through
ViewCaptureService.Options.instrumetTimeToRender
.If the
UIViewController
implements theInteractableViewController
protocol, the service will create the time-to-interactive span instead.This is a parent span starting from
viewDidLoad
and ending when the view is deemed as ready to be interacted or theUIViewController
disappears.The implementers must call
InteractableViewController.onInteractionReady()
to flag the view as ready.The parent span will contain child spans for each step of the loading process (
viewDidLoad
.viewWillAppear
andviewDidAppear
), and an extraui-ready
span that starts at the end ofviewDidAppear
and ends when the view is ready for interaction.Furthermore, if the
UIViewController
implements theInstrumentableViewController
protocol, it can use thebuildChildSpan
andrecordCompletedChildSpan
methods to add custom child spans to the time-to-render/time-to-interactive parent spans.