def trace_node(self, stats, root, connections): name = root.string_table.cache(self.name) start_time = newrelic.core.trace_node.node_start_time(root, self) end_time = newrelic.core.trace_node.node_end_time(root, self) children = [] root.trace_node_count += 1 # Agent attributes params = attribute.resolve_agent_attributes( self.agent_attributes, root.settings.attribute_filter, DST_TRANSACTION_SEGMENTS) # User attributes override agent attributes if self.params: params.update(self.params) # Intrinsic attributes override everything params['exclusive_duration_millis'] = 1000.0 * self.exclusive return newrelic.core.trace_node.TraceNode(start_time=start_time, end_time=end_time, name=name, params=params, children=children, label=None)
def span_event(self, settings, base_attrs=None, parent_guid=None, attr_class=dict): i_attrs = base_attrs and base_attrs.copy() or attr_class() i_attrs['type'] = 'Span' i_attrs['name'] = self.name i_attrs['guid'] = self.guid i_attrs['timestamp'] = int(self.start_time * 1000) i_attrs['duration'] = self.duration i_attrs['category'] = 'generic' if parent_guid: i_attrs['parentId'] = parent_guid a_attrs = attribute.resolve_agent_attributes(self.agent_attributes, settings.attribute_filter, DST_SPAN_EVENTS, attr_class=attr_class) u_attrs = attribute.resolve_user_attributes( self.processed_user_attributes, settings.attribute_filter, DST_SPAN_EVENTS, attr_class=attr_class) # intrinsics, user attrs, agent attrs return [i_attrs, u_attrs, a_attrs]
def trace_node(self, stats, root, connections): name = root.string_table.cache(self.name) start_time = newrelic.core.trace_node.node_start_time(root, self) end_time = newrelic.core.trace_node.node_end_time(root, self) children = [] root.trace_node_count += 1 # Agent attributes self.agent_attributes['db.instance'] = self.db_instance params = attribute.resolve_agent_attributes( self.agent_attributes, root.settings.attribute_filter, DST_TRANSACTION_SEGMENTS) # Intrinsic attributes override everything params['exclusive_duration_millis'] = 1000.0 * self.exclusive ds_tracer_settings = stats.settings.datastore_tracer instance_enabled = ds_tracer_settings.instance_reporting.enabled if instance_enabled: if self.instance_hostname: params['host'] = self.instance_hostname if self.port_path_or_id: params['port_path_or_id'] = self.port_path_or_id return newrelic.core.trace_node.TraceNode(start_time=start_time, end_time=end_time, name=name, params=params, children=children, label=None)
def trace_node(self, stats, root, connections): name = root.string_table.cache(self.name) start_time = newrelic.core.trace_node.node_start_time(root, self) end_time = newrelic.core.trace_node.node_end_time(root, self) children = [] root.trace_node_count += 1 # Agent attributes self.agent_attributes['db.instance'] = self.db_instance params = attribute.resolve_agent_attributes( self.agent_attributes, root.settings.attribute_filter, DST_TRANSACTION_SEGMENTS) # Intrinsic attributes override everything params['exclusive_duration_millis'] = 1000.0 * self.exclusive # Only send datastore instance params if not empty. if self.host: params['host'] = self.instance_hostname if self.port_path_or_id: params['port_path_or_id'] = self.port_path_or_id sql = self.formatted if sql: # Limit the length of any SQL that is reported back. limit = root.settings.agent_limits.sql_query_length_maximum params['sql'] = root.string_table.cache(sql[:limit]) if self.stack_trace: params['backtrace'] = [ root.string_table.cache(x) for x in self.stack_trace ] # Only perform an explain plan if this node ended up being # flagged to have an explain plan. This is applied when cap # on number of explain plans for whole harvest period is # applied across all transaction traces just prior to the # transaction traces being generated. if getattr(self, 'generate_explain_plan', None): explain_plan_data = self.explain_plan(connections) if explain_plan_data: params['explain_plan'] = explain_plan_data return newrelic.core.trace_node.TraceNode(start_time=start_time, end_time=end_time, name=name, params=params, children=children, label=None)
def get_trace_segment_params(self, settings, params=None): _params = attribute.resolve_agent_attributes(self.agent_attributes, settings.attribute_filter, DST_TRANSACTION_SEGMENTS) if params: _params.update(params) _params.update( attribute.resolve_user_attributes(self.processed_user_attributes, settings.attribute_filter, DST_TRANSACTION_SEGMENTS)) _params['exclusive_duration_millis'] = 1000.0 * self.exclusive return _params
def trace_node(self, stats, root, connections): netloc = self.netloc method = self.method or '' if self.cross_process_id is None: name = 'External/%s/%s/%s' % (netloc, self.library, method) else: name = 'ExternalTransaction/%s/%s/%s' % ( netloc, self.cross_process_id, self.external_txn_name) name = root.string_table.cache(name) start_time = newrelic.core.trace_node.node_start_time(root, self) end_time = newrelic.core.trace_node.node_end_time(root, self) children = [] root.trace_node_count += 1 # Agent attributes self.agent_attributes['http.url'] = self.http_url params = attribute.resolve_agent_attributes( self.agent_attributes, root.settings.attribute_filter, DST_TRANSACTION_SEGMENTS) # User attributes override agent attributes params.update(self.params) # Intrinsic attributes override everything params['exclusive_duration_millis'] = 1000.0 * self.exclusive return newrelic.core.trace_node.TraceNode(start_time=start_time, end_time=end_time, name=name, params=params, children=children, label=None)