Skip to content

Commit d34c99a

Browse files
BYKsentrivana
andauthored
feat: Add opportunistic Brotli compression (#3612)
Brotli level 4 and 5 offer comparable or better compression to GZip level 9 (which is our default) with better performance. This patch adds opportunistic Brotli compression at level 4 (to be conservative) when it detects the `brotli` module is available. It also provides some escape hatches through `transport_compression_level` and `transport_compression_algo` experiment configs to fine tune the behavior. In the future, we may want to bump the default level from 4 to 5 for better compression. --------- Co-authored-by: Ivana Kellyer <[email protected]>
1 parent 4f79aec commit d34c99a

File tree

5 files changed

+167
-94
lines changed

5 files changed

+167
-94
lines changed

Diff for: requirements-testing.txt

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ pysocks
1313
socksio
1414
httpcore[http2]
1515
setuptools
16+
Brotli

Diff for: sentry_sdk/consts.py

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class EndpointType(Enum):
1818
ENVELOPE = "envelope"
1919

2020

21+
class CompressionAlgo(Enum):
22+
GZIP = "gzip"
23+
BROTLI = "br"
24+
25+
2126
if TYPE_CHECKING:
2227
import sentry_sdk
2328

@@ -59,6 +64,8 @@ class EndpointType(Enum):
5964
"continuous_profiling_mode": Optional[ContinuousProfilerMode],
6065
"otel_powered_performance": Optional[bool],
6166
"transport_zlib_compression_level": Optional[int],
67+
"transport_compression_level": Optional[int],
68+
"transport_compression_algo": Optional[CompressionAlgo],
6269
"transport_num_pools": Optional[int],
6370
"transport_http2": Optional[bool],
6471
"enable_metrics": Optional[bool],

0 commit comments

Comments
 (0)