Datadog not able to track network call and logs from secondary isolates.
Describe the bug
Hey I have be using Datadog to setup observability for our app. With straightforward config as mentioned in docs its able to capture network class and logs happening in the flutter main context.
I have a specific scenario where in I delegate heavy operations like File Uploading etch to a secondary isolate using flutter_background_service.
Datadog not able to capture network calls and logs happening in the secondary flutter_background_services thread.
Reproduction steps
final configuration = DatadogConfiguration( clientToken: '', env: 'staging', site: DatadogSite.us5, nativeCrashReportEnabled: true, loggingConfiguration: DatadogLoggingConfiguration(), rumConfiguration: DatadogRumConfiguration( trackBackgroundEvents: true, applicationId: '', reportFlutterPerformance: true ), ) ..enableHttpTracking(); await DatadogSdk.runApp(configuration, TrackingConsent.granted, () async { runApp(const MainApp()); });
using latest: 2.13.1 version
SDK logs
No response
Expected behavior
No response
Affected SDK versions
2.13.1
Latest working SDK version
No response
Did you confirm if the latest SDK version fixes the bug?
Yes
Flutter Version
3.22.3
Setup Type
Pure Flutter App
Device Information
Android One Plus Device
Other relevant information
No response
Hi @khanjasir90,
This is a duplicate of #580, which contains a possible workaround, at least for logs. It may also work for HttpTracking as well, but I haven't tested it. Can you try the attachToExisiting workaround in your project and report back?
@fuzzybinary did try this but its behaviour is quite weird like sometimes it logs and sometimes it doesn't.
@khanjasir90 Is this potentially a race condition on initialization? Are you trying to log while Datadog is being initialized, or calling attachToExisting very early in the application's lifecycle? We've seen that be an issue in #580.
Can you also make background isolate tracking is raised as a Feature Request for our internal tracking?