ddtrace/api.py
def _parse_response_json(response):
    """
    Parse the content of a response object, and return the right type,
    can be a string if the output was plain text, or a dictionnary if
    the output was a JSON.
    """
    if hasattr(response, 'read'):
        body = response.read()
        try:
            if not isinstance(body, str) and hasattr(body, 'decode'):
                body = body.decode('utf-8')
            if hasattr(body, 'startswith') and body.startswith('OK'):
                # This typically happens when using a priority-sampling enabled
                # library with an outdated agent. It still works, but priority sampling
                # will probably send too many traces, so the next step is to upgrade agent.
                log.debug("'OK' is not a valid JSON, please make sure trace-agent is up to date")
                return
            content = loads(body)
            return content
        except (ValueError, TypeError) as err:
            log.debug("unable to load JSON '%s': %s" % (body, err))

    Parse the content of a response object, and return the right type,
    can be a string if the output was plain text, or a dictionnary if
    the output was a JSON.
    
Parse the content of a response object, and return the right type,
can be a string if the output was plain text, or a dictionnary if
the output was a JSON.
Parse the content of a response object and return the right type can be a string if the output was plain text or a dictionnary if the output was a JSON .
def _parse_response_json(response):
    if hasattr(response, 'read'):
        body = response.read()
        try:
            if not isinstance(body, str) and hasattr(body, 'decode'):
                body = body.decode('utf-8')
            if hasattr(body, 'startswith') and body.startswith('OK'):
                log.debug("'OK' is not a valid JSON, please make sure trace-agent is up to date")
                return
            content = loads(body)
            return content
        except (ValueError, TypeError) as err:
            log.debug("unable to load JSON '%s': %s" % (body, err))
def _parse_response_json ( response ) : if hasattr ( response , 'read' ) : body = response . read ( ) try : if not isinstance ( body , str ) and hasattr ( body , 'decode' ) : body = body . decode ( 'utf-8' ) if hasattr ( body , 'startswith' ) and body . startswith ( 'OK' ) : log . debug ( "'OK' is not a valid JSON, please make sure trace-agent is up to date" ) return content = loads ( body ) return content except ( ValueError , TypeError ) as err : log . debug ( "unable to load JSON '%s': %s" % ( body , err ) )
Parse the content of a response object, and return the right type,
can be a string if the output was plain text, or a dictionnary if
the output was a JSON.
Parse the content of a response object and return the right type can be a string if the output was plain text or a dictionnary if the output was a JSON .
"""
    Parse the content of a response object, and return the right type,
    can be a string if the output was plain text, or a dictionnary if
    the output was a JSON.
    """ # This typically happens when using a priority-sampling enabled # library with an outdated agent. It still works, but priority sampling # will probably send too many traces, so the next step is to upgrade agent.
response