https://kotlinlang.org logo
#dagger
Title
# dagger
a

Amanjeet Singh

06/04/2021, 9:07 PM
Excited to announce DaggerTrack, A Gradle plugin that automatically adds clock tracking to dagger components and their subcomponents. Snapshots available now: https://github.com/amanjeetsingh150/dagger-track Project Website: https://amanjeetsingh150.github.io/dagger-track/ Useful for people optimizing their dagger graphs. Gives you wall clock time, on CPU and off CPU time for your injection. Do try it and give your reviews for further improvements. Contributions, feature requests, and issues are welcome.
1
c

Colton Idle

06/04/2021, 9:19 PM
Ooh. Sounds interesting. Will try to integrate this later tonight.
🙂 1
j

Jeremy

06/07/2021, 3:05 PM
Can library track the first time a dependency is initialized? Some things like OkHttp/Gson introduce delay when first init but the actual injection is fast I've found
1
a

Amanjeet Singh

06/07/2021, 3:41 PM
Hey @Jeremy thanks for reaching out currently DaggerTrack gives you total time took by dependencies of class say your application class to inject. The time per dependency is something which is in pipeline for this. But you can still see which of your classes took largest time to inject by replicating a cold start through adb commands and then narrow down through debug API tracing to see what is taking maximum time. Hope the answer helps. Let me know if you need any further help on this.
j

Jeremy

06/07/2021, 3:54 PM
👍 Currently we just add firebase trackers in modules. I've found in multiple apps that init of dagger graph is longest single component of app startup. Maybe library could allow folks to inject arbitrary tracking code for integration w/ their own trackers in prod
a

Amanjeet Singh

06/07/2021, 4:03 PM
Agreed, the dagger init is longest. For now, you can profile on your release debuggable builds to see which component is taking maximum and then further use this debug API record trace for that component injection to record per dependency time https://developer.android.com/reference/android/os/Debug#startMethodTracing(java.lang.String,%20int,%20int)
For recording the particular time in production as you suggested through trackers I have thought of some ideas like exposing annotations from library which will help you to record any desired dependency and then dump tracking logs to a file or maybe analytics. Will definitely work on this. Let me know if you any other feedbacks while using the library 🙂
j

Jeremy

06/10/2021, 9:02 PM
yep annotations would work, we currently just use
@AddTrace
on the module methods for "expensive" dependencies (okhttp, gson, react native) etc
👍 1
If doing this automatically I'd make sure to post whether main thread or not
3 Views