-
Notifications
You must be signed in to change notification settings - Fork 421
refactor(metrics): optimize validation and serialization #307
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
refactor(metrics): optimize validation and serialization #307
Conversation
Posted on original issue Alright, here are the results with the lowest memory (128m) using the same 99 metrics -- @tgip-work @nmoutschen @michaelbrewer I'm pretty happy with it, and will not proceed with ujson as the underlying machine Lambda uses doesn't seem to make much use tbh - it could be different in other scenarios perhaps. I'll adjust the test SLA to take into account GitHub CI slower machines but I'd consider it solved... let me know otherwise @tgip-work :) BEFORE - Current public PowertoolsFastest Lambda execution according to X-Ray: 54ms All virtual users finished AFTER -- New Powertools with Lazy Loading and this PR optimizationFastest Lambda execution according to X-Ray: 2.2ms All virtual users finished AFTER - New optimizations + ujsonFastest Lambda execution according to X-Ray: 2.6ms All virtual users finished Details Load test with artillery using REST API + Lambda (could be even faster w/ HTTP API): Source code from aws_lambda_powertools import Metrics
# https://awslabs.github.io/aws-lambda-powertools-python/#features
metrics = Metrics(namespace="perftest", service="perftest")
@metrics.log_metrics
def lambda_handler(event, context):
for i in range(99):
metrics.add_metric(name=f"metric_{i}", value=1, unit="Count")
return {"statusCode": 200, "body": "hello world"} |
Codecov Report
@@ Coverage Diff @@
## develop #307 +/- ##
===========================================
- Coverage 99.78% 99.54% -0.25%
===========================================
Files 91 90 -1
Lines 3315 3291 -24
Branches 157 160 +3
===========================================
- Hits 3308 3276 -32
- Misses 5 10 +5
- Partials 2 5 +3
Continue to review full report at Codecov.
|
thanks @nmoutschen ;) 🎉 |
Issue #, if available: #303
Description of changes:
This change allows customers to disable metric validation to gain extra speed if they're confident they provided the bare minimum for metrics to be generated correctly in CloudWatch.
Checklist
validate_metrics
parameter in Metrics and Single MetricBreaking change checklist
RFC issue #:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.