Compress envelopes with Zstandard on .NET 11

Open
#5,914 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Active
Tech stack
csharp

Research direction

Start with GzipRequestBodyHandler, GzipBufferedRequestBodyHandler, DefaultSentryHttpClientFactory, and the RequestBodyCompressionLevel option; inspect how options are bound through BindableSentryOptions. Then review the .NET 11 compression APIs and the issue’s open questions about opt-in selection, older target frameworks, and mobile performance. Done means choosing and implementing the option and target framework behavior, with measurements informing any default.

Written by the indexing model from the issue text.

Description

Improvement State: Needs Discussion

On net11.0, envelopes could be compressed with Zstandard instead of gzip. Smaller envelopes matter most on Android and iOS, which also target net11.0 on version7.

Current state

We compress request bodies by hand with GZipStream, in GzipRequestBodyHandler and GzipBufferedRequestBodyHandler. DefaultSentryHttpClientFactory picks one when RequestBodyCompressionLevel isn't NoCompression.

What .NET 11 adds

System.Net.Http now has GZipCompressedContent, BrotliCompressedContent and ZstandardCompressedContent. They set Content-Encoding and compress the content as the request is written. ZstandardStream and ZstandardEncoder live in System.IO.Compression. All five are in the 11.0.0 GA reference pack.

See What's new in the .NET 11 libraries.

Server support

Relay has accepted Content-Encoding: zstd since getsentry/relay#4089. However, Relay rejects encodings it doesn't recognise, so a self-hosted Sentry running an older Relay would drop zstd envelopes. Zstd should therefore be opt-in, not the new default.

Open questions

  • How should users choose the algorithm? One option is a new option next to RequestBodyCompressionLevel, which also needs a matching BindableSentryOptions property.
  • Should the net11.0 gzip path also move to GZipCompressedContent? The existing handlers have to stay for older TFMs either way, so this adds a #if NET11_0_OR_GREATER path rather than removing code.
  • How much smaller are typical envelopes with zstd than with gzip, and what does it cost in CPU on mobile? Measure before choosing defaults.
Dominant language
C#
Stars
775
Forks
262
Avg merge
1d 16h
Merged PRs (30d)
118

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-dotnet

All issues in getsentry/sentry-dotnet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.