55
66from werkzeug import Response as WerkzeugResponse
77
8- from localstack import config
98from localstack .aws .connect import connect_to
9+ from localstack .utils .bootstrap import is_api_enabled
1010from localstack .utils .strings import to_str
1111from localstack .utils .time import now_utc
1212
@@ -25,7 +25,7 @@ def dimension_lambda(kwargs):
2525
2626def publish_lambda_metric (metric , value , kwargs , region_name : Optional [str ] = None ):
2727 # publish metric only if CloudWatch service is available
28- if not config . service_port ("cloudwatch" ):
28+ if not is_api_enabled ("cloudwatch" ):
2929 return
3030 cw_client = connect_to (region_name = region_name ).cloudwatch
3131 try :
@@ -62,6 +62,8 @@ def publish_sqs_metric(
6262 :param value The value of the metric data, default: 1
6363 :param unit The unit of the metric data, default: "Count"
6464 """
65+ if not is_api_enabled ("cloudwatch" ):
66+ return
6567 cw_client = connect_to (region_name = region , aws_access_key_id = account_id ).cloudwatch
6668 try :
6769 cw_client .put_metric_data (
@@ -104,6 +106,8 @@ def store_cloudwatch_logs(
104106 start_time = None ,
105107 auto_create_group : Optional [bool ] = True ,
106108):
109+ if not is_api_enabled ("logs" ):
110+ return
107111 start_time = start_time or int (time .time () * 1000 )
108112 log_output = to_str (log_output )
109113
0 commit comments