Skip to content

Provide basic functionality like measuring time/success/failure count for function through @Metrics annotation #24

@vigneshtdev

Description

@vigneshtdev

Is your feature request related to a problem? Please describe.
I would like to know time taken & success/failure ration for a service call from lambda function.

Describe the solution you'd like
Currently Metrics annotation only supports capturing cold start, it would be really if we can get time/success/failure count for the method being executed(similar to DCM/DLM :)).

Describe alternatives you've considered

Currently we are using Guava's stopwatch & manually instrumenting the code.

Activity

pankajagrawal16

pankajagrawal16 commented on Jul 19, 2021

@pankajagrawal16

Hi @vigneshtdev Thanks for opening the issue. Since this belongs to core utility Metrics, I would like to hear thoughts from Python folks as well. Moving this to roadmap for further discussion.

@heitorlessa Thoughts on this? Adding built in support for Metrics annotation/decorator to capture success/failure/duration metrics conditionally like cold start

heitorlessa

heitorlessa commented on Jul 27, 2021

@heitorlessa
Contributor

I'd love to hear more on why the Lambda function default metrics themselves are not sufficient.

I've typically seen this request in cases where customers have a "fat" Lambda function, in which case you could create your own middleware to handle errors with Powertools that also create a metric as you see fit.

NOTE: Middleware "factory" utility isn't available in Java but Python, so you might need more boilerplate hence perhaps the ask.

Is that the case? If so, I'd like to hear more customer demand on this before we consider it.

vigneshtdev

vigneshtdev commented on Jul 27, 2021

@vigneshtdev
Author

One reason I can think of is with the default metrics provided by lambda it's difficult to distinguish between failures occurring in static block & failures in handleRequest

https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics.html

Errors – The number of invocations that result in a function error. Function errors include exceptions thrown by your code and exceptions thrown by the Lambda runtime. The runtime returns errors for issues such as timeouts and configuration errors.

Also in case these annotations can be used on non-handleRequest methods then we can analyse individual service calls easily

dreamorosi

dreamorosi commented on Jul 17, 2025

@dreamorosi
Contributor

We haven't received any significant traction on this item in the past 4 years, because of this we'll close it as not planned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @heitorlessa@dreamorosi@pankajagrawal16@vigneshtdev

        Issue actions

          Provide basic functionality like measuring time/success/failure count for function through @Metrics annotation · Issue #24 · aws-powertools/powertools-lambda