Skip to content

🐛 Resource tracking cannot be turned off #2143

Closed
@cgood92

Description

@cgood92

Describe the bug
This is a problem with DataDog RUM.

While using @datadog/browser-rum-slim, v4.30.0 and v4.38.0 (latest), I have this configuration:

const ddRumConfig = {
  clientToken: 'SCRUBBED',
  applicationId: 'SCRUBBED',
  version: process.env.VERSION,
  sampleRate: 100,
  sessionReplaySampleRate: 0,
  trackUserInteractions: false,
  trackInteractions: false,
  trackResources: false,
  env: 'SCRUBBED',
};

    <script src="datadog-v4.38.0" type="text/javascript"></script>
    <script>
        window.DD_RUM && DD_RUM.onReady(function() {
            window.DD_RUM.init(ddRumConfig);
        })
    </script>

But, even with that, resources are still being tracked.

The expectation is that resources (ajax, css, js, etc) would not be tracked and sent to DataDog when the trackResources: false is set in the configuration.

I cloned your repo, and began looking into the problem, and here are some of my notes:

  1. If you search for trackResources, you will see that it is not used directly in any logic or conditions, but it is mapped to resourceAllowed.
  2. If you search for resourceAllowed, I can see that it is only used in computeIndexingInfo to set discarded as true. But, that doesn't stop the request from going through.

So, it looks to me as though the setting trackResources is not actually doing anything.

In addition to that, I think if someone sets trackResources to be false, that you should never run startResourceCollection or startRequestCollection, because:

  1. If we're not going to track these resources in DataDog, then don't spend cycles instrumenting and tracking them (this just slows down our system).
  2. Instrumenting them ruins stack traces for no reason if we're not going to use DataDog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions