@@ -62,9 +62,10 @@ def span_event(self, settings, base_attrs=None, parent_guid=None, attr_class=dic
62
62
i_attrs ["timestamp" ] = int (self .start_time * 1000 )
63
63
i_attrs ["duration" ] = self .duration
64
64
i_attrs ["category" ] = "generic"
65
+ # TODO: limit intrinsic attributes but this likely requires changes in the pipeline.
65
66
#if settings.core_tracing.enabled:
66
- # i_ct_attrs = {"type", "name", "guid", "parentId", "transaction.name", "traceId", "nr.entryPoint", "transactionId"}
67
- # i_attrs = {key: value for key, value in i_attrs.items() if key in i_ct_attrs}
67
+ # i_ct_attrs = {"type", "name", "guid", "parentId", "transaction.name", "traceId", "timestamp", "duration ", "nr.entryPoint", "transactionId"}
68
+ # i_attrs = {key: value for key, value in i_attrs.items() if key in i_ct_attrs}
68
69
69
70
if parent_guid :
70
71
i_attrs ["parentId" ] = parent_guid
@@ -81,32 +82,40 @@ def span_event(self, settings, base_attrs=None, parent_guid=None, attr_class=dic
81
82
u_attrs , settings .attribute_filter , DST_SPAN_EVENTS , attr_class = attr_class
82
83
)
83
84
85
+ start_time = time .time ()
84
86
if settings .core_tracing .drop_inprocess_spans or settings .core_tracing .enabled :
85
87
exit_span_attrs_present = attribute .SPAN_ENTITY_RELATIONSHIP_ATTRIBUTES & set (a_attrs )
86
88
if self .__class__ .__name__ == "RootNode" :
87
- return [i_attrs , u_attrs , a_attrs ]
89
+ if settings .core_tracing .enabled :
90
+ ct_processing_time [0 ] += (time .time () - start_time )
91
+ return [i_attrs , {}, {}]
92
+ else :
93
+ ct_processing_time [0 ] += (time .time () - start_time )
94
+ return [i_attrs , u_attrs , a_attrs ]
88
95
if not exit_span_attrs_present :
96
+ ct_processing_time [0 ] += (time .time () - start_time )
89
97
return None
90
- if settings .core_tracing .enabled :
91
- start_time = time .time ()
92
- # TODO: use attr value name rather than str casting.
93
- span_attrs = "" .join ([str (a_attrs [key ]) for key in exit_span_attrs_present ])
94
- new_exit_span = span_attrs not in ct_exit_spans
95
- if new_exit_span :
96
- ct_exit_spans [span_attrs ] = self .ids
97
- else :
98
- # For now add ids to user attributes list
99
- ct_exit_spans [span_attrs ].append (self .guid )
100
- ct_processing_time += (time .time () - start_time )
101
- if new_exit_span :
102
- return [i_attrs , u_attrs , a_attrs ]
103
- return None
98
+ if settings .core_tracing .enabled :
99
+ a_attrs = attr_class ({key : a_attrs [key ] for key in exit_span_attrs_present })
100
+ # TODO: use attr value name rather than str casting.
101
+ span_attrs = "" .join ([str (a_attrs [key ]) for key in exit_span_attrs_present ])
102
+ new_exit_span = span_attrs not in ct_exit_spans
103
+ if new_exit_span :
104
+ ct_exit_spans [span_attrs ] = self .ids
105
+ else :
106
+ # For now add ids to user attributes list
107
+ ct_exit_spans [span_attrs ].append (self .guid )
108
+ if new_exit_span :
109
+ ct_processing_time [0 ] += (time .time () - start_time )
110
+ return [i_attrs , u_attrs , a_attrs ]
111
+ ct_processing_time [0 ] += (time .time () - start_time )
112
+ return None
113
+ ct_processing_time [0 ] += (time .time () - start_time )
104
114
return [i_attrs , u_attrs , a_attrs ]
105
115
106
- def span_events (self , settings , base_attrs = None , parent_guid = None , attr_class = dict , ct_exit_spans = None , ct_processing_time = 0 ):
116
+ def span_events (self , settings , base_attrs = None , parent_guid = None , attr_class = dict , ct_exit_spans = None , ct_processing_time = None ):
107
117
if settings .core_tracing .drop_inprocess_spans or settings .core_tracing .enabled :
108
118
span = self .span_event (settings , base_attrs = base_attrs , parent_guid = parent_guid , attr_class = attr_class , ct_exit_spans = ct_exit_spans , ct_processing_time = ct_processing_time )
109
- start_time = time .time ()
110
119
parent_id = parent_guid
111
120
if span : # span will be None if the span is an inprocess span or repeated exit span.
112
121
yield span
@@ -118,11 +127,12 @@ def span_events(self, settings, base_attrs=None, parent_guid=None, attr_class=di
118
127
if event : # event will be None if the span is an inprocess span or repeated exit span.
119
128
yield event
120
129
else :
121
- yield self .span_event (settings , base_attrs = base_attrs , parent_guid = parent_guid , attr_class = attr_class )
130
+ span = self .span_event (settings , base_attrs = base_attrs , parent_guid = parent_guid , attr_class = attr_class , ct_processing_time = ct_processing_time )
131
+ yield span
122
132
123
133
for child in self .children :
124
134
for event in child .span_events ( # noqa: UP028
125
- settings , base_attrs = base_attrs , parent_guid = self .guid , attr_class = attr_class
135
+ settings , base_attrs = base_attrs , parent_guid = self .guid , attr_class = attr_class , ct_processing_time = ct_processing_time
126
136
):
127
137
yield event
128
138
0 commit comments