You've already forked FrameTour-RenderWorker
feat(tracing): 增强文件下载上传的日志记录和追踪功能
- 添加任务上下文信息到日志前缀,便于追踪具体任务 - 在跨度中增加文件源URL和上传URL的属性记录 - 将存储服务中的info级别日志调整为debug级别以减少冗余输出 - 添加文件访问地址的调试日志输出 - 优化根日志级别设置允许DEBUG日志流入处理器 - 修复重试失败后的错误日志格式问题
This commit is contained in:
@@ -23,7 +23,7 @@ from domain.result import TaskResult, ErrorCode
|
||||
from domain.config import WorkerConfig
|
||||
from services import storage
|
||||
from services.cache import MaterialCache
|
||||
from util.tracing import mark_span_error, start_span
|
||||
from util.tracing import get_current_task_context, mark_span_error, start_span
|
||||
from constant import (
|
||||
HW_ACCEL_NONE, HW_ACCEL_QSV, HW_ACCEL_CUDA,
|
||||
VIDEO_ENCODE_PARAMS, VIDEO_ENCODE_PARAMS_QSV, VIDEO_ENCODE_PARAMS_CUDA
|
||||
@@ -413,10 +413,15 @@ class BaseHandler(TaskHandler, ABC):
|
||||
if timeout is None:
|
||||
timeout = self.config.download_timeout
|
||||
|
||||
task_context = get_current_task_context()
|
||||
task_prefix = f"[task:{task_context.task_id}] " if task_context else ""
|
||||
logger.debug(f"{task_prefix}Downloading from: {url} -> {dest}")
|
||||
|
||||
with start_span(
|
||||
"render.task.file.download",
|
||||
kind=SpanKind.CLIENT,
|
||||
attributes={
|
||||
"render.file.source_url": url,
|
||||
"render.file.destination": dest,
|
||||
"render.file.use_cache": use_cache,
|
||||
},
|
||||
@@ -429,13 +434,14 @@ class BaseHandler(TaskHandler, ABC):
|
||||
|
||||
if result:
|
||||
file_size = os.path.getsize(dest) if os.path.exists(dest) else 0
|
||||
logger.debug(f"Downloaded: {url} -> {dest} ({file_size} bytes)")
|
||||
logger.debug(f"{task_prefix}Downloaded: {url} -> {dest} ({file_size} bytes)")
|
||||
if span is not None:
|
||||
span.set_attribute("render.file.size_bytes", file_size)
|
||||
return result
|
||||
except Exception as e:
|
||||
mark_span_error(span, str(e), ErrorCode.E_INPUT_UNAVAILABLE.value)
|
||||
logger.error(f"Download failed: {url} -> {e}")
|
||||
logger.error(f"{task_prefix}Download failed: {e}")
|
||||
logger.debug(f"{task_prefix}Download source address: {url}")
|
||||
return False
|
||||
|
||||
def upload_file(
|
||||
@@ -477,11 +483,22 @@ class BaseHandler(TaskHandler, ABC):
|
||||
logger.error(f"[task:{task_id}] Invalid upload URL response")
|
||||
return None
|
||||
|
||||
logger.debug(
|
||||
f"[task:{task_id}] Upload target address: uploadUrl={upload_url}, accessUrl={access_url}"
|
||||
)
|
||||
if span is not None:
|
||||
span.set_attribute("render.file.upload_url", upload_url)
|
||||
if access_url:
|
||||
span.set_attribute("render.file.access_url", access_url)
|
||||
|
||||
try:
|
||||
result = storage.upload_file(upload_url, file_path, timeout=self.config.upload_timeout)
|
||||
if result:
|
||||
file_size = os.path.getsize(file_path)
|
||||
logger.info(f"[task:{task_id}] Uploaded: {file_path} ({file_size} bytes)")
|
||||
logger.info(
|
||||
f"[task:{task_id}] Uploaded: {file_path} ({file_size} bytes)"
|
||||
)
|
||||
logger.debug(f"[task:{task_id}] Uploaded access address: {access_url or upload_url}")
|
||||
if span is not None:
|
||||
span.set_attribute("render.file.size_bytes", file_size)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user