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

Importing module @datadog/browser-logs breaks on Google Cloud Platform #1764

Closed
r3c opened this issue Oct 10, 2022 · 5 comments
Closed

Importing module @datadog/browser-logs breaks on Google Cloud Platform #1764

r3c opened this issue Oct 10, 2022 · 5 comments

Comments

@r3c
Copy link

r3c commented Oct 10, 2022

Hi,

We're experiencing an issue related to @datadog/browser-logs crashing when running from a Google Cloud Platform environment due to the side-effects it performs when imported, namely the binding operations on console.{debug,log,info,warn,error} executed at top-level from module display.ts.

This file contains top-level code assuming it runs in a browser and calls Function.bind for all known logging methods of console object. Such approach works fine in most web browser but breaks on our application hosted on Google Cloud Platform because the implementation of console there doesn't have a console.debug function. I believe this regression was introduced with #1501 as only warn, log and error were previously used and they all exist in GCP.

Current behavior may be intentional and rely on the fact @datadog/browser-logs always runs within a standard web browser, which would be a fair assumption based on the package's name. However since the package description says it is intended to "send logs to Datadog from web browsers or other Javascript clients", you may also want to consider improving compatibility by checking the existence of console.debug (and other functions) before trying to bind them.

Please let me know what makes most sense to you 🙂

@amortemousque
Copy link
Contributor

Hi @r3c,

To clarify, when you're saying running from a Google Cloud Platform environment, are you talking about a Node.js backend environment?

@r3c
Copy link
Author

r3c commented Oct 10, 2022

Hello @amortemousque not sure about Node.js exactly but it's very likely a backend V8 execution platform. I couldn't find much details and will try to dig this through, yet I expect it to be fully compatible with a Node.js environment.

@amortemousque
Copy link
Contributor

Your current supposition is true. @datadog/browser-logs SDK is tailored for a browser environment. For other environment, Datadog provides other ways (example for node.js), which may be a better fit for your case.

@r3c
Copy link
Author

r3c commented Oct 11, 2022

OK then I think I was confused by the part in your README file that mentions "other Javascript clients". Using the same library for browers and Node.js allowed us easier factorization, but I understand this may not be aligned with the intended usage of this package so we'll split the codebase on our end. Thanks for your answer 🙂

(I would also recommand updating README.md to avoid any confusion 🙂)

@amortemousque
Copy link
Contributor

Thanks for your feedback, we will update the README.md 🙂

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

2 participants