@@ -39,22 +39,24 @@ def send_environment_update_message(environment_key: str, updated_at):
39
39
response .raise_for_status ()
40
40
41
41
42
- @register_recurring_task (
43
- run_every = timedelta (seconds = 60 ),
44
- )
45
- def update_sse_usage ():
46
- with influxdb_client .write_api (
47
- write_options = WriteOptions (batch_size = 1000 , flush_interval = 2000 )
48
- ) as write_api :
49
- for log in sse_service .stream_access_logs ():
50
- environment = Environment .get_from_cache (log .api_key )
51
-
52
- if not environment :
53
- logger .warning ("Invalid api_key %s" , log .api_key )
54
- continue
55
-
56
- record = _get_influx_point (environment , log .generated_at )
57
- write_api .write (bucket = settings .SSE_INFLUXDB_BUCKET , record = record )
42
+ if settings .AWS_SSE_LOGS_BUCKET_NAME :
43
+
44
+ @register_recurring_task (
45
+ run_every = timedelta (seconds = 60 ),
46
+ )
47
+ def update_sse_usage ():
48
+ with influxdb_client .write_api (
49
+ write_options = WriteOptions (batch_size = 1000 , flush_interval = 2000 )
50
+ ) as write_api :
51
+ for log in sse_service .stream_access_logs ():
52
+ environment = Environment .get_from_cache (log .api_key )
53
+
54
+ if not environment :
55
+ logger .warning ("Invalid api_key %s" , log .api_key )
56
+ continue
57
+
58
+ record = _get_influx_point (environment , log .generated_at )
59
+ write_api .write (bucket = settings .SSE_INFLUXDB_BUCKET , record = record )
58
60
59
61
60
62
def _get_influx_point (environment : Environment , event_time : str ) -> Point :
0 commit comments