Skip to content

Commit

Permalink
Merge pull request #2376 from DataDog/mconstantin/rum-6400/add-log-fo…
Browse files Browse the repository at this point in the history
…r-sdk-initialization-outside-main-process

RUM-6400 Add warning log when initializing the SDK outside of main process
  • Loading branch information
mariusc83 authored Nov 7, 2024
2 parents ab89e64 + 97c83d1 commit a7c4f31
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 a7c4f31

Please sign in to comment.