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