dd-sdk-flutter icon indicating copy to clipboard operation
dd-sdk-flutter copied to clipboard

RUM Resource Event Mapper is not called sometimes

Open hakivin opened this issue 1 year ago • 6 comments

Describe the bug

In our 2 Flutter applications, we are using the Datadog SDK to monitor Real User Monitoring (RUM) events. We have implemented a resource event mapper to filter query parameters from the RUM resource events.

RumResourceEvent? _mapRumResourceEvent({
  required RumResourceEvent event,
}) {
  String finalUrl = event.resource.url;
  if (event.resource.type == RumResourceType.native) {
    final uri = Uri.tryParse(event.resource.url);
    if (uri != null) {
      if (_isExcludedResource(event.resource)) {
        return null;
      }
      // remove query params
      final url = '${uri.origin}${uri.path}';
      finalUrl = _maskUrl(url, method: event.resource.method);
    }
  }
  return event.copyWith(
    resource: event.resource.copyWith(
      url: finalUrl,
    ),
  );
}

We have observed that the resource event mapper is not consistently called for all resource events.

Image

We would appreciate any insights into why this issue happened. If there are any additional steps we can take to debug or resolve this issue, please let us know.

Thank you.

Reproduction steps

We are unable to reliably reproduce this issue since the issue is intermitten

SDK logs

No response

Expected behavior

No response

Affected SDK versions

2.5.0, 2.6.0

Latest working SDK version

No response

Did you confirm if the latest SDK version fixes the bug?

No

Flutter Version

3.19.6

Setup Type

No response

Device Information

No response

Other relevant information

No response

hakivin avatar Oct 08 '24 11:10 hakivin

Hi @hakivin,

Do you know if this seems to happen more often on iOS or Android?

Also, if you haven't yet, can you please open a support issue with Datadog and point them to this issue? I'd like to take a look and see if I'm seeing any telemetry from your org that might point to the potential problem.

Thanks!

fuzzybinary avatar Oct 08 '24 11:10 fuzzybinary

it is only happened in Android.

I have just submitted a support ticket. Thank you.

hakivin avatar Oct 08 '24 12:10 hakivin

Hi @hakivin ,

Really quick, do you have any background services or multiple flutter engines being created on Android? I'm seeing one error I expected, but a second that I wasn't.

fuzzybinary avatar Oct 09 '24 11:10 fuzzybinary

I don't think our apps are creating multiple Flutter engines or running any background services. May I know about the error you're seeing? I suspect it might be related to a background process as well.

hakivin avatar Oct 09 '24 11:10 hakivin

Hi @fuzzybinary, after further investigation, I discovered that an additional Flutter engine instance is being created by Firebase Messaging. This occurs specifically within the following code.

hakivin avatar Oct 10 '24 04:10 hakivin

Okay, that makes more sense now. I'll hopefully have a solution for you soon.

Thanks for reporting!

fuzzybinary avatar Oct 10 '24 09:10 fuzzybinary

Hi,

This should now be fixed in 2.8.0. We've raised the timeout for processing mappers and multiple flutter engines should no longer cause issues for the mappers. Let me know if you continue to see issues.

fuzzybinary avatar Oct 24 '24 14:10 fuzzybinary