|
7 | 7 |
|
8 | 8 | from fastapi import FastAPI |
9 | 9 | from models_library.error_codes import create_error_code |
| 10 | +from servicelib.logging_errors import create_troubleshotting_log_kwargs |
10 | 11 |
|
11 | 12 | from .....core.dynamic_services_settings.scheduler import ( |
12 | 13 | DynamicServicesSchedulerSettings, |
@@ -144,17 +145,27 @@ async def observing_single_service( |
144 | 145 |
|
145 | 146 | # With unhandled errors, let's generate and ID and send it to the end-user |
146 | 147 | # so that we can trace the logs and debug the issue. |
| 148 | + front_end_msg = ( |
| 149 | + f"This service ({service_name}) unexpectedly failed." |
| 150 | + " Our team has recorded the issue and is working to resolve it as quickly as possible." |
| 151 | + " Thank you for your patience." |
| 152 | + ) |
147 | 153 |
|
148 | | - error_code = create_error_code(e) |
149 | 154 | logger.exception( |
150 | | - "Observation of %s unexpectedly failed [%s]", |
151 | | - f"{service_name=} ", |
152 | | - f"{error_code}", |
153 | | - extra={"error_code": error_code}, |
| 155 | + **create_troubleshotting_log_kwargs( |
| 156 | + front_end_msg, |
| 157 | + exception=e, |
| 158 | + error_context={ |
| 159 | + "service_name": service_name, |
| 160 | + "user_id": scheduler_data.user_id, |
| 161 | + }, |
| 162 | + tip=f"Observation of {service_name=} unexpectedly failed", |
| 163 | + ) |
154 | 164 | ) |
| 165 | + error_code = create_error_code(e) |
155 | 166 | scheduler_data.dynamic_sidecar.status.update_failing_status( |
156 | 167 | # This message must be human-friendly |
157 | | - f"Upss! This service ({service_name}) unexpectedly failed", |
| 168 | + front_end_msg, |
158 | 169 | error_code, |
159 | 170 | ) |
160 | 171 | finally: |
|
0 commit comments