Skip to content

Commit 472436b

Browse files
committed
fail silently + better comments
1 parent e112bec commit 472436b

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

analytics/analytics.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

analytics/entries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AnalyticsEntry(ABC):
2323
get_value_use_before: function to get the value to be recorded using the before context
2424
compute_before: function to compute some context before the view/function is called
2525
filter_do_record: function to determine if the entry should be recorded,
26-
defaults to record if exception is thrown
26+
defaults to not record if exception is thrown
2727
2828
* Only one type of value "getter" should be supplied.
2929
"""

0 commit comments

Comments
 (0)