Skip to content

Commit 09154fb

Browse files
committed
estimate
1 parent 6a11ba1 commit 09154fb

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

sentry_sdk/_span_batcher.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,18 @@ 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":

sentry_sdk/integrations/httpx.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from sentry_sdk.utils import (
1414
SENSITIVE_DATA_SUBSTITUTE,
1515
capture_internal_exceptions,
16-
ensure_integration_enabled,
1716
logger,
1817
parse_url,
1918
)

0 commit comments

Comments
 (0)