33import logging
44
55import aiohttp
6+ from waterbutler .core .utils import async_retry
67
78from mfr .server import settings
89from mfr .version import __version__
9- from waterbutler .core .utils import async_retry
10-
1110
1211logger = logging .getLogger (__name__ )
1312
@@ -75,9 +74,7 @@ async def log_analytics(request, metrics, is_error=False):
7574
7675 # send the private payload
7776 private_collection = "mfr_errors" if is_error else "mfr_action"
78- if (
79- is_error and settings .KEEN_PRIVATE_LOG_ERRORS
80- ) or settings .KEEN_PRIVATE_LOG_VIEWS :
77+ if (is_error and settings .KEEN_PRIVATE_LOG_ERRORS ) or settings .KEEN_PRIVATE_LOG_VIEWS :
8178 await _send_to_keen (
8279 keen_payload ,
8380 private_collection ,
@@ -108,9 +105,7 @@ async def log_analytics(request, metrics, is_error=False):
108105
109106
110107@async_retry (retries = 5 , backoff = 5 )
111- async def _send_to_keen (
112- payload , collection , project_id , write_key , action , domain = "private"
113- ):
108+ async def _send_to_keen (payload , collection , project_id , write_key , action , domain = "private" ):
114109 """Serialize and send an event to Keen. If an error occurs, try up to five more times.
115110 Will raise an excpetion if the event cannot be sent."""
116111
@@ -126,9 +121,7 @@ async def _send_to_keen(
126121
127122 async with aiohttp .request ("POST" , url , headers = headers , data = serialized ) as resp :
128123 if resp .status == 201 :
129- logger .info (
130- f"Successfully logged { action } to { collection } collection in { domain } Keen"
131- )
124+ logger .info (f"Successfully logged { action } to { collection } collection in { domain } Keen" )
132125 else :
133126 raise Exception (
134127 "Failed to log {} to {} collection in {} Keen. Status: {} Error: {}" .format (
0 commit comments