def finalize_regex()

in skywalking/config.py [0:0]


def finalize_regex() -> None:
    """
    Build path matchers based on user provided regex expressions
    """
    reesc = re.compile(r'([.*+?^=!:${}()|\[\]\\])')
    suffix = r'^.+(?:' + '|'.join(reesc.sub(r'\\\1', s.strip()) for s in agent_ignore_suffix.split(',')) + ')$'
    method = r'^' + '|'.join(s.strip() for s in plugin_http_ignore_method.split(',')) + '$'
    grpc_method = r'^' + '|'.join(s.strip() for s in plugin_grpc_ignored_methods.split(',')) + '$'
    path = '^(?:' + \
           '|'.join(  # replaces ","
               '/(?:[^/]*/)*'.join(  # replaces "/**/"
                   '(?:(?:[^/]+/)*[^/]+)?'.join(  # replaces "**"
                       '[^/]*'.join(  # replaces "*"
                           '[^/]'.join(  # replaces "?"
                               reesc.sub(r'\\\1', s) for s in p3.split('?')
                           ) for p3 in p2.split('*')
                       ) for p2 in p1.strip().split('**')
                   ) for p1 in p0.split('/**/')
               ) for p0 in agent_trace_ignore_path.split(',')
           ) + ')$'

    global RE_IGNORE_PATH, RE_HTTP_IGNORE_METHOD, RE_GRPC_IGNORED_METHODS
    RE_IGNORE_PATH = re.compile(f'{suffix}|{path}')
    RE_HTTP_IGNORE_METHOD = re.compile(method, re.IGNORECASE)
    RE_GRPC_IGNORED_METHODS = re.compile(grpc_method, re.IGNORECASE)