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

Route console log to new relic logs #761

Open
murphpdx opened this issue Oct 5, 2023 · 10 comments
Open

Route console log to new relic logs #761

murphpdx opened this issue Oct 5, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@murphpdx
Copy link

murphpdx commented Oct 5, 2023

I'd like a setting in the new relic brower agent that will automatically hook into the console.log/console.error functions and send the logs to new relic logging. I would also like it to not log in the browser. Alternatively, an api call that will send logs to new relic. It does not have to hook into console but it would be nice if it did.

Summary

Forward logs to new relic via the browser agent.

Desired Behavior

Conditionally override the console.log, console.error, console.debug, console.info etc functions so that they send logs to new relic and do not log in the console.

Possible Solution

Additional context

@murphpdx murphpdx added the enhancement New feature or request label Oct 5, 2023
@workato-integration
Copy link

@patrickhousley
Copy link
Member

Hi @murphpdx and thanks for the feature request. This is actually on our roadmap for the quarter starting in January. We did do some work in a past version of the agent to gauge the data that would be sent if we automatically instrumented the console global. Unfortunately we found that extremely large objects are sometimes logged to the console in production systems resulting in a performance issue when we have to serialize it for sending to New Relic.

If you, or any community member or customer, has any suggestions around what you would like to see with this feature, please let us know either here, in our forums, or by reaching out to customer engagement or support.

Some things that we are trying to consider:

  • Do we need to implement log levels, what are they, and what do they map to on the console?
  • What limits can/should we put in place on what gets serialized for logging?
    • Object depth limit?
    • Only flat objects?
  • Do we need an API to allow customer code to inspect a log before it is serialized?
    • Log filtering
    • Custom serialization
  • How/Should we handle obfuscation of log data?

@workato-integration
Copy link

@sconzof
Copy link

sconzof commented Feb 13, 2024

Hi! Piggy-backing on the request from @murphpdx
This feature set would be very useful for some of our internal applications.

@CavalcanteLeo
Copy link

any news about this?

@patrickhousley
Copy link
Member

@CavalcanteLeo this work is on our roadmap to start this quarter.

@FranciscoKloganB
Copy link

FranciscoKloganB commented May 3, 2024

Just shimming in, this feature might be nice as an opt-in.

Some projects allow the use of console.debug (and friends) freely in the code for development reasons and remove them for production builds using vite/webpack/rollup directives.

@CavalcanteLeo
Copy link

CavalcanteLeo commented May 3, 2024

For me, instead of sending the console.log automatically, I would prefer something to manually send it to new relic, something like newrelic.log(text: string), and on the frontend I can abstract it, and create a function with the logger I want to use...

const useLog = (text: string): void => {
  newrelic.log(text) // here sends the log to new relic [newrelic.info(), newrelic.error()]
  console.log(text)  // Here I could use some other log, like Pino or Winston. And It will get rid in production as well
}

in this case, we don't rely on the console.logs only.

Most of the frameworks get rid of the console logs when building the prod (which is correct)

@caviyacht
Copy link

Optionally allowing each method in a config would be preferred. Our main focus is to get console.error captured as it would help track down a ton of problems.

The console.log could become a ton of noise and high data ingest, but toggling it on and off at will would be super beneficial.

@piyushchauhan2011
Copy link

Thank you for good work on logs

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

No branches or pull requests

7 participants