Skip to content

High Trace Duration in Distributed Tracing When App Goes to Background #236

@ngcvm

Description

@ngcvm

Description
Not sure if it's an issue. I'm using newrelic-react-native-agent as a New Relic agent in my React Native project. When viewing the distributed tracing for my mobile app in the New Relic dashboard (Production), I notice that some tracing requests have unusually high trace duration times.

After debugging locally, I can confirm that my HTTP requests do not take that long, and the test distributed tracing logs reflect the correct durations. However, I can reproduce the issue by opening the app and suddenly putting it into the background.

In the Timeline view of the high trace duration events, I see a blank time gap between the start span and end span, which seems to correspond to the time the app was in the background.

Context

  • React Native version: 0.75.3
  • newrelic-react-native-agent version: 1.5.5
  • Platform: iOS
  • Background fetch: Enabled

Expected Behavior
The trace duration time should reflect the actual HTTP request time, even if the app transitions to the background during the request.

Observed Behavior

  • Trace duration times are significantly inflated when the app transitions to the background during an HTTP request.
  • In the Timeline view, there is a blank time gap between the start span and end span, which seems to correspond to the time the app was in the background.

Questions

  1. Does the trace duration time also include UI interaction or other app lifecycle events?
  2. If I want to track only the HTTP request time for mobile, should I use custom events instead of relying on noticeHttpTransaction?

Steps to Reproduce

  1. Open the app and initiate an HTTP request.
  2. Immediately put the app into the background while the request is in progress.
  3. Bring the app back to the foreground and observe the distributed tracing logs in the New Relic dashboard.

Additional Notes

  • The issue seems to occur because the app transitions to the background, and the trace duration includes the time the app was paused.
  • I have tried to disabled these configurations: interactionTracingEnabled, webViewInstrumentation

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions