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

Adding support for log levels of WARN and ERROR #84

Open
FredLandis-Inmar opened this issue Sep 30, 2021 · 3 comments
Open

Adding support for log levels of WARN and ERROR #84

FredLandis-Inmar opened this issue Sep 30, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@FredLandis-Inmar
Copy link

FredLandis-Inmar commented Sep 30, 2021

Summary

In projects which use many lambdas that are invoked often, the logs written out by this layer that could be thought of as being of the "INFO" severity can really start to add up. The layer does use a NEW_RELIC_EXTENSION_LOG_LEVEL environment variable, but currently it only supports values of "INFO" and "DEBUG". I think it would be nice to have the options of "WARN" and "ERROR" as well so as to optionally omit the logs that are written over the course of normal, successful layer behavior.

Desired Behavior

I'm not sure that I've exhaustively identified each log that belongs to the INFO and WARN severities respectively, but I think the ones I have specifically linked should give a good idea of what I mean.

If the NEW_RELIC_EXTENSION_LOG_LEVEL environment variable is supplied with a value of either "WARN" or "ERROR", then many of the logs currently written over the course of normal, successful layer behavior ("INFO" logs) should not be written.

Such logs include

If the NEW_RELIC_EXTENSION_LOG_LEVEL environment variable is supplied with a value of "ERROR", then the following logs which represent information that is potentially problematic but not necessarily indicative of any failures ("WARN" logs) should not be written

Such logs include

And in both of the above cases, the existing DEBUG logs should not be written either.

Possible Solution

New Warnf, Warnln, Errorf, and Errorln functions could be added to /util/logger.go, similar to how there are currently Debugf, Debugln, Logf, and Logln functions.

The Logf and Logln functions could be renamed to Infof and Infoln.

Logs that report conceptual warnings would no longer be written via Logf and Logln and would instead be written via Warnf and Warnln.

Logs that report failures would no longer be written via Logf and Logln and would instead be written via Errorf and Errorln.

If the NEW_RELIC_EXTENSION_LOG_LEVEL environment variable were to be given a value of "ERROR", of all the aforementioned log functions, only Errorf and Errorln would actually write any logs if invoked.

If the NEW_RELIC_EXTENSION_LOG_LEVEL environment variable were to be given a value of "WARN", of all the aforementioned log functions, only Warnf, Warnln, Errorf, and Errorln would actually write any logs if invoked.

If the NEW_RELIC_EXTENSION_LOG_LEVEL environment variable were to be given a value of "INFO", of all the aforementioned log functions, only Infof, Infoln, Warnf, Warnln, Errorf, and Errorln would actually write any logs if invoked.

If the NEW_RELIC_EXTENSION_LOG_LEVEL environment variable were to be given a value of "DEBUG", then all of the aforementioned log functions would write logs if invoked.

Additional context

I'm willing to create a PR to add this functionality myself if you agree that it would be good to have.

@FredLandis-Inmar FredLandis-Inmar added the enhancement New feature or request label Sep 30, 2021
@FredLandis-Inmar FredLandis-Inmar changed the title Adding support for a log levels of WARN and ERROR Adding support for log levels of WARN and ERROR Oct 1, 2021
@alessandrobologna
Copy link

Any news on this?

@rittneje
Copy link

@iamemilio We are looking to switch from the log-group-subscription approach to this extension layer. However, the current implementation means that we would see an increase in CloudWatch costs due to the extension emitting these unnecessary log messages. Thus we have no choice but to disable the extension's logs entirely. Is there any plan to fix this?

@chaudharysaket chaudharysaket self-assigned this Dec 9, 2024
@workato-integration
Copy link

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

4 participants