def get_binary_annotations(request, response):
    """Helper method for getting all binary annotations from the request.

    :param request: the Pyramid request object
    :param response: the Pyramid response object
    :returns: binary annotation dict of {str: str}
    """
    route = request.matched_route.pattern if request.matched_route else ''
    annotations = {'http.uri': request.path, 'http.uri.qs': request.path_qs,
        'http.route': route, 'response_status_code': str(response.status_code)}
    settings = request.registry.settings
    if 'zipkin.set_extra_binary_annotations' in settings:
        annotations.update(settings['zipkin.set_extra_binary_annotations'](
            request, response))
    return annotations
