powertools-lambda-dotnet
powertools-lambda-dotnet copied to clipboard
Feature request: Add support for default dimensions on ColdStart metric
Use case
Related to https://github.com/aws-powertools/powertools-lambda-python/issues/5237
Add anew DefaultDimensions property to Metrics decorator to allow it to set Default Dimentsions on coldstart.
This new property will set global default dimensions not just for the cold start
The existing SetDefaultDimensions Metrics static method will still work. If same key added it will replace that key on Metrics called after the method was called
Solution/User Experience
using AWS.Lambda.Powertools.Metrics;
public class Function {
private Dictionary<string, string> _defaultDimensions = new Dictionary<string, string>{
{"Environment", "Prod"},
{"Another", "One"}
};
[Metrics(Namespace = "ExampleApplication", Service = "Booking", DefaultDimensions = _defaultDimensions)]
public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
{
// SetDefaultDimensions still available and will override existing properties in later calls to Metrics
Metrics.SetDefaultDimensions(_defaultDimensions);
Metrics.AddMetric("SuccessfulBooking", 1, MetricUnit.Count);
}
}
Alternative solutions
No response
Acknowledgment
- [X] This feature request meets Powertools for AWS Lambda (.NET) Tenets
- [X] Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and TypeScript