@@ -63,7 +63,7 @@ def span_event(self, settings, base_attrs=None, parent_guid=None, attr_class=dic
63
63
i_attrs ["duration" ] = self .duration
64
64
i_attrs ["category" ] = "generic"
65
65
# TODO: limit intrinsic attributes but this likely requires changes in the pipeline.
66
- #if settings.core_tracing .enabled:
66
+ #if settings.distributed_tracing.minimize_attributes .enabled:
67
67
# i_ct_attrs = {"type", "name", "guid", "parentId", "transaction.name", "traceId", "timestamp", "duration", "nr.entryPoint", "transactionId"}
68
68
# i_attrs = {key: value for key, value in i_attrs.items() if key in i_ct_attrs}
69
69
@@ -74,38 +74,49 @@ def span_event(self, settings, base_attrs=None, parent_guid=None, attr_class=dic
74
74
self .agent_attributes , settings .attribute_filter , DST_SPAN_EVENTS , attr_class = attr_class
75
75
)
76
76
u_attrs = self .processed_user_attributes
77
- if settings .core_tracing .enabled :
77
+ if settings .distributed_tracing . unique_spans .enabled :
78
78
# ids is the list of span guids that share this unqiue exit span.
79
- u_attrs = { "ids" : self .ids }
79
+ u_attrs [ "ids" ] = self .ids
80
80
81
81
u_attrs = attribute .resolve_user_attributes (
82
82
u_attrs , settings .attribute_filter , DST_SPAN_EVENTS , attr_class = attr_class
83
83
)
84
84
85
85
start_time = time .time ()
86
- if settings .core_tracing .drop_inprocess_spans or settings .core_tracing .enabled :
86
+ if settings .distributed_tracing .drop_inprocess_spans . enabled or settings .distributed_tracing . unique_spans .enabled :
87
87
exit_span_attrs_present = attribute .SPAN_ENTITY_RELATIONSHIP_ATTRIBUTES & set (a_attrs )
88
+ # If this is the entry node, always return it.
88
89
if self .__class__ .__name__ == "RootNode" :
89
90
ct_processing_time [0 ] += (time .time () - start_time )
90
- return [i_attrs , {}, {}] if settings .core_tracing .enabled else [i_attrs , u_attrs , a_attrs ]
91
+ return [i_attrs , u_attrs , {}] if settings .distributed_tracing .minimize_attributes .enabled else [i_attrs , u_attrs , a_attrs ]
92
+ # If the span is not an exit span, skip it by returning None.
91
93
if not exit_span_attrs_present :
92
94
ct_processing_time [0 ] += (time .time () - start_time )
93
95
return None
94
- if settings .core_tracing .enabled :
95
- a_attrs = attr_class ({key : a_attrs [key ] for key in exit_span_attrs_present })
96
- # TODO: use attr value name rather than str casting.
97
- span_attrs = "" .join ([str (a_attrs [key ]) for key in exit_span_attrs_present ])
96
+ # If the span is an exit span but unique spans is enabled, we need to check
97
+ # for uniqueness before returning it.
98
+ if settings .distributed_tracing .unique_spans .enabled :
99
+ a_minimized_attrs = attr_class ({key : a_attrs [key ] for key in exit_span_attrs_present })
100
+ # Combine all the entity relationship attr values into a string to be
101
+ # used as the hash to check for uniqueness.
102
+ # TODO: use attr value name rather than str casting for infinite tracing.
103
+ span_attrs = "" .join ([str (a_minimized_attrs [key ]) for key in exit_span_attrs_present ])
98
104
new_exit_span = span_attrs not in ct_exit_spans
105
+ # If this is a new exit span, add it to the known ct_exit_spans and return it.
99
106
if new_exit_span :
100
107
ct_exit_spans [span_attrs ] = self .ids
101
- else :
102
- # For now add ids to user attributes list
103
- ct_exit_spans [span_attrs ].append (self .guid )
104
- if new_exit_span :
105
108
ct_processing_time [0 ] += (time .time () - start_time )
106
- return [i_attrs , u_attrs , a_attrs ]
109
+ return [i_attrs , u_attrs , a_minimized_attrs ] if settings .distributed_tracing .minimize_attributes .enabled else [i_attrs , u_attrs , a_attrs ]
110
+ # If this is an exit span we've already seen, add it's guid to the list
111
+ # of ids on the seen span and return None.
112
+ # For now add ids to user attributes list
113
+ ct_exit_spans [span_attrs ].append (self .guid )
107
114
ct_processing_time [0 ] += (time .time () - start_time )
108
115
return None
116
+ elif settings .distributed_tracing .minimize_attributes .enabled :
117
+ # Drop all non-entity relationship attributes from the span.
118
+ exit_span_attrs_present = attribute .SPAN_ENTITY_RELATIONSHIP_ATTRIBUTES & set (a_attrs )
119
+ a_attrs = attr_class ({key : a_attrs [key ] for key in exit_span_attrs_present })
109
120
ct_processing_time [0 ] += (time .time () - start_time )
110
121
return [i_attrs , u_attrs , a_attrs ]
111
122
0 commit comments