-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Labels
bugUnexpected, reproducible and unintended software behaviourUnexpected, reproducible and unintended software behaviourreleasedFix or implementation already in main and releasedFix or implementation already in main and releasedstatus/confirmedThe scope is clear, ready for implementationThe scope is clear, ready for implementation
Description
Expected Behaviour
The root level service
property of the logging output should be prioritized in this order:
LoggingAttribute.Service
property valuePOWERTOOLS_SERVICE_NAME
environment variable
Current Behaviour
The root level service
property of the logging output no longer prioritizes and uses the service name provided prior to the first log call.
Code snippet
// Each log entry is the value of the Root level service property when written to CloudWatch
// v1.5.1 behavior
Logger.LogInformation("Service: service_undefined");
Environment.SetEnvironmentVariable("POWERTOOLS_SERVICE_NAME", "Environment Service", EnvironmentVariableTarget.Process);
Logger.LogInformation("Service: Environment Service");
await LambdaBootstrapBuilder.Create((Func<string, ILambdaContext, Task<string>>)Handler, new DefaultLambdaJsonSerializer())
.Build()
.RunAsync();
[Logging(Service = "Attribute Service")]
async Task<string> Handler(string input, ILambdaContext context)
{
Logger.LogInformation("Service: Attribute Service");
return await Task.FromResult(input);
}
// v1.6.2 behavior - example 1
Logger.LogInformation("Service: service_undefined");
Environment.SetEnvironmentVariable("POWERTOOLS_SERVICE_NAME", "Environment Service", EnvironmentVariableTarget.Process);
Logger.LogInformation("Service: service_undefined");
await LambdaBootstrapBuilder.Create((Func<string, ILambdaContext, Task<string>>)Handler, new DefaultLambdaJsonSerializer())
.Build()
.RunAsync();
[Logging(Service = "Attribute Service")]
async Task<string> Handler(string input, ILambdaContext context)
{
Logger.LogInformation("Service: service_undefined");
return await Task.FromResult(input);
}
// v1.6.2 behavior - example 2
Environment.SetEnvironmentVariable("POWERTOOLS_SERVICE_NAME", "Environment Service", EnvironmentVariableTarget.Process);
Logger.LogInformation("Service: Environment Service");
await LambdaBootstrapBuilder.Create((Func<string, ILambdaContext, Task<string>>)Handler, new DefaultLambdaJsonSerializer())
.Build()
.RunAsync();
[Logging(Service = "Attribute Service")]
async Task<string> Handler(string input, ILambdaContext context)
{
Logger.LogInformation("Service: Environment Service");
return await Task.FromResult(input);
}
// v1.6.2 behavior - example 3
await LambdaBootstrapBuilder.Create((Func<string, ILambdaContext, Task<string>>)Handler, new DefaultLambdaJsonSerializer())
.Build()
.RunAsync();
[Logging(Service = "Attribute Service")]
async Task<string> Handler(string input, ILambdaContext context)
{
Logger.LogInformation("Service: Attribute Service");
return await Task.FromResult(input);
}
Possible Solution
Rollback to the v1.5.1 behavior.
Steps to Reproduce
Code snippet above provides all the steps to reproduce.
Powertools for AWS Lambda (.NET) version
1.6.2
AWS Lambda function runtime
dotnet8
Debugging logs
Metadata
Metadata
Assignees
Labels
bugUnexpected, reproducible and unintended software behaviourUnexpected, reproducible and unintended software behaviourreleasedFix or implementation already in main and releasedFix or implementation already in main and releasedstatus/confirmedThe scope is clear, ready for implementationThe scope is clear, ready for implementation
Type
Projects
Status
✅ Done