Calls to mutually exclusive methods were found in the code. This could indicate a bug or a deeper problem.
1def get_metrics_noncompliant() -> None:
2 import boto3
3 client = boto3.client('cloudwatch', region_name='eu-west-1')
4 datapoints = client.get_metric_statistics(
5 Namespace='CloudWatchSdkTest',
6 MetricName='PythonBotoTestMetric',
7 Dimensions=[
8 {
9 'Name': 'DimensionName',
10 'Value': 'DimensionValue'
11 },
12 ],
13 EndTime=datetime.datetime.now(datetime.timezone.utc),
14 StartTime=EndTime - datetime.timedelta(days=1),
15 Period=300,
16 # Noncompliant: calls mutually exclusive methods.
17 Statistics=[
18 'SampleCount', 'Average', 'Sum', 'Minimum', 'Maximum'
19 ],
20 ExtendedStatistics=[
21 'p70'
22 ]
23 )
1def get_metrics_compliant() -> None:
2 import boto3
3 client = boto3.client('cloudwatch', region_name='eu-west-1')
4 datapoints = client.get_metric_statistics(
5 Namespace='CloudWatchSdkTest',
6 MetricName='PythonBotoTestMetric',
7 Dimensions=[
8 {
9 'Name': 'DimensionName',
10 'Value': 'DimensionValue'
11 },
12 ],
13 EndTime=datetime.datetime.now(datetime.timezone.utc),
14 StartTime=EndTime - datetime.timedelta(days=1),
15 Period=300,
16 # Compliant: avoid calling mutually exclusive methods.
17 ExtendedStatistics=[
18 'p99',
19 'p100'
20 ]
21 )