You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
util.Logf("Log server terminating: %v\n", server.Serve(listener))
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
util.Logln("Warning: handler not set to New Relic layer wrapper", r.wrapperName)
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.
The text was updated successfully, but these errors were encountered:
@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?
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
newrelic-lambda-extension/main.go
Line 145 in d49852d
newrelic-lambda-extension/main.go
Line 43 in d49852d
newrelic-lambda-extension/telemetry/client.go
Line 104 in d49852d
newrelic-lambda-extension/credentials/credentials.go
Line 37 in 8aba524
newrelic-lambda-extension/main.go
Line 76 in d49852d
newrelic-lambda-extension/credentials/credentials.go
Line 76 in 8aba524
newrelic-lambda-extension/lambda/logserver/logserver.go
Lines 195 to 196 in 81c21a7
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 writtenSuch logs include
newrelic-lambda-extension/checks/startup_check.go
Line 31 in 8aba524
newrelic-lambda-extension/checks/startup_check.go
Line 43 in 8aba524
newrelic-lambda-extension/checks/handler_check.go
Line 44 in 8aba524
And in both of the above cases, the existing DEBUG logs should not be written either.
Possible Solution
New
Warnf
,Warnln
,Errorf
, andErrorln
functions could be added to/util/logger.go
, similar to how there are currentlyDebugf
,Debugln
,Logf
, andLogln
functions.The
Logf
andLogln
functions could be renamed toInfof
andInfoln
.Logs that report conceptual warnings would no longer be written via
Logf
andLogln
and would instead be written viaWarnf
andWarnln
.Logs that report failures would no longer be written via
Logf
andLogln
and would instead be written viaErrorf
andErrorln
.If the
NEW_RELIC_EXTENSION_LOG_LEVEL
environment variable were to be given a value of "ERROR", of all the aforementioned log functions, onlyErrorf
andErrorln
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, onlyWarnf
,Warnln
,Errorf
, andErrorln
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, onlyInfof
,Infoln
,Warnf
,Warnln
,Errorf
, andErrorln
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.
The text was updated successfully, but these errors were encountered: