-
Notifications
You must be signed in to change notification settings - Fork 7
PostgreSQLHandler logs wrong server_type/server_id for multi-service machines #643
Description
Problem
PostgreSQLHandler.emit() derives server_type and server_id at log-time from the OS environment:
# log_manager.py:348-349
"server_type": config.get_server_name_from_env(), # USERPROFILE → "presentation" / "acquisition" / "control"
"server_id": platform.uname().node, # hostname → "stm" / "acq" / "ctr"This breaks when a machine runs more than one service. The new ACQ service on the STM machine logs as presentation|stm — identical to the presentation service — making it impossible to distinguish which service produced a log_application row.
The correct identity is already known at startup:
server_acq.py:37—enable_crash_handler(f"ACQ_{acq_index}")server_acq.py:41—config.load_config_by_service_name("ACQ", acq_index=acq_index)server_stm.py:40—enable_crash_handler("STM")gui.py:647—enable_crash_handler("CTR")
But PostgreSQLHandler never receives this information.
Impact
Cannot analyze mbient connect/reset timing by service when RF/LF are managed by the new acquisition service on the STM machine. All five mbients appear to come from only two server identities (acquisition|acq and presentation|stm) even though there are now three services.
Proposed fix
Store the service identity in a module-level variable in log_manager.py (like SESSION_ID and SUBJECT_ID), set it once at startup, and use it in emit():
- Add a module-level
SERVICE_NAME: str = ""tolog_manager.py. - Have
make_db_logger()accept an optionalservice_nameparameter and store it inSERVICE_NAME. - In
PostgreSQLHandler.emit(), replace:with:"server_type": config.get_server_name_from_env(), "server_id": platform.uname().node,
"server_type": _role_from_service_name(SERVICE_NAME), # "acquisition", "presentation", "control" "server_id": SERVICE_NAME, # "ACQ_0", "ACQ_1", "STM", "CTR"
- Update the three entry points to pass the service name through:
server_acq.py→make_db_logger(service_name=f"ACQ_{acq_index}")server_stm.py→make_db_logger(service_name="STM")gui.py→make_db_logger(service_name="CTR")
This keeps server_type as a coarse role for filtering and makes server_id the specific service instance. No schema changes needed — just different values written to the existing columns.
Files
neurobooth_os/log_manager.py—PostgreSQLHandler.emit()(line 348-349),make_db_logger()(line 115)neurobooth_os/server_acq.py—main()(line 42)neurobooth_os/server_stm.py—main()(line 45)neurobooth_os/gui.py—setup_log()/main()(line 652)