cdklabs / cdk-monitoring-constructs

Easy-to-use CDK constructs for monitoring your AWS infrastructure
https://constructs.dev/packages/cdk-monitoring-constructs
Apache License 2.0
443 stars 56 forks source link

MetricFactory `toRate` does not pass ".with(properties)" to underlying metric #434

Open jackbnz-aws opened 9 months ago

jackbnz-aws commented 9 months ago

Version

5.0.0

Steps and/or minimal code example to reproduce

  1. Create a MetricFactory with a tps metric.
  2. use .with(properties); on the tps metric
  3. Observe that properties aren't included on the tps metric itself.

Relevant line of code: https://github.com/cdklabs/cdk-monitoring-constructs/blob/064d54fca62f7f62ed68ef40870db672cc7ee9f5/lib/monitoring/aws-apigateway/ApiGatewayMetricFactory.ts#L77

Expected behavior

I would expect that properties are passed to the underlying metric. This functionality works on metrics that do not use the "toRate" method as the metric is directly returned.

For example, .with(properties) works correctly on metric4XXErrorCount: https://github.com/cdklabs/cdk-monitoring-constructs/blob/064d54fca62f7f62ed68ef40870db672cc7ee9f5/lib/monitoring/aws-apigateway/ApiGatewayMetricFactory.ts#L98

Actual behavior

Properties are not passed to underlying TPS metric.

Other details

We are using this to show a widget for TPS, but need to specify the account. The account for the TPS metric we specify in the properties is not being used.