Skip to content

Commit

Permalink
track zlib
Browse files Browse the repository at this point in the history
  • Loading branch information
aspicer committed Jun 17, 2024
1 parent 81e2b72 commit 8cd1afd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion posthog/caching/tolerant_zlib_compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
""",
)

USING_ZLIB_VALUE_COUNTER = Counter(
"posthog_redis_using_zlib_value_counter",
"""
A counter to track cache keys that are still being decompressed with (deprecated) zlib
""",
)


class TolerantZlibCompressor(BaseCompressor):
"""
Expand All @@ -46,7 +53,9 @@ def decompress(self, value: bytes) -> bytes:
try:
return zstd.decompress(value)
except zstd.Error:
return zlib.decompress(value) # Phasing out zlib, it is 10x slower and compresses worse
r = zlib.decompress(value) # Phasing out zlib, it is 10x slower and compresses worse
USING_ZLIB_VALUE_COUNTER.inc()
return r
except zlib.error:
if settings.USE_REDIS_COMPRESSION:
COULD_NOT_DECOMPRESS_VALUE_COUNTER.inc()
Expand Down

0 comments on commit 8cd1afd

Please sign in to comment.