notify-243 remove statsd

This commit is contained in:
Kenneth Kehl
2023-04-25 07:50:56 -07:00
parent 625f6e3f6b
commit 001954538e
19 changed files with 178 additions and 282 deletions

View File

@@ -14,7 +14,7 @@ class AwsSnsClient(SmsClient):
AwsSns sms client
"""
def init_app(self, current_app, statsd_client, *args, **kwargs):
def init_app(self, current_app, *args, **kwargs):
self._client = client(
"sns",
region_name=cloud_config.sns_region,
@@ -23,7 +23,6 @@ class AwsSnsClient(SmsClient):
)
super(SmsClient, self).__init__(*args, **kwargs)
self.current_app = current_app
self.statsd_client = statsd_client
self._valid_sender_regex = re.compile(r"^\+?\d{5,14}$")
@property
@@ -67,19 +66,14 @@ class AwsSnsClient(SmsClient):
start_time = monotonic()
response = self._client.publish(PhoneNumber=to, Message=content, MessageAttributes=attributes)
except botocore.exceptions.ClientError as e:
self.statsd_client.incr("clients.sns.error")
raise str(e)
except Exception as e:
self.statsd_client.incr("clients.sns.error")
raise str(e)
finally:
elapsed_time = monotonic() - start_time
self.current_app.logger.info("AWS SNS request finished in {}".format(elapsed_time))
self.statsd_client.timing("clients.sns.request-time", elapsed_time)
self.statsd_client.incr("clients.sns.success")
return response["MessageId"]
if not matched:
self.statsd_client.incr("clients.sns.error")
self.current_app.logger.error("No valid numbers found in {}".format(to))
raise ValueError("No valid numbers found for SMS delivery")