-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Labels
area/loggingCore logging utilityCore logging utilitybugUnexpected, reproducible and unintended software behaviourUnexpected, reproducible and unintended software behaviour
Description
Expected Behaviour
Think there is a bug when using log sampling. When I set POWERTOOLS_LOGGER_SAMPLE_RATE environment to 0.9 I would expect in 90 percent of the cases to have all logs elevated to debug level and thus logged even though minimum log level is set to Error using POWERTOOLS_LOG_LEVEL variable.
Current Behaviour
Logs are never elevated to debug. It only happens when I set POWERTOOLS_LOGGER_SAMPLE_RATE to 1.
Code snippet
I am using the logger using the static log configuration in a console application and I set POWERTOOLS_LOG_LEVEL to Error and POWERTOOLS_LOGGER_SAMPLE_RATE to 0.9 using environment variables
[Logging(Service = "HelloWorldService", LoggerOutputCase = LoggerOutputCase.CamelCase, LogEvent = true)]
static void Main(string[] args)
{
var logLevel = Environment.GetEnvironmentVariable("POWERTOOLS_LOG_LEVEL");
Console.WriteLine($"POWERTOOLS_LOG_LEVEL: {logLevel}");
var sampleRate = Environment.GetEnvironmentVariable("POWERTOOLS_LOGGER_SAMPLE_RATE");
Console.WriteLine($"POWERTOOLS_SAMPLE_RATE: {sampleRate}");
// This should NOT be logged (Info < Error)
Logger.LogInformation("This is an info message — should not appear");
}
Possible Solution
No response
Steps to Reproduce
Just create a console app using the same configuration and environment variables. Information is only loggen when sample rate is set to 1
Powertools for AWS Lambda (.NET) version
2.0.0
AWS Lambda function runtime
dotnet8
Debugging logs
Metadata
Metadata
Labels
area/loggingCore logging utilityCore logging utilitybugUnexpected, reproducible and unintended software behaviourUnexpected, reproducible and unintended software behaviour
Type
Projects
Status
✅ Done