我怎样才能确定我的应用程序是否在开发服务器上运行?我想,我可以检查的价值settings.DEBUG,并假设如果DEBUG是True那么它的开发服务器上运行,但我更愿意知道肯定不是依靠惯例.
当我在本地服务器上工作时(即http://127.0.0.1:8000/ ) ,我试图阻止 Sentry 将错误记录到我的 Sentry 仪表板。我希望哨兵将错误记录到仪表板的唯一时间是当我的代码投入生产时。我该怎么办?我在下面尝试过这个,但它不起作用:
if DEBUG == True
sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN', None),
integrations=[DjangoIntegration()],
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
traces_sample_rate=1.0,
# If you wish to associate users to errors (assuming you are using
# django.contrib.auth) you may enable sending PII data.
send_default_pii=True
)
Run Code Online (Sandbox Code Playgroud)