Skip to content

Feature request: Metrics support setting functionName #784

Closed
@hjgraca

Description

@hjgraca

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

Metadata

Metadata

Assignees

Labels

area/metricsCore metrics utilityfeature-requestNew or enhancements to existing featurespending-releaseFix or implementation already in dev waiting to be releasedv2v2 release

Type

No type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions