Skip to content

Commit

Permalink
RUM-6400 Add warning log when initializing the sdk outside of main pr…
Browse files Browse the repository at this point in the history
…ocess
  • Loading branch information
mariusc83 committed Nov 7, 2024
1 parent b83e7b6 commit 97c83d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,13 @@ internal class CoreFeature(
} else {
appContext.packageName == currentProcess.processName
}
if (!isMainProcess) {
internalLogger.log(
InternalLogger.Level.WARN,
InternalLogger.Target.USER,
{ SDK_INITIALIZED_IN_SECONDARY_PROCESS_WARNING_MESSAGE }
)
}
}

private fun shutDownExecutors() {
Expand Down Expand Up @@ -676,6 +683,10 @@ internal class CoreFeature(
// endregion

companion object {
internal const val SDK_INITIALIZED_IN_SECONDARY_PROCESS_WARNING_MESSAGE =
"Datadog SDK was initialized in a secondary process: although data will still be captured," +
" nothing will be uploaded from this process. Make sure to also initialize the SDK from the main" +
" process of your application."

internal val DEFAULT_FLUSHABLE_EXECUTOR_SERVICE_FACTORY =
FlushableExecutorService.Factory { logger, executorContext, backPressureStrategy ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,11 @@ internal class CoreFeatureTest {

// Then
assertThat(testedFeature.isMainProcess).isFalse()
mockInternalLogger.verifyLog(
InternalLogger.Level.WARN,
InternalLogger.Target.USER,
CoreFeature.SDK_INITIALIZED_IN_SECONDARY_PROCESS_WARNING_MESSAGE
)
}

@Test
Expand Down

0 comments on commit 97c83d1

Please sign in to comment.