RUM-9511: RumAuto scenario for android benchmark app#2689
Conversation
|
|
||
| Spacer(modifier = Modifier.width(8.dp)) | ||
|
|
||
| Column() { |
There was a problem hiding this comment.
9c246f2 to
5a7f10a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2689 +/- ##
===========================================
+ Coverage 69.91% 70.00% +0.09%
===========================================
Files 822 822
Lines 30693 30693
Branches 5169 5169
===========================================
+ Hits 21456 21484 +28
+ Misses 7794 7761 -33
- Partials 1443 1448 +5 🚀 New features to boost your workflow:
|
b853349 to
ce4e10c
Compare
| import javax.inject.Inject | ||
|
|
||
| @SuppressLint("CustomSplashScreen") | ||
| internal class LaunchActivity : AppCompatActivity() { |
There was a problem hiding this comment.
Important place.
Now the first activity that is launched is this LaunchActivity and then we launch a different activity with actual UI of the benchmarking scenario.
I had to do this, because automatic tracking of gestures in RUM is initialized here before Activity.onCreate is called. We have to know that need to enable RUM feature before Activity.onCreate.
The solution is to introduce this LaunchActivity which determines which scenario we run, initializes all necessary Datadog features and then launch the activity with the scenario itself.
Thanks @ambushwork for suggesting this idea.
| val context: Context | ||
| val benchmarkConfig: BenchmarkConfig | ||
|
|
||
| val sdkCore: SdkCore |
There was a problem hiding this comment.
All Datadog stuff moved to application component, because we initialize Datadog in LaunchActivity.onCreate and it only has access to BenchmarkAppComponent.
BenchmarkActivityComponent corresponds to the activity with scenario UI.
| } | ||
| } | ||
|
|
||
| private fun NavGraphBuilder.navGraphRumAutoScenario() { |
There was a problem hiding this comment.
Only this navGraphRumAutoScenario is new here, other code just moved and didn't change.
| } | ||
|
|
||
| private fun initializeCoil() { | ||
| Coil.setImageLoader(ImageLoader(applicationContext).newBuilder().okHttpClient(okHttpClient.get()).build()) |
There was a problem hiding this comment.
Initializing Coil with OkHttp client that already exists in dagger graph and is used everywhere (in Glide and for rickandmorty api requests).
| import com.datadog.sample.benchmark.R | ||
| import javax.inject.Inject | ||
|
|
||
| internal class SessionReplayNavigationManagerImpl @Inject constructor() : |
There was a problem hiding this comment.
This is FragmentsNavigationManagerImpl that I renamed to SessionReplayNavigationManagerImpl.
To me it looks better that each scenario has its own "NavigationManager", I created RumAutoScenarioNavigator for rumAuto. This one is for session replay.
| ) { | ||
| val lazyListState: LazyListState = rememberLazyListState() | ||
|
|
||
| LastItemTracker( |
There was a problem hiding this comment.
Tracking then last item appears, so that we can load more items.
| } | ||
| } | ||
|
|
||
| @AssistedFactory |
There was a problem hiding this comment.
| } | ||
| .launchIn(lifecycleScope) | ||
|
|
||
| trackRecyclerViewVisibleItems( |
There was a problem hiding this comment.
tracking visible items, so that we can load more items when end is reached
| ktorServerNetty = { module = "io.ktor:ktor-server-netty", version.ref = "ktorServer" } | ||
| ktorServerSSE = { module = "io.ktor:ktor-server-sse", version.ref = "ktorServer" } | ||
|
|
||
| # ktor client |
There was a problem hiding this comment.
this should have been in another commit, sorry
| sdkInstanceName = DATADOG_SDK_INSTANCE_NAME | ||
| ) { | ||
| @Inject | ||
| lateinit var okHttpClient: OkHttpClient |
There was a problem hiding this comment.
reusing okhttpclient that is already in dagger graph
| ktorClient = "2.3.13" | ||
| ktor = "1.6.8" |
There was a problem hiding this comment.
should we simply do ktor = 2.3.13, without introducing ktorClient option?
| setContentView(binding.root) | ||
|
|
||
| binding.rumAutoBottomNavbar.setContent { | ||
| val currentTab: RumAutoScenarioTab? by rumAutoScenarioNavigator.currentTab.collectAsStateWithLifecycle(null) |
There was a problem hiding this comment.
removed the explicit type, not needed
| fun provideBenchmarkConfig( | ||
| holder: BenchmarkConfigHolder | ||
| ): BenchmarkConfig { | ||
| return holder.config!! |
There was a problem hiding this comment.
changed to config field to be lateinit
| ExtendWith(ForgeExtension::class) | ||
| ) | ||
| @MockitoSettings(strictness = Strictness.LENIENT) | ||
| class KtorHttpClientUtilsTest { |
There was a problem hiding this comment.
minor: let's add given / when / then blocks to the tests for the readability
| @Extensions( | ||
| ExtendWith(MockitoExtension::class), | ||
| ExtendWith(ForgeExtension::class) | ||
| ) | ||
| @MockitoSettings(strictness = Strictness.LENIENT) |
There was a problem hiding this comment.
removed these annotations, not needed
There was a problem hiding this comment.
I added the transitive dependencies plugin here just for my own convenience to look at the dependencies I am using. Not very important.
36234a6 to
3655f68
Compare
| # Local Server | ||
| ktorCore = { module = "io.ktor:ktor", version.ref = "ktor" } | ||
| ktorGson = { module = "io.ktor:ktor-gson", version.ref = "ktor" } | ||
| ktorGson = { module = "io.ktor:ktor-serialization-gson", version.ref = "ktor" } |
There was a problem hiding this comment.
the name of the artifact changed when I changed to ktor=2.3.13, that is why sample:vendor-lib didn't compile
What does this PR do?
Implemented RUM Auto scenario for Android benchmark app, described here.
demo link
Created a synthetic test using this scenario link. I checked that it runs well for my local build.
RUM Session from the synthetic test: link
Sorry for a big pr. I split it into multiple commits, each containing a more or less independent part, so that it is easier to view. Also look at comments in the pr.
About the app.
OkHttp+Ktor 2.3.13+kotlinx.serializationfor requests to the api. NotKtor3, because it lead to update of kotlin stdlib version for the benchmark app (now we have 1.9.24, it became 2.something). Most likely it is fine, but I decided to be cautious here.Coilis used with theOkHttpclient that hasDatadogInterceptorinstalled in it.Glideis used with theOkHttpclient that hasDatadogInterceptorinstalled in it. For more convenientRecyclerViewimplementation AdapterDelegates4 library is used. Also ViewBinding is used.Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)