2026-11-02 12:16:49 +08:00
|
|
|
"""Retired entry point of the previous trace pipeline.
|
2026-05-11 16:37:17 +08:00
|
|
|
|
2026-11-02 12:16:49 +08:00
|
|
|
Producers from before an upgrade may still enqueue this task. Its payload uses
|
|
|
|
|
the previous record format, so the message is dropped and its payload deleted;
|
|
|
|
|
only old workers can export it. Keep new workers off the old queue until it has
|
|
|
|
|
drained. The new pipeline's sweeper leaves legacy payloads alone.
|
2026-05-11 16:37:17 +08:00
|
|
|
"""
|
|
|
|
|
|
2024-06-28 00:24:37 +08:00
|
|
|
import logging
|
2026-11-02 12:16:49 +08:00
|
|
|
import re
|
2024-06-28 00:24:37 +08:00
|
|
|
|
2025-08-24 23:07:22 +08:00
|
|
|
from celery import shared_task
|
2024-06-28 00:24:37 +08:00
|
|
|
|
2024-11-08 14:43:47 +08:00
|
|
|
from extensions.ext_storage import storage
|
2024-06-28 00:24:37 +08:00
|
|
|
|
2025-08-26 18:10:31 +08:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
2026-11-02 12:16:49 +08:00
|
|
|
_PAYLOAD_SEGMENT = re.compile(r"[A-Za-z0-9-]+")
|
2024-06-28 00:24:37 +08:00
|
|
|
|
2026-05-11 16:37:17 +08:00
|
|
|
|
2026-11-02 12:16:49 +08:00
|
|
|
@shared_task(queue="ops_trace")
|
|
|
|
|
def process_trace_tasks(file_info: dict[str, object]) -> None:
|
|
|
|
|
app_id, file_id = file_info.get("app_id"), file_info.get("file_id")
|
|
|
|
|
if isinstance(app_id, str) and isinstance(file_id, str):
|
|
|
|
|
if _PAYLOAD_SEGMENT.fullmatch(app_id) and _PAYLOAD_SEGMENT.fullmatch(file_id):
|
2026-03-27 00:56:31 -07:00
|
|
|
try:
|
2026-11-02 12:16:49 +08:00
|
|
|
storage.delete(f"ops_trace/{app_id}/{file_id}.json")
|
2026-03-27 00:56:31 -07:00
|
|
|
except Exception:
|
2026-11-02 12:16:49 +08:00
|
|
|
logger.warning("Legacy trace payload cleanup failed: app_id=%s", app_id, exc_info=True)
|
|
|
|
|
logger.info("Dropped a trace task enqueued before the trace pipeline upgrade: app_id=%s", app_id)
|