删除sync_center埋点
This commit is contained in:
parent
364ceb29a1
commit
85c2e7459e
60
util/api.py
60
util/api.py
@ -24,40 +24,32 @@ def sync_center():
|
||||
:return: 任务列表
|
||||
"""
|
||||
from template import TEMPLATES, download_template
|
||||
tracer = get_tracer(__name__)
|
||||
with tracer.start_as_current_span("sync_center"):
|
||||
with tracer.start_as_current_span("sync_center.request") as req_span:
|
||||
try:
|
||||
req_span.set_attribute("http.method", "POST")
|
||||
req_span.set_attribute("http.url", os.getenv('API_ENDPOINT') + "/sync")
|
||||
response = session.post(os.getenv('API_ENDPOINT') + "/sync", json={
|
||||
'accessKey': os.getenv('ACCESS_KEY'),
|
||||
'clientStatus': util.system.get_sys_info(),
|
||||
'templateList': [{'id': t.get('id', ''), 'updateTime': t.get('updateTime', '')} for t in
|
||||
TEMPLATES.values()]
|
||||
}, timeout=10)
|
||||
req_span.set_attribute("http.status_code", response.status_code)
|
||||
req_span.set_attribute("http.response", response.text)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
req_span.set_attribute("http.error", str(e))
|
||||
logger.error("请求失败!", e)
|
||||
return []
|
||||
data = response.json()
|
||||
logger.debug("获取任务结果:【%s】", data)
|
||||
if data.get('code', 0) == 200:
|
||||
templates = data.get('data', {}).get('templates', [])
|
||||
tasks = data.get('data', {}).get('tasks', [])
|
||||
else:
|
||||
tasks = []
|
||||
templates = []
|
||||
logger.warning("获取任务失败")
|
||||
for template in templates:
|
||||
template_id = template.get('id', '')
|
||||
if template_id:
|
||||
logger.info("更新模板:【%s】", template_id)
|
||||
download_template(template_id)
|
||||
return tasks
|
||||
try:
|
||||
response = session.post(os.getenv('API_ENDPOINT') + "/sync", json={
|
||||
'accessKey': os.getenv('ACCESS_KEY'),
|
||||
'clientStatus': util.system.get_sys_info(),
|
||||
'templateList': [{'id': t.get('id', ''), 'updateTime': t.get('updateTime', '')} for t in
|
||||
TEMPLATES.values()]
|
||||
}, timeout=10)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
logger.error("请求失败!", e)
|
||||
return []
|
||||
data = response.json()
|
||||
logger.debug("获取任务结果:【%s】", data)
|
||||
if data.get('code', 0) == 200:
|
||||
templates = data.get('data', {}).get('templates', [])
|
||||
tasks = data.get('data', {}).get('tasks', [])
|
||||
else:
|
||||
tasks = []
|
||||
templates = []
|
||||
logger.warning("获取任务失败")
|
||||
for template in templates:
|
||||
template_id = template.get('id', '')
|
||||
if template_id:
|
||||
logger.info("更新模板:【%s】", template_id)
|
||||
download_template(template_id)
|
||||
return tasks
|
||||
|
||||
|
||||
def get_template_info(template_id):
|
||||
|
Loading…
x
Reference in New Issue
Block a user