当前位置: 首页>>代码示例>>Python>>正文


Python flask.Sentry方法代码示例

本文整理汇总了Python中raven.contrib.flask.Sentry方法的典型用法代码示例。如果您正苦于以下问题:Python flask.Sentry方法的具体用法?Python flask.Sentry怎么用?Python flask.Sentry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在raven.contrib.flask的用法示例。


在下文中一共展示了flask.Sentry方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_plugins

# 需要导入模块: from raven.contrib import flask [as 别名]
# 或者: from raven.contrib.flask import Sentry [as 别名]
def init_plugins():
        """初始化日志、错误追踪、打点插件"""
        from everyclass.rpc import init as init_rpc
        from everyclass.common.flask import print_config

        # Sentry
        if plugin_available("sentry"):
            sentry.init_app(app=__app)
            sentry_handler = SentryHandler(sentry.client)
            sentry_handler.setLevel(logging.WARNING)
            logging.getLogger().addHandler(sentry_handler)

            init_rpc(sentry=sentry)
            logger.info('Sentry is inited because you are in {} mode.'.format(__app.config['CONFIG_NAME']))

        # metrics
        global statsd
        statsd = DogStatsd(namespace=f"{__app.config['SERVICE_NAME']}.{os.environ.get('MODE').lower()}",
                           use_default_route=True)

        init_rpc(logger=logger)

        print_config(__app, logger) 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:25,代码来源:__init__.py

示例2: public_dsn

# 需要导入模块: from raven.contrib import flask [as 别名]
# 或者: from raven.contrib.flask import Sentry [as 别名]
def public_dsn(dsn):
    '''Transform a standard Sentry DSN into a public one'''
    m = RE_DSN.match(dsn)
    if not m:
        log.error('Unable to parse Sentry DSN')
    public = '{scheme}://{client_id}@{domain}/{site_id}'.format(
        **m.groupdict())
    return public 
开发者ID:opendatateam,项目名称:udata,代码行数:10,代码来源:sentry.py

示例3: create_app

# 需要导入模块: from raven.contrib import flask [as 别名]
# 或者: from raven.contrib.flask import Sentry [as 别名]
def create_app():
    # instantiate the app
    app = BaseFlask(__name__)

    # configure sentry
    if not app.debug and not app.testing:
        global sentry
        sentry = Sentry(app, dsn=app.config['SENTRY_DSN'])

    # set up extensions
    db.init_app(app)
    bcrypt.init_app(app)
    migrate.init_app(app, db)
    mail.init_app(app)

    # register blueprints
    from project.api.v1.auth import auth_blueprint
    from project.api.v1.users import users_blueprint
    from project.api.v1.devices import devices_blueprint
    from project.api.v1.phone_validation import phone_validation_blueprint
    from project.api.v1.email_validation import email_validation_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/v1')
    app.register_blueprint(users_blueprint, url_prefix='/v1')
    app.register_blueprint(devices_blueprint, url_prefix='/v1')
    app.register_blueprint(phone_validation_blueprint, url_prefix='/v1')
    app.register_blueprint(email_validation_blueprint, url_prefix='/v1')

    # register error handlers
    from project.api.common.utils import exceptions
    from project.api.common import error_handlers
    app.register_error_handler(exceptions.InvalidPayload, error_handlers.handle_exception)
    app.register_error_handler(exceptions.BusinessException, error_handlers.handle_exception)
    app.register_error_handler(exceptions.UnauthorizedException, error_handlers.handle_exception)
    app.register_error_handler(exceptions.ForbiddenException, error_handlers.handle_exception)
    app.register_error_handler(exceptions.NotFoundException, error_handlers.handle_exception)
    app.register_error_handler(exceptions.ServerErrorException, error_handlers.handle_exception)
    app.register_error_handler(Exception, error_handlers.handle_general_exception)
    return app


# noinspection PyPropertyAccess 
开发者ID:mtnbarreto,项目名称:flask-base-api,代码行数:43,代码来源:__init__.py

示例4: _add_sentry

# 需要导入模块: from raven.contrib import flask [as 别名]
# 或者: from raven.contrib.flask import Sentry [as 别名]
def _add_sentry(app, level=logging.NOTSET):
    """Adds Sentry logging.
    Sentry is a realtime event logging and aggregation platform. Additional
    information about it is available at https://sentry.readthedocs.org/.
    We use Raven as a client for Sentry. More info about Raven is available at
    https://raven.readthedocs.org/.
    """
    Sentry(app, logging=True, level=level) 
