Skip to content

Commit

Permalink
feat: Add opportunistic Brotli compression (#3612)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
BYK and sentrivana authored Oct 8, 2024
1 parent 4f79aec commit d34c99a
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 94 deletions.
1 change: 1 addition & 0 deletions requirements-testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ pysocks
socksio
httpcore[http2]
setuptools
Brotli
7 changes: 7 additions & 0 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class EndpointType(Enum):
ENVELOPE = "envelope"


class CompressionAlgo(Enum):
GZIP = "gzip"
BROTLI = "br"


if TYPE_CHECKING:
import sentry_sdk

Expand Down Expand Up @@ -59,6 +64,8 @@ class EndpointType(Enum):
"continuous_profiling_mode": Optional[ContinuousProfilerMode],
"otel_powered_performance": Optional[bool],
"transport_zlib_compression_level": Optional[int],
"transport_compression_level": Optional[int],
"transport_compression_algo": Optional[CompressionAlgo],
"transport_num_pools": Optional[int],
"transport_http2": Optional[bool],
"enable_metrics": Optional[bool],
Expand Down
Loading

0 comments on commit d34c99a

Please sign in to comment.