text: # -*- coding: utf-8 -*-
  """
  TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-用户管理(Bk-User) available.
  Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.
  Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
  You may obtain a copy of the License at http://opensource.org/licenses/MIT
  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  specific language governing permissions and limitations under the License.
  """
  import sentry_sdk
  from sentry_sdk.integrations.django import DjangoIntegration
  
  
  def init_sentry_sdk():
      """Register celery error events to sentry"""
      from django.conf import settings
  
      if settings.SENTRY_DSN:
          # 初始化 sentry_sdk
          sentry_sdk.init(
              # debug=True,
              dsn=settings.SENTRY_DSN,
              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,
              # By default the SDK will try to use the SENTRY_RELEASE
              # environment variable, or infer a git commit
              # SHA as release, however you may want to set
              # something more human-readable.
              # release="myapp@1.0.0",
              # Can export the environment
              # environment="production",
          )
          # set global tag
          sentry_sdk.set_tag('service_name', 'bk-user-saas')
  