예제 #1
0
    get_errno_fields,
    module_dict,
    parse_url,
    Local,
)

__all__ = [
    'configure',
    'enable_requests_logging',
    'get_session',
    'register_endpoint_name',
]

STORAGE = Local()
STORAGE.sessions = {}
HOSTS = module_dict()
DEBUG_HEADER = future.utils.text_to_native_str('X-Debug')


def clear():
    if hasattr(STORAGE, 'sessions'):
        STORAGE.sessions.clear()
    HOSTS.clear()


# storage for metric url state, as requests design allows for no other way
logger = logging.getLogger('talisker.requests')


class RequestsMetric:
    latency = talisker.metrics.Histogram(
예제 #2
0
파일: config.py 프로젝트: hackoder/talisker
from talisker.util import (
    force_unicode,
    module_cache,
    module_dict,
    sanitize_url,
)

__all__ = ['get_config']

# All valid config
CONFIG_META = collections.OrderedDict()
CONFIG_ALIASES = {
    'TALISKER_COLOUR': 'TALISKER_COLOR',
}
# A cache of calculated config values
CONFIG_CACHE = module_dict()
# Collect any configuration errors
CONFIG_ERRORS = module_dict()


def clear():
    CONFIG_CACHE.clear()
    CONFIG_ERRORS.clear()


@module_cache
def get_config(env=os.environ):
    raw = load_env_config(env)
    return Config(raw)

예제 #3
0
)

__all__ = [
    'get_client',
    'configure_client',
    'set_client',
    'register_client_update',
]

default_processors = set([
    'raven.processors.RemovePostDataProcessor',
    'raven.processors.SanitizePasswordsProcessor',
    'raven.processors.RemoveStackLocalsProcessor',
])

sentry_globals = module_dict()

# sql queries and http requests are recorded as explicit breadcrumbs as well as
# logged, so ignore the log breadcrumb
raven.breadcrumbs.ignore_logger('talisker.slowqueries')
raven.breadcrumbs.ignore_logger('talisker.requests')


def register_client_update(update_func):
    sentry_globals.setdefault('updates', []).append(update_func)
    return update_func


def update_client_references(client):
    for update_func in sentry_globals.get('updates', []):
        update_func(client)
예제 #4
0
import logging
import logging.handlers
import numbers
import sys
import time

from talisker.context import ContextStack
from talisker.util import module_dict, module_cache, get_errno_fields

__all__ = [
    'configure',
    'configure_test_logging',
    'logging_context',
]

logging_globals = module_dict()


def set_global_extra(extra):
    if 'extra' not in logging_globals:
        logging_globals['extra'] = OrderedDict()
    logging_globals['extra'].update(extra)


def reset_logging():
    """Reset logging config"""
    # avoid unclosed file resource warning
    for handler in logging.getLogger().handlers:
        if getattr(handler, '_debug_handler', False):
            handler.stream.close()
    logging.getLogger().handlers = []
예제 #5
0
from talisker.util import (
    force_unicode,
    module_cache,
    module_dict,
    sanitize_url,
)


__all__ = ['get_config']


# All valid config
CONFIG_META = collections.OrderedDict()
CONFIG_ALIASES = {'TALISKER_COLOUR': 'TALISKER_COLOR'}
# A cache of calculated config values
CONFIG_CACHE = module_dict()
# Collect any configuration errors
CONFIG_ERRORS = module_dict()


def clear():
    CONFIG_CACHE.clear()
    CONFIG_ERRORS.clear()


@module_cache
def get_config(env=os.environ):
    raw = load_env_config(env)
    return Config(raw)