Use case
As a user of Powertools v1, and considering moving to v2, I found the withMetricsLogger now replaced with flushSingleMetric. I see 2 issues
- The current overloads, requires setting
namespace, even though previously I've been relying on the namespace being whatever was already set (e.g. via powertools environment variables). I find this a degradation in UX if - which I think is a typical use case - I wanna use the same namespace
- I also had use cases for
withMetricsLogger where I add multiple metrics, which share an overriden dimensionset. Now this needs to be replaced with multiple calls to flushSingleMetric
I think the refactor/abstractions led to some degradations when it comes to withMetricsLogger. Moreover, LambdaMetricsAspect do set a few other properties/metadata that no longer seem to be available in instances emitted by flushSingleMetric such as trace and function id.
Solution/User Experience
For 1, one solution would be to add flushSingleMetric overloads that don't take a namespace, and to update EmfMetricsLogger to treat the namespace parameter as nullable and a potential override to its this.namespace
For 2, maybe Metrics should get a new method flushMetrics with takes a Consumer<Metrics>, then one is more free about using default dimensions/namespace, or overriding them and adding multiple metrics.
Alternative solutions
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Use case
As a user of Powertools v1, and considering moving to v2, I found the
withMetricsLoggernow replaced withflushSingleMetric. I see 2 issuesnamespace, even though previously I've been relying on the namespace being whatever was already set (e.g. via powertools environment variables). I find this a degradation in UX if - which I think is a typical use case - I wanna use the same namespacewithMetricsLoggerwhere I add multiple metrics, which share an overriden dimensionset. Now this needs to be replaced with multiple calls toflushSingleMetricI think the refactor/abstractions led to some degradations when it comes to
withMetricsLogger. Moreover,LambdaMetricsAspectdo set a few other properties/metadata that no longer seem to be available in instances emitted byflushSingleMetricsuch as trace and function id.Solution/User Experience
For 1, one solution would be to add
flushSingleMetricoverloads that don't take anamespace, and to updateEmfMetricsLoggerto treat thenamespaceparameter as nullable and a potential override to itsthis.namespaceFor 2, maybe
Metricsshould get a new methodflushMetricswith takes aConsumer<Metrics>, then one is more free about using default dimensions/namespace, or overriding them and adding multiple metrics.Alternative solutions
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.