简体   繁体   中英

Using the Datadog logs and RUM SDKs sends multiple requests when errors are being thrown

I have the following issue:

However, I want to run them both, so this is not an option at the moment.

    import { datadogLogs } from '@datadog/browser-logs';
    import { datadogRum } from '@datadog/browser-rum';

    if (process.env.NODE_ENV === 'production' && process.env.DATADOG_CLIENT_TOKEN) {
            const environment = getEnvironment();
            const config = {
                site: 'datadoghq.eu',
                clientToken: process.env.DATADOG_CLIENT_TOKEN,
                service: typeof DATADOG_SERVICE !== 'undefined' ? DATADOG_SERVICE : undefined,
                env: environment ? `${environment}` : undefined,
                proxyHost: process.env.PROXY_HOST
            };
        
            datadogLogs.init(config);
        
            
                if (process.env.DATADOG_APPLICATION_ID) {
                    datadogRum.init({
                        ...config,
                        trackInteractions: true,
                        applicationId: process.env.DATADOG_APPLICATION_ID
                    });
        
                    datadogRum.setUser({
                        name: service.getName(),
                        email: service.getEmail()
                    });
                }
    }

I had the same issue, Upgrading both Datadog Rum and logging to 3.6.13 fixed this for me:

"@datadog/browser-logs": "^3.6.13",
"@datadog/browser-rum": "^3.6.13",

For anyone else:

  1. Use localhost , not custom domain names. For some reason, DD_RUM.getInternalContext() didn't work for custom domain names.

  2. Install versions of both RUM and logs - latest and possibly the same version. Incase you want specific varying versions, check the dependency packages for the datadog packages on the package.lock. It can be different which can throw errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM