def error_events(self, stats_table): errors = [] for error in self.errors: intrinsics = self.error_event_intrinsics(error, stats_table) # Add user and agent attributes to event agent_attributes = {} for attr in self.agent_attributes: if attr.destinations & DST_ERROR_COLLECTOR: agent_attributes[attr.name] = attr.value user_attributes = {} for attr in self.user_attributes: if attr.destinations & DST_ERROR_COLLECTOR: user_attributes[attr.name] = attr.value # add error specific custom params to this error's userAttributes err_attrs = create_user_attributes(error.custom_params, self.settings.attribute_filter) for attr in err_attrs: if attr.destinations & DST_ERROR_COLLECTOR: user_attributes[attr.name] = attr.value error_event = [intrinsics, user_attributes, agent_attributes] errors.append(error_event) return errors
def error_details(self): """Return a generator yielding the details for each unique error captured during this transaction. """ # TODO There is no attempt so far to eliminate duplicates. # Duplicates could be eliminated based on exception type # and message or exception type and file name/line number # presuming the latter are available. Right now the file # name and line number aren't captured so can't rely on it. # TODO There are no constraints in place on what keys/values # can be in params dictionaries. Need to convert values to # strings at some point. if not self.errors: return for error in self.errors: params = {} params["stack_trace"] = error.stack_trace intrinsics = { 'spanId': error.span_id, 'error.expected': error.expected } intrinsics.update(self.trace_intrinsics) params['intrinsics'] = intrinsics params['agentAttributes'] = {} for attr in self.agent_attributes: if attr.destinations & DST_ERROR_COLLECTOR: params['agentAttributes'][attr.name] = attr.value params['userAttributes'] = {} for attr in self.user_attributes: if attr.destinations & DST_ERROR_COLLECTOR: params['userAttributes'][attr.name] = attr.value # add source context attrs for error if self.settings and self.settings.code_level_metrics and self.settings.code_level_metrics.enabled and getattr( error, "source", None): error.source.add_attrs(params['agentAttributes'].__setitem__) # add error specific custom params to this error's userAttributes err_attrs = create_user_attributes(error.custom_params, self.settings.attribute_filter) for attr in err_attrs: if attr.destinations & DST_ERROR_COLLECTOR: params['userAttributes'][attr.name] = attr.value yield newrelic.core.error_collector.TracedError( start_time=error.timestamp, path=self.path, message=error.message, type=error.type, parameters=params)
def error_details(self): """Return a generator yielding the details for each unique error captured during this transaction. """ # TODO There is no attempt so far to eliminate duplicates. # Duplicates could be eliminated based on exception type # and message or exception type and file name/line number # presuming the latter are available. Right now the file # name and line number aren't captured so can't rely on it. # TODO There are no constraints in place on what keys/values # can be in params dictionaries. Need to convert values to # strings at some point. if not self.errors: return for error in self.errors: params = {} params["request_uri"] = self.request_uri params["stack_trace"] = error.stack_trace params['intrinsics'] = self.trace_intrinsics params['agentAttributes'] = {} for attr in self.agent_attributes: if attr.destinations & DST_ERROR_COLLECTOR: params['agentAttributes'][attr.name] = attr.value params['userAttributes'] = {} for attr in self.user_attributes: if attr.destinations & DST_ERROR_COLLECTOR: params['userAttributes'][attr.name] = attr.value # add error specific custom params to this error's userAttributes err_attrs = create_user_attributes(error.custom_params, self.settings.attribute_filter) for attr in err_attrs: if attr.destinations & DST_ERROR_COLLECTOR: params['userAttributes'][attr.name] = attr.value yield newrelic.core.error_collector.TracedError( start_time=error.timestamp, path=self.path, message=error.message, type=error.type, parameters=params)
def user_attributes(self): return create_user_attributes(self._custom_params, self.attribute_filter)