# Path: osprofiler/_utils.py
# def split(text, strip=True):
# def binary_encode(text, encoding="utf-8"):
# def binary_decode(data, encoding="utf-8"):
# def generate_hmac(data, hmac_key):
# def signed_pack(data, hmac_key):
# def signed_unpack(data, hmac_data, hmac_keys):
# def itersubclasses(cls, _seen=None):
# def import_modules_from_package(package):
# def shorten_id(span_id):
# 
# Path: osprofiler/profiler.py
# def clean():
# def _ensure_no_multiple_traced(traceable_attrs):
# def init(hmac_key, base_id=None, parent_id=None):
# def get():
# def start(name, info=None):
# def stop(info=None):
# def trace(name, info=None, hide_args=False, hide_result=True,
#           allow_multiple_trace=True):
#     def decorator(f):
#         def wrapper(*args, **kwargs):
# def trace_cls(name, info=None, hide_args=False, hide_result=True,
#               trace_private=False, allow_multiple_trace=True,
#               trace_class_methods=False, trace_static_methods=False):
#     def trace_checker(attr_name, to_be_wrapped):
#     def decorator(cls):
#     def __init__(cls, cls_name, bases, attrs):
#     def __init__(self, name, info=None):
#     def __enter__(self):
#     def __exit__(self, etype, value, traceback):
#     def __init__(self, hmac_key, base_id=None, parent_id=None):
#     def get_shorten_id(self, uuid_id):
#     def get_base_id(self):
#     def get_parent_id(self):
#     def get_id(self):
#     def start(self, name, info=None):
#     def stop(self, info=None):
#     def _notify(self, name, info):
# class TracedMeta(type):
# class Trace(object):
# class _Profiler(object):


import webob.dec
from osprofiler import _utils as utils
from osprofiler import profiler
                 It's here to avoid some extra keyword arguments in local_conf
                 that cause `__init__() got an unexpected keyword argument`.
        """
        self.application = application
        self.name = "wsgi"
        self.enabled = enabled
        self.hmac_keys = utils.split(hmac_keys or "")

    @classmethod
    def factory(cls, global_conf, **local_conf):
        def filter_(app):
            return cls(app, **local_conf)
        return filter_

    def _trace_is_valid(self, trace_info):
        if not isinstance(trace_info, dict):
            return False
        trace_keys = set(trace_info.keys())
        if not all(k in trace_keys for k in _REQUIRED_KEYS):
            return False
        if trace_keys.difference(_REQUIRED_KEYS + _OPTIONAL_KEYS):
            return False
        return True

    @webob.dec.wsgify
    def __call__(self, request):
        if (_ENABLED is not None and not _ENABLED
                or _ENABLED is None and not self.enabled):
            return request.get_response(self.application)


# Path: osprofiler/_utils.py
# def split(text, strip=True):
# def binary_encode(text, encoding="utf-8"):
# def binary_decode(data, encoding="utf-8"):
# def generate_hmac(data, hmac_key):
# def signed_pack(data, hmac_key):
# def signed_unpack(data, hmac_data, hmac_keys):
# def itersubclasses(cls, _seen=None):
# def import_modules_from_package(package):
# def shorten_id(span_id):
# 
# Path: osprofiler/profiler.py
# def clean():
# def _ensure_no_multiple_traced(traceable_attrs):
# def init(hmac_key, base_id=None, parent_id=None):
# def get():
# def start(name, info=None):
# def stop(info=None):
# def trace(name, info=None, hide_args=False, hide_result=True,
#           allow_multiple_trace=True):
#     def decorator(f):
#         def wrapper(*args, **kwargs):
# def trace_cls(name, info=None, hide_args=False, hide_result=True,
#               trace_private=False, allow_multiple_trace=True,
#               trace_class_methods=False, trace_static_methods=False):
#     def trace_checker(attr_name, to_be_wrapped):
#     def decorator(cls):
#     def __init__(cls, cls_name, bases, attrs):
#     def __init__(self, name, info=None):
#     def __enter__(self):
#     def __exit__(self, etype, value, traceback):
#     def __init__(self, hmac_key, base_id=None, parent_id=None):
#     def get_shorten_id(self, uuid_id):
#     def get_base_id(self):
#     def get_parent_id(self):
#     def get_id(self):
#     def start(self, name, info=None):
#     def stop(self, info=None):
#     def _notify(self, name, info):
# class TracedMeta(type):
# class Trace(object):
# class _Profiler(object):


# Path: osprofiler/web.py
import webob.dec
from osprofiler import _utils as utils
from osprofiler import profiler

                 It's here to avoid some extra keyword arguments in local_conf
                 that cause `__init__() got an unexpected keyword argument`.
        """
        self.application = application
        self.name = "wsgi"
        self.enabled = enabled
        self.hmac_keys = utils.split(hmac_keys or "")

    @classmethod
    def factory(cls, global_conf, **local_conf):
        def filter_(app):
            return cls(app, **local_conf)
        return filter_

    def _trace_is_valid(self, trace_info):
        if not isinstance(trace_info, dict):
            return False
        trace_keys = set(trace_info.keys())
        if not all(k in trace_keys for k in _REQUIRED_KEYS):
            return False
        if trace_keys.difference(_REQUIRED_KEYS + _OPTIONAL_KEYS):
            return False
        return True

    @webob.dec.wsgify
    def __call__(self, request):
        if (_ENABLED is not None and not _ENABLED
                or _ENABLED is None and not self.enabled):
            return request.get_response(self.application)


        trace_info = utils.signed_unpack(request.headers.get(X_TRACE_INFO),