

def setup_handlers():
    if ('sentry_handler' not in __opts__):
        log.debug("No 'sentry_handler' key was found in the configuration")
        return False
    options = {
        
    }
    dsn = get_config_value('dsn')
    if (dsn is not None):
        try:
            from raven.transport import TransportRegistry, default_transports
            from raven.utils.urlparse import urlparse
            transport_registry = TransportRegistry(default_transports)
            url = urlparse(dsn)
            if (not transport_registry.supported_scheme(url.scheme)):
                raise ValueError('Unsupported Sentry DSN scheme: {0}'.format(url.scheme))
            dsn_config = {
                
            }
            conf_extras = transport_registry.compute_scope(url, dsn_config)
            dsn_config.update(conf_extras)
            options.update({
                'project': dsn_config['SENTRY_PROJECT'],
                'servers': dsn_config['SENTRY_SERVERS'],
                'public_key': options['SENTRY_PUBLIC_KEY'],
                'secret_key': dsn_config['SENTRY_SECRET_KEY'],
            })
        except ValueError as exc:
            log.info('Raven failed to parse the configuration provided DSN: {0}'.format(exc))
    for key in ('project', 'servers', 'public_key', 'secret_key'):
        config_value = get_config_value(key)
        if ((config_value is None) and (key not in options)):
            log.debug("The required 'sentry_handler' configuration key, '{0}', is not properly configured. Not configuring the sentry logging handler.".format(key))
            return
        elif (config_value is None):
            continue
        options[key] = config_value
    options.update({
        'site': get_config_value('site'),
        'name': get_config_value('name'),
        'exclude_paths': get_config_value('exclude_paths', ()),
        'include_paths': get_config_value('include_paths', ()),
        'list_max_length': get_config_value('list_max_length'),
        'string_max_length': get_config_value('string_max_length'),
        'auto_log_stacks': get_config_value('auto_log_stacks'),
        'timeout': get_config_value('timeout', 1),
        'processors': get_config_value('processors'),
        'dsn': dsn,
    })
    client = raven.Client(**options)
    context = get_config_value('context')
    context_dict = {
        
    }
    if (context is not None):
        for tag in context:
            tag_value = __salt__['grains.get'](tag)
            if (len(tag_value) > 0):
                context_dict[tag] = tag_value
        if (len(context_dict) > 0):
            client.context.merge({
                'tags': context_dict,
            })
    try:
        handler = SentryHandler(client)
        handler.setLevel(LOG_LEVELS[get_config_value('log_level', 'error')])
        return handler
    except ValueError as exc:
        log.debug('Failed to setup the sentry logging handler: {0}'.format(exc), exc_info=exc)

dataset/ETHPy150Open saltstack/salt/salt/log/handlers/sentry_mod.py setup_handlers/VarMisuse@168/274 `dsn_config`->`options`