Commit 8e8a56a
committed
fix(metrics): warnings when there are default_dimensions
This fixes and reorganizes the code in a few ways:
* Make it clearer that _metrics, _dimensions, _metadata and
_default_dimensions are class attributes. They don't need to be also
set as instance attributes when constructing Metrics, as they're only
meant to be used to construct the provider with shared data.
* Expose metric_set, dimension_set, metadata_set and default_dimensions
as attributes just to keep backwards compatibility. Don't expose setters
for these as previously setting them would have no side effect. Now
users will get an error, which is a small breaking change but arguably
for something they should never be doing anyway.
* Fix setting the default_dimensions in AmazonCloudWatchEMFProvider, as
`default_dimensions or {}` was setting a new dict instance when the
given default_dimensions was empty and we want to share the given dict.1 parent 8db13c7 commit 8e8a56a
3 files changed
Lines changed: 46 additions & 19 deletions
File tree
- aws_lambda_powertools/metrics
- provider/cloudwatch_emf
- tests/functional/metrics/required_dependencies
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | 94 | | |
102 | 95 | | |
103 | 96 | | |
104 | 97 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
109 | 102 | | |
110 | 103 | | |
111 | 104 | | |
| |||
174 | 167 | | |
175 | 168 | | |
176 | 169 | | |
177 | | - | |
178 | 170 | | |
179 | 171 | | |
180 | 172 | | |
| |||
195 | 187 | | |
196 | 188 | | |
197 | 189 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| 190 | + | |
202 | 191 | | |
203 | 192 | | |
204 | 193 | | |
205 | | - | |
206 | 194 | | |
207 | 195 | | |
208 | 196 | | |
| |||
227 | 215 | | |
228 | 216 | | |
229 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
230 | 234 | | |
231 | 235 | | |
232 | 236 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
| 456 | + | |
| 457 | + | |
457 | 458 | | |
458 | 459 | | |
459 | 460 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1221 | 1221 | | |
1222 | 1222 | | |
1223 | 1223 | | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
1224 | 1246 | | |
1225 | 1247 | | |
1226 | 1248 | | |
| |||
0 commit comments