最近的项目出现一个问题:对项目进行编译,运行一切正常,也没有任何报错,就仅仅是在Sentry前端无法显示任何相关执行记录。不编译则恢复正常。 最外层代码为main.py,long.py,zhuo.py三个文件 使用setup.py文件进行编译
from sentry_sdk import start_transaction
from threading import Thread
import zhuo
import long
with start_transaction(op='xxxx', name='xxxx', status='ok') as transaction:
p1 = Thread(target=zhuo.main, args=(transaction, ))
p2 = Thread(target=long.main, args=(transaction, ))
p1.start()
p2.start()
p1.join()
p2.join()
import sentry_sdk
def main(transaction: sentry_sdk.tracing.Transaction):
with transaction.start_child(op="zhuo"):
...
...
import sentry_sdk
transaction = sentry_sdk.Hub.current.scope.transaction
def main(transaction: sentry_sdk.tracing.Transaction):
with transaction.start_child(op="long"):
...
...
import os
from distutils.core import setup
from Cython.Build import cythonize
def getListOfFiles(dirName):
listOfFile = os.listdir(dirName)
allFiles = list()
for entry in listOfFile:
fullPath = os.path.join(dirName, entry)
if os.path.isdir(fullPath):
allFiles = allFiles + getListOfFiles(fullPath)
elif os.path.splitext(fullPath)[-1] == '.py':
allFiles.append(fullPath)
return allFiles
listOfFiles = ['./main.py']
listOfFiles += ['./zhuo.py']
listOfFiles += ['./long.py']
for file in listOfFiles:
setup(
ext_modules=cythonize(
file,
language_level = "3",
compiler_directives={'always_allow_keywords': True}
)
)
if os.path.split(file)[0] != '.':
print(os.system(f'rm {os.path.splitext(file)[0]}.*'))
print(os.system(f'mv *.so {os.path.split(file)[0]}'))
else:
print(os.system(f'rm {os.path.splitext(file)[0]}.py'))
print(os.system(f'rm {os.path.splitext(file)[0]}.c'))
print(os.system('rm -r build'))
搜索了一下,发现也有人出现该问题,给的建议是使用breadcrumbs,但我还没有尝试 但奇怪的是,另一个Flask接口项目也使用了Sentry而且也进行了编译(所有.py文件),一切正常
如果看到文章的你知道其中原委,还望不吝赐教
|