-
Notifications
You must be signed in to change notification settings - Fork 421
'EphemeralMetrics' object has no attribute 'set_default_dimensions' #2676
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
hey @tibbe great to hear from you again - we intentionally did that . If you have an use case to persist dimensions across invocations within ephemeral metrics, happy to convert this to a feature request -- if you have the bandwidth to make a PR we can prioritize it for the next release :) ![]() |
Asked on Discord to bring more visibility: https://discord.com/channels/1006478942305263677/1006527338621710376/1127918302686097438 In hindsight, I'm starting to think this makes sense. We'd need to signal in the docs that I'll wait for a signal from you or another customer before proceeding. Thanks! |
Confirmed use case on Discord, will get this ready for the next release. from OP I have a Lambda that consumes a DynamoDB stream and receives a batch of items from DynamoDB in each invocation. I have three metrics that have a dimension that is the same across the batch (the "Stage" e.g. "prod" or "development") and a dimension that varies across the batch (the "ItemType" e.g. "user" or "chat"). The former dimension would be convenient to set as a default dimension. I could of course just set it directly after the invocation starts, which is what I did as a workaround. The dimension that varies across the batch is a bit trickier, as I can't re-set a dimension (all metrics would simply get the value of the last call to set_dimension). I ended up using a dict of EphemeralMetrics to handle this. At the end of the day I'm just trying to use Lambda metrics in the way that's most efficient. The ideal API is actually just to emit the dimensions with the metric (i.e. just as a SingleMetric or really just a call to a hypothetical emit_metric(*dimensions, name, unit)). What we're doing here is in my mind just a workaround for what the Lambda logging schema supports efficiently. |
|
This is now released under 2.20.0 version! |
Expected Behaviour
log_metrics()
withdefault_dimensions
should also work forEphemeralMetrics
.Current Behaviour
Since
EphemeralMetrics
has noset_default_dimensions
method it fails with the error in the issue title.Code snippet
Possible Solution
EphemeralMetrics
should have most of the methods thatMetrics
has (in particular those related to default dimensions), as these method are orthogonal to the non-singletoness ofEphemeralMetrics
.Steps to Reproduce
Run a Lambda with the code snippet above.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.10
Packaging format used
PyPi
Debugging logs
No response
The text was updated successfully, but these errors were encountered: