-
Notifications
You must be signed in to change notification settings - Fork 90
[Metrics] Improvements to Powertools Metrics #297
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
Comments
Thanks for this great feedback! |
Really great feedback @humanzz , If you are happy to contribute, we will be more than happy to take above suggestions. If not, I will spend some time next week incorporating some of those. |
There is a PR up for it now which will support the profile handler as well natively now.
This is already merged now by @msailes . So will be made available in next release.
This is actually a good idea and I personally thought about having such support in the 1st version itself but avoided until we see value in it. But now since we have feedback from community as well, there is a PR up for it already now. :)
I believe since we expose logger object as a Consumer function, clients of the API have access to it and thus can always set requestId or any other related property on for the emf logger.
Same for this one, I believe if you have a common consumer function which just sets the same property you need on all your metrics, we will be able to reuse the same consumer function on all the single metrics function. And for one on the annotation level, you will need to set that on the global logger instance. While this will be some additional code, I believe having too many high level abstraction within MetricsUtils is not very scalable and can soon start to being complex. But thats just me thinking out loud. I will be happy to hear thoughts from others as well. |
Thanks everyone. Really appreciate the prompt actions on addressing the feedback. @pankajagrawal16 I think the 2 most important things on my mind right now are
|
I agree with the thoughts. Default dimension part is something which I will have a look at next. This has been one of items that I have wanted to fix for a while already and now that we have community feedback as well around it, I sure will. |
I believe most of these suggestion are incorporated except for point 3 |
Awesome progress. Thanks a lot @msailes and @pankajagrawal16 I have a couple of comments to add
|
Makes sense, Since Logging already had those fields, it will make sense to just reuse the same names for metrics module. I will fix that before new release |
Yeah rite, thats the next thing which I plan to look at next. It might be a good idea to open a issue on EMF lib as well so that we can simplify powertools implementation once its natively available as well |
My personal taste would be for the new names used in metrics to be honest but it's not a big deal if we don't go with that option |
Yeah, But in order to avoid this being a break change for logging clients (in the sense if they have some filters like you mentioned), it makes sense to reuse the same for metrics lib. |
I agree - from a compatability point of view - but I still do think the new names are slightly better so I wonder if we can either/or
Regardless, unification is the thing we should go for. |
That's great, about the dimensions @pankajagrawal16 |
Not at this point. Since this is a core validation which is present in python version as well and if we allow it then we have to do it across. So best will be to open a separate RFC for it. |
Powertools Python folks here ;) -- EMF Spec originally had a dimension as a minimum otherwise metrics weren't created and failed silently --- That is not the case anymore. As of last Friday, we've released Lambda Powertools Python 1.11 removing the validation of a minimum one dimension. |
Thanks for confirming that Heitor, That means I will update it for java as well in the same PR. |
Happy times :-) |
All of the suggestions are available in 1.4.0 now |
Thanks a lot @msailes and @pankajagrawal16 Thanks a lot for addressing all of this. I actually have some follow up comments on
If you agree, I think a way forwards can be to implement What do you think? |
I believe I agree to allow multiple. By the way, you can just pass new DimensionSet() and that should set it with no dimensions |
Is your feature request related to a problem? Please describe.
The following requests are based on a recent experience I had using Powerttools Metrics having used https://github.com/awslabs/aws-embedded-metrics-java in different projects before and the workarounds we had to implement and hoping they should be taken care of by Powertools so we can move our older projects to Powertools and have a consistent experience among the different projects.
As such, I'll mention a few points below
Describe the solution you'd like
Improve documentation/warnings about the fact that powertools annotations require the Lambda handler method to be called
handlerRequest
handleRequest
and instead exposesrequestHandler
method that users should override to add their logicBaseHandler
that extendsRequestHandlerWithProfiling
, overridehandleRequest
callingsuper.handleRequest
and annotating it with the powertools annotations. Then implementing my concrete handlers as subclasses ofBaseHandler
Metrics emitted by
MetricsUtils.metricsLogger
should have a property for therequestId
requestId
. It has other useful things liketraceId
requestId
property by defaultMetrics emitted by
MetricsUtils.metricsLogger
should allow dimensions to be overriden or unset"Dimensions":[["LogGroup","ServiceName","ServiceType","Service"]]
.ServiceName
andService
; that's unnecessary, I believe one to be coming from the EMF Library and the other from PowertoolssetDimensions()
and giving it zero arguments if we don't need any of the default dimensions. Unfortunately this cannot be done for PowertoolsMetricsUtils.metricsLogger()
as it fails validation if dimensions count is equal to 0MetricsUtils.withSingleMetric
should have improved properties and namespace configswithSingleMetric
requires the setting of a namespace. In most cases, one would want to use the default namespace which is not easily accessible (beyond grabbing it explicitly from the environment variables). I believe there should be a version of this method which simply reuses the namespace configured forMetricsUtils.metricsLogger
withSingleMetric
should also add therequestId
propertyMetricsUtils
. It provides the same general capabilities - a default metricsLogger that gets flushed at the end of a request + one off metrics. The one thing we have on top of that is that we're able to set some default properties that will be written to both types of metrics e.g.defaultProperties
that we can append to at any time. It adds to theMetricsUtils.metricsLogger
, but gets applied to the equivalent ofwithSingleMetrics
when they're instantiated. This allows us to have a consistent set of properties common across all our EMF metrics.Additional context
It's likely that each of topics above should be addressed in a different issue and I'm happy to break it down further if you think that's useful.
I'm also happy to attempt to contribute after discussions if needed.
The text was updated successfully, but these errors were encountered: