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

Datadog Trace Headers Not Added for Angular HttpClient Requests #2712

Open
playtowork opened this issue Apr 17, 2024 · 2 comments
Open

Datadog Trace Headers Not Added for Angular HttpClient Requests #2712

playtowork opened this issue Apr 17, 2024 · 2 comments

Comments

@playtowork
Copy link

playtowork commented Apr 17, 2024

What's Working:
I have a web application. It has an Angular (version 14) client-side and Play framework server-side. I have followed the directions in Datadog's documentation for connecting RUM and traces. The end-to-end trace is working (with the relevant X-Datadog-* headers being sent) for the requests made via the fetch function (located in node_modules/typescript/lib/lib.dom.d.ts).

What's Not Working:

But the majority of the requests the Angular app makes to my server are via the HttpClient in node_modules/@angular/common/http/index.d.ts. None of those requests are being traced end-to-end because the relevant X-Datadog-* headers are not being injected in them. I also have some HttpInterceptors, so I thought perhaps one of them might be stripping out these headers. But the X-Datadog-* headers never seem to have been injected at all (they're never present even at the beginning of any interceptor's intercept function). This is despite the server's responses' Access-Control-Allow-Headers headers always including the headers "X-Datadog-Trace-Id", etc.

Attempted Solutions:

I'm guessing perhaps the Datadog RUM SDK's header-injection logic and Angular HttpClient's dealing with requests' headers are conflicting somehow. But I don't know how to fix it. I've tried with @datadog/browser-rum versions 5.13.0 and 5.15.0. I've also tried doing datadogRum.init() as the first thing in main.ts as well as in the ngOnInit() function of app.component.ts.

@amortemousque
Copy link
Contributor

Hello @playtowork,
Thank you for your feedback. I wasn't able to reproduce the issue locally; I can see the header when using HttpClient.
Can you confirm that the allowedTracingUrls is well configured? If yes, could you provide a minimal reproducible example?

You can also contact our support to provide more details. They will be able to assist you in identifying the problem.

@danielpoonwj
Copy link

do you happen to be using pace.js in your frontend app? i encountered this issue too, turns out there's a bug that overrides XMLHttpRequest.prototype to an empty object. The Datadog browser SDK adds the headers by wrapping the prototype's methods. Removing this dependency worked for me
CodeByZach/pace#261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants