RUMM-2607: Use event write context for Logs#1103
Conversation
ca2db72 to
cd86390
Compare
Codecov Report❌ Patch coverage is Please upload reports for the commit 169cbec to get more accurate results. Additional details and impacted files@@ Coverage Diff @@
## feature/sdkv2 #1103 +/- ##
=================================================
- Coverage 82.69% 82.46% -0.23%
=================================================
Files 350 351 +1
Lines 11301 11362 +61
Branches 1846 1874 +28
=================================================
+ Hits 9345 9369 +24
- Misses 1394 1424 +30
- Partials 562 569 +7
🚀 New features to boost your workflow:
|
|
|
||
| @AnyThread | ||
| override fun onReceive(event: Any) { | ||
| if (event !is Map<*, *>) { |
|
|
||
| @Suppress("ComplexMethod") | ||
| private fun sendCrashLog(data: Map<*, *>) { | ||
| val threadName = data["threadName"] as? String |
There was a problem hiding this comment.
should we add these keys in static constants or maybe not as they will not be visible from the other modules anyway ?
There was a problem hiding this comment.
They are not in the constants on purpose, because caller (crash reporting/NDK crash reporting) and consumer (logs) will be in the different modules without any dependency. We have a task in the backlog to document messages format though.
Maybe later will create some common constants in the core module, will see.
|
|
||
| @Suppress("UnsafeThirdPartyFunctionCall") | ||
| val lock = | ||
| if (syncWrite) CountDownLatch(1) else null |
| datadogContext: DatadogContext, | ||
| networkInfo: NetworkInfo? | ||
| ): LogEvent.Network { | ||
| // TODO RUMM-0000 use V2 (RUM should write V2 version) |
There was a problem hiding this comment.
I am not sure I get this comment ?
There was a problem hiding this comment.
for NDK crash reporting we are saving to the disk UserInfo and NetworkInfo as models from com.datadog.android.core.model package. So later on we deserialized them back in the DatadogNdkCrashHandler and create LogEvent, but outside this flow, say using the normal Logger we are taking UserInfo and NetworkInfo from DatadogContext, and these ones are living in com.datadog.android.v2.api.context, they are different classes.
There was a problem hiding this comment.
I see, tks for the explanation ;)
| ) | ||
|
|
||
| @Suppress("ThreadSafety") // called in a worker thread context | ||
| dataWriter.write(eventBatchWriter, log) |
There was a problem hiding this comment.
why not using the eventBatchWriter directly?
There was a problem hiding this comment.
Because of the assertion. EventBatchWriter is taking ByteArray, I cannot use LogEventAssert with it directly (without de-serializing back). So just for the convenience.
xgouchet
left a comment
There was a problem hiding this comment.
LGTM, added one comment
cd86390 to
169cbec
Compare
What does this PR do?
This change brings the usage of event write context (EWC) to the Logs feature, by doing the following:
withWriteContextto getDatadogContextand the binary batch writer.LogEventis now taken fromDatadogContextwhich is not available during the feature construction time, many values are moved out from theDatadogLogGeneratorconstructor.LogEventshould be created and written in the synchronous manner, caller should pass thesyncWriteparameter with the event.DataWriterfor v2 now should accept 2 arguments for thewritemethod - event which should be serialized, andEventBatchWriterwhich will write serialized event and provided by thewithWriteContextcall.There is some duplication between
NetworkInfoandUserInfoclasses from v2 and network model packages, it will essentially go away later (we won't expose network models in the public API).Review checklist (to be filled by reviewers)