-
Notifications
You must be signed in to change notification settings - Fork 60
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
RUM-6400 Add warning log when initializing the SDK outside of main process #2376
RUM-6400 Add warning log when initializing the SDK outside of main process #2376
Conversation
@@ -626,6 +626,13 @@ internal class CoreFeature( | |||
} else { | |||
appContext.packageName == currentProcess.processName | |||
} | |||
if (!isMainProcess) { | |||
internalLogger.log( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewers should we also send a telemetry here ? I think it is a bit overkill, what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be actionable? how it would help us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure it will be that actionable, that is the reason why I did not add it and just asked your opinion. I think we are better off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's an interesting data to know at least, and if we notice that there are really amount of clients doing it in background (probably meaning intentionally), the action will be making it work even if the initialization happens in background.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2376 +/- ##
===========================================
+ Coverage 70.31% 70.41% +0.10%
===========================================
Files 744 744
Lines 27719 27724 +5
Branches 4631 4632 +1
===========================================
+ Hits 19490 19520 +30
+ Misses 6939 6926 -13
+ Partials 1290 1278 -12
|
internal const val SDK_INITIALIZED_IN_SECONDARY_PROCESS_WARNING_MESSAGE = | ||
"Datadog SDK was initialized in a secondary process. We strongly recommend to initialize the SDK" + | ||
"in the application main process otherwise the SDK would not function properly. The only scenario" + | ||
"where this is acceptable is where there will be 2 instances of the SDKs running " + | ||
"in the same time and one instance is guaranteed to be in the main process." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal const val SDK_INITIALIZED_IN_SECONDARY_PROCESS_WARNING_MESSAGE = | |
"Datadog SDK was initialized in a secondary process. We strongly recommend to initialize the SDK" + | |
"in the application main process otherwise the SDK would not function properly. The only scenario" + | |
"where this is acceptable is where there will be 2 instances of the SDKs running " + | |
"in the same time and one instance is guaranteed to be in the main process." | |
internal const val SDK_INITIALIZED_IN_SECONDARY_PROCESS_WARNING_MESSAGE = | |
"Datadog SDK was initialized in a secondary process. We strongly recommend to initialize the SDK" + | |
" in the application main process otherwise the SDK would not function properly. The only scenario" + | |
" where this is acceptable is where there will be 2 instances of the SDKs running" + | |
" in the same time and one instance is guaranteed to be in the main process." |
I feel though that this is very verbose. Maybe we can re-word it simpler? Like tell user that SDK must have instance initialized in the main process and that is it. And speaking of the SDK would not function properly
: maybe we can just say that no data will be recorded (well, to be precise - uploaded).
This warning though raises a question why such limitation exists and why cannot we solve it (in theory we could?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I wanted to present all the possibilities in the message but I guess we can lower the amount of information. Regarding your second point there are some strong reasons why we took this approach. Let's debate about this.
1ec22e1
to
fad663b
Compare
"Datadog SDK was initialized in a secondary process. We strongly recommend to initialize the SDK" + | ||
"in the application main process. The sdk will not upload any data in this case." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
We strongly recommend to initialize the SDK in the application main process
This part of the message makes it seem like initialising the SDK in a secondary process is wrong, when it's totally legitimate to want to capture events in a non main process.
Maybe we could phrase it differently, e.g.:
"Datadog SDK was initialized in a secondary process. We strongly recommend to initialize the SDK" + | |
"in the application main process. The sdk will not upload any data in this case." | |
"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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I agree this makes more sense. the first message was making more sense with my initial message where I explained the difference between running it in the main or main + secondary also.
fad663b
to
22e1d39
Compare
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: does "the main process" refers to "main thread" in Android?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Android each process has its own JVM running code, each with several threads.
"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" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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" + | |
"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" + |
22e1d39
to
97c83d1
Compare
What does this PR do?
During our escalation sessions with our clients we encountered several situations where the SDK was not initialised outside the main process. Unless the application is using 2 different processes and has 2 SDK instances (one in each process) this scenario will lead to a non - functional SDK as the data will no be uploaded as we are not initialising our schedulers in a secondary process.
In this PR we are adding a warning log for our users when the SDK is initialised in a secondary process just to better debug this situations and avoid long escalation back and forth.
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)