-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add new duration signal type where the SDK tracks duration & sends it #224
Conversation
@Jeehut What do you think about not isolating these methods to the main actor? There is an unexpected side effect in that integrations will need to dispatch to the main queue to be able to access them (I already encountered this with the navigation API). It seems convenient to be able to use TelemetryDeck from any queue or actor, without "having to think about it too much" while making an app. |
@kkostov I don't necessarily agree with the navigation feature as navigation is directly related to UI (which is run on the main thread), but I do understand your point with this specific PR. I just reworked the details to use a |
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.
Fantastic work! There's so many cool things we can do with this on the UI
@Jeehut just to be sure we're on some page: I think it's fine to use strict concurrency, and it would be beneficial to have API which avoids interacting with the main queue directly. In iOS, for instance, handling events from other parts of the app often doesn't occur on the main thread (we don't enforce what the concept of "navigation" is for an app). Similarly, in Flutter, navigation events aren't necessarily on the main thread. In all these cases, dispatching could lead to unnecessary contention. Specifically for session duration, we're interacting with the local cache which happens on a worker queue and either very early or very late in the application lifecycle, I think it's good to avoid interfering with the main queue at these moments. If you still feel that this is work that must be done main, then it's better to leave the MainActor API so integrations will have a choice to use it without dispatch. |
@kkostov I'm not sure if you understood my previous message. I changed the implementation in this PR already to accommodate for your feedback since I agree. It's no longer requiring the main thread. If you want me to also change the thread for the navigation signal sending functions, feel free to open a separate issue since I'll be merging this now and that discussion doesn't belong here. I'm not sure if you requested that change now or already have a solution working with the current implementation for navigation. |
bdb8f5f
to
5d35f65
Compare
This implements what we had discussed in our call recently, documented in the Pirate Metrics overview task as:
I'm posting this as a separate PR because while it was discussed for Pirate Metrics, it's not directly related and can be published as a separate SDK improvement. I feel it could distract/confuse people if combined with Pirate Metrics.
I decided to call the APIs
startDurationSignal
andstopAndSendDurationSignal
. These two functions are the only added public API. The duration will be reported in the parameterTelemetryDeck.Signal.durationInSeconds
. The SDK takes care of the duration tracking internally, including making sure the duration only reflects the app's foreground time.Should I adjust the Swift SDK setup guide? Or write a new doc page about this? Or maybe a blog article?