@@ -318,19 +318,23 @@ def _refresh_headers(self):
318318 }
319319
320320 def submit_transaction (self , txn : AnalyticsTxn ):
321- # TODO: We should make this fail safely, as to not interrupt the everyday
322- # business logic products do.
323- # However, given that we do not have appropriate logging infrastructure
324-
325- # Offer a 30 second buffer to refresh
326- if time .time () >= self .expires_at - 30 :
327- # TODO: According to @judtinzhang there is a subtle bug here with regards
328- # to tokens
329- _refresh_if_outdated ()
330- self ._refresh_expires_at ()
331- self ._refresh_headers ()
332-
333- self .executor .submit (self .send_message , txn .to_json ())
321+ try :
322+ # Offer a 30 second buffer to refresh
323+ # TODO: According to @judtinzhang, the reason we need this buffer is due to a
324+ # subtle bug on DLA with regards to tokens.
325+ if time .time () >= self .expires_at - 30 :
326+ _refresh_if_outdated ()
327+ self ._refresh_expires_at ()
328+ self ._refresh_headers ()
329+
330+ self .executor .submit (self .send_message , txn .to_json ())
331+ except Exception :
332+ # As to not interrupt everyday business logic products do when the analytics
333+ # server is down, we should not raise an exception.
334+
335+ # TODO: However, we should be logging this error so that we can investigate.
336+ # We should set up a logging infrastructure to do this.
337+ pass
334338
335339 def _send_message (self , json ):
336340 self .session .post (url = self .ANALYTICS_URL , json = json , headers = self .headers )
0 commit comments