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

Inconsistent behaviour regarding forwardErrorsToLogs and forwardConsoleLogs #3356

Open
OliverJAsh opened this issue Feb 20, 2025 · 3 comments
Labels
bug Something isn't working major version

Comments

@OliverJAsh
Copy link

When forwardErrorsToLogs is explicitly enabled, Datadog adds error to forwardConsoleLogs:

if (initConfiguration.forwardErrorsToLogs && !forwardConsoleLogs.includes(ConsoleApiName.error)) {
forwardConsoleLogs.push(ConsoleApiName.error)
}

However, if forwardErrorsToLogs is omitted from the initial configuration, this does not happen, despite the fact that forwardErrorsToLogs defaults to true.

Datadog should behave the same when forwardErrorsToLogs: true and when forwardErrorsToLogs is omitted.

@OliverJAsh OliverJAsh added the bug Something isn't working label Feb 20, 2025
@OliverJAsh
Copy link
Author

OliverJAsh commented Feb 20, 2025

On a related note, I find it strange that you can't opt out from console.error collection when forwardErrorsToLogs is specified, even when specifying forwardConsoleLogs: [].

(When specifying forwardErrorsToLogs: true, forwardConsoleLogs: [], Datadog will resolve the configuration as forwardConsoleLogs: ['error'].)

@BenoitZugmeyer
Copy link
Member

BenoitZugmeyer commented Feb 20, 2025

Ooh thank you for pointing that out, we'll fix this.

On a related note, I find it strange that you can't opt out from console.error collection when forwardErrorsToLogs is specified, even when specifying forwardConsoleLogs: [].

I agree that it can be a bit confusing. To understand why it works like this: at first we had forwardErrorsToLogs but not forwardConsoleLogs. At this time, when setting forwardErrorsToLogs: true, we considered console.error to be errors, and forwarded it as such. When we introduced forwardConsoleLogs, we didn't want to change the forwardErrorsToLogs behavior, this is why we enforce forwarding error logs in this case. I hope it makes sense.

Thank you for the feedback, we might consider clarifying things in a future major version.

@BenoitZugmeyer
Copy link
Member

It seems to be a breaking change: users using the default configuration would start collecting console.error without opting in. I added this to the list to do for our next major.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working major version
Projects
None yet
Development

No branches or pull requests

2 participants