コード例 #1
0
    def process_response_headers(self, response_headers):
        """
        Decode the response headers and create appropriate metics based on the
        header values. The response_headers are passed in as a list of tuples.
        [(HEADER_NAME0, HEADER_VALUE0), (HEADER_NAME1, HEADER_VALUE1)]

        """

        if not self.settings.cross_application_tracer.enabled:
            return

        appdata = None

        try:
            for k, v in response_headers:
                if k.upper() == 'X-NEWRELIC-APP-DATA':
                    appdata = simplejson.loads(deobfuscate(
                        v, self.settings.encoding_key),
                                               encoding='UTF-8')
                    break

            if appdata:
                self.params['cross_process_id'] = appdata[0]
                self.params['external_txn_name'] = appdata[1]
                self.params['transaction_guid'] = appdata[5]

        except Exception:
            pass
コード例 #2
0
    def process_response_headers(self, response_headers):
        """
        Decode the response headers and create appropriate metics based on the
        header values. The response_headers are passed in as a list of tuples.
        [(HEADER_NAME0, HEADER_VALUE0), (HEADER_NAME1, HEADER_VALUE1)]

        """

        if not self.settings.cross_application_tracer.enabled:
            return

        appdata = None

        try:
            for k, v in response_headers:
                if k.upper() == "X-NEWRELIC-APP-DATA":
                    appdata = simplejson.loads(deobfuscate(v, self.settings.encoding_key), encoding="UTF-8")
                    break

            if appdata:
                self.params["cross_process_id"] = appdata[0]
                self.params["external_txn_name"] = appdata[1]
                self.params["transaction_guid"] = appdata[5]

        except Exception:
            pass
コード例 #3
0
    def process_txn_header(self, environ):
        encoded_txn_header = environ.get('HTTP_X_NEWRELIC_TRANSACTION')

        if encoded_txn_header:
            try:
                decoded_txn_header = simplejson.loads(deobfuscate(
                    encoded_txn_header, self._settings.encoding_key),
                                                      encoding='UTF-8')
            except Exception:
                decoded_txn_header = None

        return decoded_txn_header
コード例 #4
0
    def process_txn_header(self, environ):
        encoded_txn_header = environ.get('HTTP_X_NEWRELIC_TRANSACTION')

        if encoded_txn_header:
            try:
                decoded_txn_header = simplejson.loads(
                        deobfuscate(encoded_txn_header,
                            self._settings.encoding_key),
                        encoding='UTF-8')
            except Exception:
                decoded_txn_header = None

        return decoded_txn_header
コード例 #5
0
        raise DiscardDataForRequest()

    # Log details of response payload for debugging. Use the JSON
    # encoded value so know that what original encoded value was.

    duration = time.time() - start

    _logger.debug("Valid response from data collector after %.2f " "seconds with content=%r.", duration, r.content)

    # If we got this far we should have a legitimate response from the
    # data collector. The response is JSON so need to decode it.
    # Everything will come back as Unicode. Make sure all strings are
    # decoded as 'UTF-8'.

    try:
        result = json.loads(r.content, encoding="UTF-8")

    except Exception, exc:
        _logger.error(
            "Error decoding data for JSON payload "
            "with payload of %r. Exception which occurred was %r. "
            "Please report this problem to New Relic support.",
            r.content,
            exc,
        )

        raise DiscardDataForRequest(str(exc))

    # The decoded JSON can be either for a successful response or an
    # error. A successful response has a 'return_value' element and an
    # error an 'exception' element.
