Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions newrelic/core/external_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,15 @@ def trace_node(self, stats, root, connections):
start_time=start_time, end_time=end_time, name=name, params=params, children=children, label=None
)

def span_event(self, *args, **kwargs):
def span_event(self, settings, base_attrs=None, parent_guid=None, attr_class=dict):
self.agent_attributes["http.url"] = self.http_url
attrs = super().span_event(*args, **kwargs)
i_attrs = attrs[0]

i_attrs = (base_attrs and base_attrs.copy()) or attr_class()
i_attrs["category"] = "http"
i_attrs["span.kind"] = "client"
_, i_attrs["component"] = attribute.process_user_attribute("component", self.library)
i_attrs["component"] = self.library

if self.method:
_, i_attrs["http.method"] = attribute.process_user_attribute("http.method", self.method)
i_attrs["http.method"] = self.method

return attrs
return super().span_event(settings, base_attrs=i_attrs, parent_guid=parent_guid, attr_class=attr_class)
8 changes: 3 additions & 5 deletions newrelic/core/function_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ def trace_node(self, stats, root, connections):
start_time=start_time, end_time=end_time, name=name, params=params, children=children, label=self.label
)

def span_event(self, *args, **kwargs):
attrs = super().span_event(*args, **kwargs)
i_attrs = attrs[0]

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["name"] = f"{self.group}/{self.name}"

return attrs
return super().span_event(settings, base_attrs=i_attrs, parent_guid=parent_guid, attr_class=attr_class)
8 changes: 3 additions & 5 deletions newrelic/core/loop_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ def trace_node(self, stats, root, connections):
start_time=start_time, end_time=end_time, name=name, params=params, children=children, label=None
)

def span_event(self, *args, **kwargs):
attrs = super().span_event(*args, **kwargs)
i_attrs = attrs[0]

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["name"] = f"EventLoop/Wait/{self.name}"

return attrs
return super().span_event(settings, base_attrs=i_attrs, parent_guid=parent_guid, attr_class=attr_class)
25 changes: 12 additions & 13 deletions newrelic/core/node_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def get_trace_segment_params(self, settings, params=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["name"] = i_attrs.get("name") or self.name
i_attrs["guid"] = self.guid
i_attrs["timestamp"] = int(self.start_time * 1000)
i_attrs["duration"] = self.duration
i_attrs["category"] = "generic"
i_attrs["category"] = i_attrs.get("category") or "generic"

if parent_guid:
i_attrs["parentId"] = parent_guid
Expand Down Expand Up @@ -108,37 +108,36 @@ def db_instance(self):
self._db_instance = db_instance_attr
return db_instance_attr

def span_event(self, *args, **kwargs):
self.agent_attributes["db.instance"] = self.db_instance
attrs = super().span_event(*args, **kwargs)
i_attrs = attrs[0]
a_attrs = attrs[2]
def span_event(self, settings, base_attrs=None, parent_guid=None, attr_class=dict):
a_attrs = self.agent_attributes
a_attrs["db.instance"] = self.db_instance
i_attrs = (base_attrs and base_attrs.copy()) or attr_class()

i_attrs["category"] = "datastore"
i_attrs["span.kind"] = "client"

if self.product:
i_attrs["component"] = a_attrs["db.system"] = attribute.process_user_attribute("db.system", self.product)[1]
i_attrs["component"] = a_attrs["db.system"] = self.product
if self.operation:
a_attrs["db.operation"] = attribute.process_user_attribute("db.operation", self.operation)[1]
a_attrs["db.operation"] = self.operation
if self.target:
a_attrs["db.collection"] = attribute.process_user_attribute("db.collection", self.target)[1]
a_attrs["db.collection"] = self.target

if self.instance_hostname:
peer_hostname = attribute.process_user_attribute("peer.hostname", self.instance_hostname)[1]
peer_hostname = self.instance_hostname
else:
peer_hostname = "Unknown"

a_attrs["peer.hostname"] = a_attrs["server.address"] = peer_hostname

peer_address = f"{peer_hostname}:{self.port_path_or_id or 'Unknown'}"

a_attrs["peer.address"] = attribute.process_user_attribute("peer.address", peer_address)[1]
a_attrs["peer.address"] = peer_address

# Attempt to treat port_path_or_id as an integer, fallback to not including it
try:
a_attrs["server.port"] = int(self.port_path_or_id)
except Exception:
pass

return attrs
return super().span_event(settings, base_attrs=i_attrs, parent_guid=parent_guid, attr_class=attr_class)
8 changes: 4 additions & 4 deletions newrelic/core/root_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@


class RootNode(_RootNode, GenericNodeMixin):
def span_event(self, *args, **kwargs):
span = super().span_event(*args, **kwargs)
i_attrs = span[0]
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["transaction.name"] = self.path
i_attrs["nr.entryPoint"] = True
if self.trusted_parent_span:
i_attrs["trustedParentId"] = self.trusted_parent_span
if self.tracing_vendors:
i_attrs["tracingVendors"] = self.tracing_vendors
return span

return super().span_event(settings, base_attrs=i_attrs, parent_guid=parent_guid, attr_class=attr_class)

def trace_node(self, stats, root, connections):
name = self.path
Expand Down
Loading