接入 OTel 链路追踪 + 镜像默认启用
抓取-解析链路原本只有日志,出现"抓回内容但解析不出预期字段"时定位慢。 接入 OpenTelemetry traces(FastAPI/httpx 自动 + 手写 fetch/parse span), 解析失败时把页面 HTML 作为 span event 上报,便于事后复现。 Dockerfile 默认开启,镜像一启动即导出到自建 OTLP endpoint。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+11
-1
@@ -7,6 +7,11 @@
|
||||
# 镜像默认包含 Playwright 浏览器兜底(与 .env.example 的
|
||||
# RAKUTEN_BROWSER_FALLBACK_ENABLED=true 对齐),首次构建多约 400MB。
|
||||
# 若要裁剪,可改为 uv sync --no-dev(去掉 --extra browser)。
|
||||
#
|
||||
# 镜像默认开启 OpenTelemetry traces:RAKUTEN_OTEL_ENABLED=true +
|
||||
# RAKUTEN_OTEL_ENDPOINT=https://oltp.jerryyan.top/v1/traces 写入 ENV。
|
||||
# 容器一启动就把抓取-解析链路导出到自建 OTLP 后端,便于排查"抓回的内容
|
||||
# 为什么解析不出预期字段"。endpoint 裸跑(无鉴权);需要时运行时覆盖。
|
||||
|
||||
# ----------------------------- builder -----------------------------
|
||||
FROM registry.jerryyan.top/library/python:3.13-slim AS builder
|
||||
@@ -46,7 +51,12 @@ ENV PYTHONUNBUFFERED=1 \
|
||||
# Playwright 浏览器二进制走 npmmirror 镜像,避免从 azureedge 拉取缓慢
|
||||
PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright \
|
||||
RAKUTEN_APP_HOST=0.0.0.0 \
|
||||
RAKUTEN_APP_PORT=31107
|
||||
RAKUTEN_APP_PORT=31107 \
|
||||
# OpenTelemetry traces 默认开启:镜像一启动就把抓取-解析链路导出到自建 OTLP endpoint。
|
||||
# endpoint 裸跑(无鉴权);如部署到需要鉴权的网关,运行时覆盖 RAKUTEN_OTEL_HEADERS 即可。
|
||||
# 服务名(rakuten-scraping / rakuten-trading)由两侧 main.py 显式设定,此处不覆盖。
|
||||
RAKUTEN_OTEL_ENABLED=true \
|
||||
RAKUTEN_OTEL_ENDPOINT=https://oltp.jerryyan.top/v1/traces
|
||||
|
||||
# Chromium 运行所需的最小系统依赖。
|
||||
# 这里显式列出而不是用 `playwright install-deps`,是因为后者要求 root + apt
|
||||
|
||||
Reference in New Issue
Block a user