File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -91,13 +91,21 @@ def add(self, span: "StreamedSpan") -> None:
9191 @staticmethod
9292 def _estimate_size (item : "StreamedSpan" ) -> int :
9393 # Rough estimate of serialized span size that's quick to compute.
94- # 210 is the rough size of the payload without attributes, and we
95- # estimate additional 70 bytes on top of that per attribute.
96- return 210 + 70 * len (item ._attributes )
94+ # 210 is the rough size of the payload without attributes, and then we
95+ # estimate the attributes separately.
96+ estimate = 210
97+ for value in item ._attributes .values ():
98+ estimate += 7
99+
100+ if isinstance (value , str ):
101+ estimate += len (value )
102+ else :
103+ estimate += len (str (value ))
104+
105+ return estimate
97106
98107 @staticmethod
99108 def _to_transport_format (item : "StreamedSpan" ) -> "Any" :
100- # TODO[span-first]
101109 res : "dict[str, Any]" = {
102110 "trace_id" : item .trace_id ,
103111 "span_id" : item .span_id ,
@@ -126,7 +134,7 @@ def _flush(self) -> None:
126134 return
127135
128136 envelopes = []
129- for trace_id , spans in self ._span_buffer .items ():
137+ for spans in self ._span_buffer .values ():
130138 if spans :
131139 dsc = spans [0 ]._dynamic_sampling_context ()
132140
You can’t perform that action at this time.
0 commit comments