Skip to content

Commit

Permalink
Merge pull request #190 from salute-developers/shevchenko/PNLP-8875_r…
Browse files Browse the repository at this point in the history
…m_client_info_from_logs

PNLP-8875: remove user.raw and message raw value from logs
  • Loading branch information
SyrexMinus authored Apr 2, 2024
2 parents 9b86006 + 313b442 commit a53cfca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
1 change: 1 addition & 0 deletions core/db_adapter/ceph/ceph_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

ssl._create_default_https_context = ssl._create_unverified_context


class CephAdapter(DBAdapter):
def __init__(self, config):
self._bucket = None
Expand Down
10 changes: 4 additions & 6 deletions smart_kit/start_points/base_main_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,12 @@ def _init_monitoring_config(self, template_settings):
monitoring.init_metrics(app_name=self.app_name)

async def load_user(self, db_uid, message: SmartAppFromMessage):
db_data = None
load_error = False
try:
db_data = await self.db_adapter.get(db_uid)
except (DBAdapterException, ValueError):
log("Failed to get user data", params={log_const.KEY_NAME: log_const.FAILED_DB_INTERACTION,
log_const.REQUEST_VALUE: message.as_str}, level="ERROR")
load_error = True
log("Failed to get user data", params={log_const.KEY_NAME: log_const.FAILED_DB_INTERACTION},
level="ERROR")
monitoring.counter_load_error(self.app_name)
# to skip message when load failed
raise
Expand Down Expand Up @@ -134,8 +132,8 @@ async def save_user(self, db_uid, user, message: SmartAppFromMessage):
else:
await self.db_adapter.save(db_uid, str_data)
except (DBAdapterException, ValueError):
log("Failed to set user data", params={log_const.KEY_NAME: log_const.FAILED_DB_INTERACTION,
log_const.REQUEST_VALUE: message.as_str}, level="ERROR")
log("Failed to set user data", params={log_const.KEY_NAME: log_const.FAILED_DB_INTERACTION},
level="ERROR")
monitoring.counter_save_error(self.app_name)
if not no_collisions:
monitoring.counter_save_collision(self.app_name)
Expand Down
11 changes: 3 additions & 8 deletions smart_kit/start_points/main_loop_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ async def process_consumer(self, kafka_key):
stats.dump_stats(filename=self.profile_cpu_path)

async def queue_worker(self, worker_id, queue):
message_value = None
last_poll_begin_time = self.loop.time()
last_mem_log = self.loop.time()
log(f"-- Starting {worker_id} iter", params={log_const.KEY_NAME: "starting"})
Expand Down Expand Up @@ -247,16 +246,14 @@ async def queue_worker(self, worker_id, queue):
except KafkaException as kafka_exp:
log("kafka error: %(kafka_exp)s.",
params={log_const.KEY_NAME: log_const.STARTUP_VALUE,
"kafka_exp": str(kafka_exp),
log_const.REQUEST_VALUE: str(message_value)},
"kafka_exp": str(kafka_exp)},
level="ERROR", exc_info=True)

except Exception:
monitoring.pod_event(self.app_name, WORKER_EXCEPTION)
log("%(class_name)s worker error. Kafka key %(kafka_key)s",
params={log_const.KEY_NAME: "worker_exception",
"kafka_key": kafka_key,
log_const.REQUEST_VALUE: str(message_value)},
"kafka_key": kafka_key},
level="ERROR", exc_info=True)
try:
consumer = self.consumers[kafka_key]
Expand Down Expand Up @@ -389,7 +386,6 @@ def _is_message_timeout_to_skip(self, message: SmartAppFromMessage, waiting_mess
log_const.KEY_NAME: "waiting_message_timeout",
"waiting_message_time": waiting_message_time,
"mid": message.incremental_id,
log_const.REQUEST_VALUE: message.as_str,
},
level=log_level)
return make_break
Expand Down Expand Up @@ -717,8 +713,7 @@ async def do_behavior_timeout(self, kwargs, worker_kwargs):
monitoring.counter_save_collision_tries_left(self.app_name)
except Exception:
log("%(class_name)s error.", params={log_const.KEY_NAME: "error_handling_timeout",
"class_name": self.__class__.__name__,
log_const.REQUEST_VALUE: str(mq_message.value())},
"class_name": self.__class__.__name__, },
level="ERROR", exc_info=True)
finally:
self.concurrent_messages -= 1
Expand Down

0 comments on commit a53cfca

Please sign in to comment.