开发者ID:metabrainz,项目名称:mbspotify,代码行数:10,代码来源:loggers.py

示例5: init_app

# 需要导入模块: from raven.contrib import flask [as 别名]
# 或者: from raven.contrib.flask import Sentry [as 别名]
def init_app(self, app):
        sentry_type = app.config.get("EXCEPTION_LOG_TYPE", "FakeSentry")

        if sentry_type == "Sentry":
            sentry = FlaskSentry(app, register_signal=False)
        else:
            sentry = FakeSentry()

        # register extension with app
        app.extensions = getattr(app, "extensions", {})
        app.extensions["sentry"] = sentry
        return sentry 
开发者ID:quay,项目名称:quay,代码行数:14,代码来源:exceptionlog.py

示例6: init_app

# 需要导入模块: from raven.contrib import flask [as 别名]
# 或者: from raven.contrib.flask import Sentry [as 别名]
def init_app(self, *args, **kwargs):
        super(EnhancedSentry, self).init_app(*args, **kwargs)
        if self.client:
            # Downgrade the logging level of Sentry
            self.client.error_logger.error = self.client.error_logger.warning 
开发者ID:huskar-org,项目名称:huskar,代码行数:7,代码来源:ext.py

示例7: make_celery

# 需要导入模块: from raven.contrib import flask [as 别名]
# 或者: from raven.contrib.flask import Sentry [as 别名]
def make_celery(app, celery):
    """ From http://flask.pocoo.org/docs/0.10/patterns/celery/ """
    # Register our custom serializer type before updating the configuration.
    from kombu.serialization import register
    from doorman.celery_serializer import djson_dumps, djson_loads

    register(
        'djson', djson_dumps, djson_loads,
        content_type='application/x-djson',
        content_encoding='utf-8'
    )

    # Actually update the config
    celery.config_from_object(app.config)

    # Register Sentry client
    if 'SENTRY_DSN' in app.config and app.config['SENTRY_DSN']:
        client = Client(app.config['SENTRY_DSN'])
        # register a custom filter to filter out duplicate logs
        register_logger_signal(client)
        # hook into the Celery error handler
        register_signal(client)

    TaskBase = celery.Task

    class ContextTask(TaskBase):

        abstract = True

        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)

    celery.Task = ContextTask
    return celery 
开发者ID:mwielgoszewski,项目名称:doorman,代码行数:37,代码来源:extensions.py

示例8: init_app

# 需要导入模块: from raven.contrib import flask [as 别名]
# 或者: from raven.contrib.flask import Sentry [as 别名]
def init_app(app):
    if app.config['SENTRY_DSN']:
        try:
            from raven.contrib.celery import (
                register_signal, register_logger_signal
            )
            from raven.contrib.flask import Sentry
        except ImportError:
            log.error('raven is required to use Sentry')
            return

        sentry = Sentry()
        tags = app.config['SENTRY_TAGS']
        log_level_name = app.config['SENTRY_LOGGING']
        if log_level_name:
            log_level = getattr(logging, log_level_name.upper())
            if log_level:
                sentry.logging = True
                sentry.level = log_level

        # Do not send HTTPExceptions
        exceptions = set(app.config['SENTRY_IGNORE_EXCEPTIONS'])
        for exception in IGNORED_EXCEPTIONS:
            exceptions.add(exception)
        app.config['SENTRY_IGNORE_EXCEPTIONS'] = list(exceptions)

        app.config['SENTRY_PUBLIC_DSN'] = public_dsn(app.config['SENTRY_DSN'])

        # Versions Management: uData and plugins versions as tags.
        for dist in entrypoints.get_plugins_dists(app):
            if dist.version:
                tags[dist.project_name] = dist.version
        # Do not forget udata itself
        tags['udata'] = pkg_resources.get_distribution('udata').version

        sentry.init_app(app)

        # register a custom filter to filter out duplicate logs
        register_logger_signal(sentry.client, loglevel=sentry.level)

        # hook into the Celery error handler
        register_signal(sentry.client) 
开发者ID:opendatateam,项目名称:udata,代码行数:44,代码来源:sentry.py


注:本文中的raven.contrib.flask.Sentry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。