Closed
Description
Use case
Currently we cannot set the FunctionName in metrics as this value is added as dimension from the lambda context.
This can cause issues when the names are auto generated by infra tools or top level statements lambdas
Related to issue: aws-powertools/powertools-lambda-typescript#3642
Solution/User Experience
Support setting FunctionName
Decorator
[Metrics(Namespace = "ns", Service = "svc", CaptureColdStart = true, FunctionName= "MyFunctionName")]
public void HandleWithParamAndLambdaContext(string input, ILambdaContext context)
{
}
Configure
Metrics.Configure(options =>
{
options.FunctioName = "MyFunctionName";
options.Namespace = "dotnet-powertools-test";
options.Service = "testService";
options.CaptureColdStart = true;
options.DefaultDimensions = new Dictionary<string, string>
{
{ "Environment", "Prod" },
{ "Another", "One" }
};
});
Builder
_metrics = new MetricsBuilder()
.WithFunctionName("MyFunctionName")
.WithCaptureColdStart(true)
.WithService("testService")
.WithNamespace("dotnet-powertools-test")
.WithDefaultDimensions(new Dictionary<string, string>
{
{ "Environment", "Prod1" },
{ "Another", "One" }
}).Build();
Alternative solutions
Acknowledgment
- This feature request meets Powertools for AWS Lambda (.NET) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and TypeScript
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
✅ Done