mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
notify-243 remove statsd
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user