1. 程式人生 > >Sanic整合Sentry

Sanic整合Sentry

匯入名稱:sentry_sdk.integrations.sanic.SanicIntegration Sanic整合增加了對Sanic Web Framework的支援。

1、從PyPI安裝sentry-sdk:

$ pip install --upgrade sentry-sdk==0.4.3

2、要配置SDK,請在初始化應用程式之前或之後使用整合對其進行初始化:

import sentry_sdk
from sentry_sdk.integrations.sanic import SanicIntegration

sentry_sdk.init(
    dsn="https://<key>@sentry.io/<project>",
    integrations=[SanicIntegration()]
)

app = Sanic(__name__)

一、行為

1、將為您的所有應用程式安裝Sanic整合。

2、每個事件都附有一些資料:

  • 除非將send_default_pii設定為true,否則將排除個人可識別資訊(例如使用者ID,使用者名稱,cookie,授權標頭,IP地址)。
  • 請求資料附加到所有事件。
  • 報告導致內部伺服器錯誤的所有異常。

3、使用任何記錄器進行日誌記錄將在啟用日誌記錄整合時建立麵包屑(預設情況下已完成)。