Skip to content

Feature request: Metrics support setting functionName #784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
hjgraca opened this issue Feb 24, 2025 · 0 comments · Fixed by #785
Closed
2 tasks done

Feature request: Metrics support setting functionName #784

hjgraca opened this issue Feb 24, 2025 · 0 comments · Fixed by #785
Assignees
Labels
area/metrics Core metrics utility feature-request New or enhancements to existing features pending-release Fix or implementation already in dev waiting to be released v2 v2 release
Milestone

Comments

@hjgraca
Copy link
Contributor

hjgraca commented Feb 24, 2025

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

@hjgraca hjgraca added area/metrics Core metrics utility feature-request New or enhancements to existing features v2 v2 release labels Feb 24, 2025
@hjgraca hjgraca added this to the Metrics V2 milestone Feb 24, 2025
@hjgraca hjgraca self-assigned this Feb 24, 2025
@hjgraca hjgraca moved this to 🏗 In progress in Powertools for AWS Lambda (.NET) Feb 24, 2025
@hjgraca hjgraca linked a pull request Feb 25, 2025 that will close this issue
7 tasks
@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Feb 27, 2025
@hjgraca hjgraca moved this from 🏗 In progress to ✅ Done in Powertools for AWS Lambda (.NET) Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/metrics Core metrics utility feature-request New or enhancements to existing features pending-release Fix or implementation already in dev waiting to be released v2 v2 release
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant