Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distributed Tracing Doesn't Seem to Work With Built Files #77

Closed
wrumsby opened this issue Jun 15, 2021 · 2 comments
Closed

Distributed Tracing Doesn't Seem to Work With Built Files #77

wrumsby opened this issue Jun 15, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@wrumsby
Copy link

wrumsby commented Jun 15, 2021

Description

I've tried using the built files to host the SPA agent locally with a configuration like the following:

<script type="text/javascript">
  window.NREUM||(NREUM={});
  NREUM.init = {
    distributed_tracing: {
      enabled: true,
      cors_use_newrelic_header: true,
      cors_use_tracecontext_headers: true,
      allowed_origins: [/* array of strings of origins, e.g. 'https://example.com', 'https://mydomain' */]
    },
    privacy: {
      cookies_enabled: true
    }
  };
  NREUM.info = {
    licenseKey: "/* my license key */",
    applicationID: /* my application id */,
    agent: "https://MY_CDN/nr-spa.js"
  };
</script>
<script src="https://MY_CDN/nr-loader-spa.js"></script>

It appears that most of the standard browser monitoring works, but distributed tracing does not.

Steps to Reproduce

  1. clone this project
  2. run npm run build
  3. upload the generated nr-spa.js and nr-spa-loader.js to a CDN, web server, etc.
  4. initialise the agent to use distributed tracing with a set of allowed domains that are also configured to support distributed tracing headers
  5. in a browser app using the generated scripts make XHR requests which should be included in distributed traces

Expected Behavior

  • AJAX requests are made with tracestate, traceparent and newrelic headers
  • requests appear in Distributed Tracing

Relevant Logs / Console output

Your Environment

  • Chome 91.0.4472.101
  • OS X 11.4

Additional context

@wrumsby wrumsby added bug Something isn't working needs triage labels Jun 15, 2021
@aubreymasten
Copy link
Contributor

Hey @wrumsby, thanks for all the detail here! You may need to include some additional attributes in NREUM.info for distributed tracing to work. If you add accountId and agentId to that config block, are the headers still not showing up on outgoing requests?

The agent checks these attributes before generating Distributed Tracing headers here:

if (!accountId || !agentId) {
return null
}

You may also want to add the trustKey attribute and give it the same value as accountId if traces aren't showing up in the UI.

Let me know if that works or you run into other issues!

@wrumsby
Copy link
Author

wrumsby commented Jun 17, 2021

Hello @aubreymasten, yes it does seem I need to include the following to get distributed tracing to work:

NREUM.loader_config = {
  accountID: /* my account id */,
  trustKey: /* my account id */,
  agentID: /* my application id */
};

I'll close this issue as this now works for me, but it might be worth including more details about init, info and loader_config in the agent documentation.

@wrumsby wrumsby closed this as completed Jun 17, 2021
@rr0214 rr0214 added this to Triage Needed: Unprioritized Features in Browser Instrumentation Engineering Board Aug 17, 2021
@rr0214 rr0214 moved this from Triage Needed: Unprioritized Features to Done: Issues recently completed in Browser Instrumentation Engineering Board Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Browser Instrumentation Engineering B...
  
Done: Issues recently completed
Development

No branches or pull requests

3 participants