【Sentry使用】【Py】Python代码编译后无法进入Sentry

15 篇文章 0 订阅
9 篇文章 1 订阅

最近的项目出现一个问题:对项目进行编译,运行一切正常,也没有任何报错,就仅仅是在Sentry前端无法显示任何相关执行记录。不编译则恢复正常。
最外层代码为main.py,long.py,zhuo.py三个文件
使用setup.py文件进行编译

# main.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()
# zhuo.py
import sentry_sdk

def main(transaction: sentry_sdk.tracing.Transaction):
    with transaction.start_child(op="zhuo"):
        ...
        ...
# long.py
import sentry_sdk

transaction = sentry_sdk.Hub.current.scope.transaction

def main(transaction: sentry_sdk.tracing.Transaction):
    with transaction.start_child(op="long"):
        ...
        ...
# setup.py
import os
from distutils.core import setup
from Cython.Build import cythonize


def getListOfFiles(dirName):
    # create a list of file and sub directories
    # names in the given directory
    listOfFile = os.listdir(dirName)
    allFiles = list()
    # Iterate over all the entries
    for entry in listOfFile:
        # Create full path
        fullPath = os.path.join(dirName, entry)
        # If entry is a directory then get the list of files in this directory
        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文件),一切正常

如果看到文章的你知道其中原委,还望不吝赐教

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值