コード例 #6
0
                'seconds with content=%r.', duration, r.content)
    elif settings.debug.log_data_collector_calls:
        _logger.debug('Valid response from data collector after %.2f '
                'seconds.', duration)

    # If we got this far we should have a legitimate response from the
    # data collector. The response is JSON so need to decode it.
    # Everything will come back as Unicode. Make sure all strings are
    # decoded as 'UTF-8'.

    internal_metric('Supportability/Collector/Input/Bytes/%s' % method,
            len(r.content))

    try:
        with InternalTrace('Supportability/Collector/JSON/Decode/%s' % method):
            result = simplejson.loads(r.content, encoding='UTF-8')

    except Exception, exc:
        _logger.error('Error decoding data for JSON payload for method %r '
                'with payload of %r. Exception which occurred was %r. '
                'Please report this problem to New Relic support.', method,
                r.content, exc)

        if settings.debug.log_malformed_json_data:
            _logger.info('JSON data received from data collector which '
                    'could not be decoded was %r.', r.content)

        raise DiscardDataForRequest(str(exc))

    # The decoded JSON can be either for a successful response or an
    # error. A successful response has a 'return_value' element and an
コード例 #7
0
    elif settings.debug.log_data_collector_calls:
        _logger.debug(
            'Valid response from data collector after %.2f '
            'seconds.', duration)

    # If we got this far we should have a legitimate response from the
    # data collector. The response is JSON so need to decode it.
    # Everything will come back as Unicode. Make sure all strings are
    # decoded as 'UTF-8'.

    internal_metric('Supportability/Collector/Input/Bytes/%s' % method,
                    len(content))

    try:
        with InternalTrace('Supportability/Collector/JSON/Decode/%s' % method):
            result = simplejson.loads(content, encoding='UTF-8')

    except Exception, exc:
        _logger.error(
            'Error decoding data for JSON payload for method %r '
            'with payload of %r. Exception which occurred was %r. '
            'Please report this problem to New Relic support.', method,
            content, exc)

        if settings.debug.log_malformed_json_data:
            _logger.info(
                'JSON data received from data collector which '
                'could not be decoded was %r.', content)

        raise DiscardDataForRequest(str(exc))
コード例 #8
0
    # Log details of response payload for debugging. Use the JSON
    # encoded value so know that what original encoded value was.

    duration = time.time() - start

    _logger.debug(
        'Valid response from data collector after %.2f '
        'seconds with content=%r.', duration, r.content)

    # If we got this far we should have a legitimate response from the
    # data collector. The response is JSON so need to decode it.
    # Everything will come back as Unicode. Make sure all strings are
    # decoded as 'UTF-8'.

    try:
        result = json.loads(r.content, encoding='UTF-8')

    except Exception, exc:
        _logger.error(
            'Error decoding data for JSON payload '
            'with payload of %r. Exception which occurred was %r. '
            'Please report this problem to New Relic support.', r.content, exc)

        raise DiscardDataForRequest(str(exc))

    # The decoded JSON can be either for a successful response or an
    # error. A successful response has a 'return_value' element and an
    # error an 'exception' element.

    if 'status' in result:
        return result['status']
コード例 #9
0
    if settings.debug.log_data_collector_payloads:
        _logger.debug("Valid response from data collector after %.2f " "seconds with content=%r.", duration, content)
    elif settings.debug.log_data_collector_calls:
        _logger.debug("Valid response from data collector after %.2f " "seconds.", duration)

    # If we got this far we should have a legitimate response from the
    # data collector. The response is JSON so need to decode it.
    # Everything will come back as Unicode. Make sure all strings are
    # decoded as 'UTF-8'.

    internal_metric("Supportability/Collector/Input/Bytes/%s" % method, len(content))

    try:
        with InternalTrace("Supportability/Collector/JSON/Decode/%s" % method):
            result = simplejson.loads(content, encoding="UTF-8")

    except Exception, exc:
        _logger.error(
            "Error decoding data for JSON payload for method %r "
            "with payload of %r. Exception which occurred was %r. "
            "Please report this problem to New Relic support.",
            method,
            content,
            exc,
        )

        if settings.debug.log_malformed_json_data:
            _logger.info("JSON data received from data collector which " "could not be decoded was %r.", content)

        raise DiscardDataForRequest(str(exc))