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

add app launch TTI log #12

Merged
merged 18 commits into from
Aug 30, 2024
Merged

add app launch TTI log #12

merged 18 commits into from
Aug 30, 2024

Conversation

Augustyniak
Copy link
Contributor

@Augustyniak Augustyniak commented Aug 28, 2024

Add predefined App Launch TTI log that can be emitted by customers using Capture SDK. In the future, we will create Capture SDK integration that emits this log automatically, in the current version we expect Capture SDK customers to call the method manually.

@Augustyniak Augustyniak marked this pull request as ready for review August 29, 2024 15:59
@Augustyniak Augustyniak requested a review from murki August 29, 2024 17:50
@@ -121,6 +124,8 @@ class MainActivity : ComponentActivity() {

Logger.addField("field_container_field_key", "field_container_field_value")
Logger.logInfo(mapOf("key" to "value")) { "MainActivity onCreate called" }

Logger.logAppLaunchTTI(1.toDuration(DurationUnit.SECONDS))
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not accurate /trolling

*/
external fun writeAppLaunchTTILog(
loggerId: Long,
durationS: Double,
Copy link
Contributor

Choose a reason for hiding this comment

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

why the S in the param name? Is it in Seconds?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see below that it is. Is this a standard, to use seconds in Doubles to track time? and if so we should add the seconds unit part to the docstring

Copy link
Contributor

Choose a reason for hiding this comment

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

also worth mentioning that the value should be positive otherwise will be ignored

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see below that it is. Is this a standard, to use seconds in Doubles to track time? and if so we should add the seconds unit part to the docstring

I like the idea. Will do.

also worth mentioning that the value should be positive otherwise will be ignored

Is there ever a case when negative duration make sense? 🙃 I can add this info to the method documentation but I wonder whether it's worth it given that it will provide little to no value at the expense of more clutter in docs. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Anything that an API allows users will do. My opinion is that we should never allow for invalid operations using the type system itself e.g. our Span API doesn't allow negative durations.

So at least we should document that this particular usage is invalid

@@ -72,6 +73,7 @@ interface ILogger {

/**
* Logs a message at a specified level.
*
Copy link
Contributor

Choose a reason for hiding this comment

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

fighting the good fight

Copy link
Contributor Author

Choose a reason for hiding this comment

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

always for the right cause

false,
);
});
}
Copy link
Contributor

@murki murki Aug 29, 2024

Choose a reason for hiding this comment

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

kudos for not putting this logic in shared-core 🙌
so much easier to review and make changes if needed

/// Logs an out-of-the-box app launch TTI log event. The method should be called only once.
/// Consecutive calls have not effect.
pub fn log_app_launch_tti(&self, duration: time::Duration) {
self.app_launch_tti_log.call_once(|| {
Copy link
Contributor

@murki murki Aug 29, 2024

Choose a reason for hiding this comment

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

I'm just learning about this primitive and their docs say

This method will block the calling thread if another initialization routine is currently running.

which seems to be aimed to help with

It is also guaranteed that any memory writes performed by the executed closure can be reliably observed by other threads at this point

This sounds like an overkill to me since there are no shared resources that we'd like to guard, but maybe I'm misunderstanding something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method will block the calling thread if another initialization routine is currently running.

yes, makes sense. Basically there is a lock in here to guarantee that the critical path is run only once. I do not think that it's a problem, we use locks here and there.

This sounds like an overkill to me since there are no shared resources that we'd like to guard, but maybe I'm misunderstanding something

I think it's fine, we use it in similar cases in other places in code. We want to protect ourselves from cases where a user wants to log app launch TTI multiple times, with this method we can implement it with a minimal amount of effort + it protects us from cases where a user have multiple threads that try to log app launch TTI at the same time (yes, it will most likely not happen in real life scenarios but since we get this protection almost fore free it's nice to have)

Copy link
Contributor

Choose a reason for hiding this comment

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

sg

self.log(
log_level::INFO,
LogType::Lifecycle,
"AppLaunchTTI".into(),
Copy link
Contributor

Choose a reason for hiding this comment

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

It could be argued that this value should be just a field in the existing app launch event, but I see how exposing it in our public api would make that complicated, so I guess this will have to do for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, making it a part of existing TTI would be tricky. Also, I think that they may diverge in the past: app launch is app launch as defined by the system while app launch TTI may be time to interaction to the first time a user touches a screen (depending on what we mean by TTI) and having them combined then would be tricky. I agree tho, we can cross this bridge when we get there

@Augustyniak Augustyniak enabled auto-merge (squash) August 30, 2024 01:53
@Augustyniak Augustyniak disabled auto-merge August 30, 2024 02:05
@Augustyniak Augustyniak enabled auto-merge (squash) August 30, 2024 11:52
@Augustyniak Augustyniak merged commit 71a64f1 into main Aug 30, 2024
15 checks passed
@Augustyniak Augustyniak deleted the add-app-launch-tti-log branch August 30, 2024 12:07
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants