Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: replace libcurl with .NET HttpClient for sentry-native - #4222

#4222
Merged
jpnurmi merged 13 commits into
maingetsentry/sentry-dotnet:mainfrom
feat/native-transportgetsentry/sentry-dotnet:feat/native-transportCopy head branch name to clipboard
Jun 5, 2025
Merged

feat: replace libcurl with .NET HttpClient for sentry-native#4222
jpnurmi merged 13 commits into
maingetsentry/sentry-dotnet:mainfrom
feat/native-transportgetsentry/sentry-dotnet:feat/native-transportCopy head branch name to clipboard

Conversation

@jpnurmi

@jpnurmi jpnurmi commented May 27, 2025

Copy link
Copy Markdown
Collaborator

Install a custom function transport for sentry-native, and send native envelopes with the .NET HttpClient instead of relying on the default libcurl-based HTTP transport in sentry-native. This way, sentry-native can be built with -DSENTRY_TRANSPORT=none to eliminate the libcurl dependency, which is problematic for minimal/chiseled .NET Native AOT containers.

The behavior remains virtually identical compared to the current native transport with libcurl. The Native AOT integration test that captures a native envelope on restart passes without any changes. The only difference is that native envelopes are sent with .NET HttpClient instead of libcurl. There's no native -> .NET envelope conversion nor hooks being called.

Close: #4116

@jpnurmi
jpnurmi force-pushed the feat/native-transport branch 3 times, most recently from a5dfd32 to 5b8a794 Compare May 29, 2025 20:35
@jpnurmi jpnurmi changed the title poc: use custom transport for sentry-native to eliminate curl poc: use custom HTTP transport for sentry-native to eliminate curl May 30, 2025
@jpnurmi
jpnurmi force-pushed the feat/native-transport branch from 711e47f to 8764d14 Compare June 1, 2025 19:59
@jpnurmi jpnurmi changed the title poc: use custom HTTP transport for sentry-native to eliminate curl feat: replace libcurl with .NET HttpClient for sentry-native Jun 3, 2025
@github-actions

github-actions Bot commented Jun 3, 2025

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against b1f0407

@jpnurmi
jpnurmi force-pushed the feat/native-transport branch from f81841c to 25efbb2 Compare June 3, 2025 07:36
@jpnurmi
jpnurmi marked this pull request as ready for review June 3, 2025 13:17
@jpnurmi
jpnurmi requested a review from bruno-garcia June 3, 2025 13:52
Comment thread src/Sentry/Platforms/Native/CFunctions.cs
Comment thread src/Sentry/Platforms/Native/CFunctions.cs
Comment thread src/Sentry/Platforms/Native/CFunctions.cs Outdated
Comment thread src/Sentry/Platforms/Native/CFunctions.cs
Comment thread src/Sentry/Platforms/Native/UnmanagedHttpContent.cs Outdated
Comment thread src/Sentry/Platforms/Native/UnmanagedHttpContent.cs Outdated
Comment thread src/Sentry/Platforms/Native/UnmanagedHttpContent.cs Outdated
_logger = logger;
}

protected override Task SerializeToStreamAsync(Stream stream, TransportContext? context)

@Flash0ver Flash0ver Jun 3, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: overload

I believe there is also a virtual overload of SerializeToStreamAsync that takes a CancellationToken cancellationToken.
Would we like to override this overload as well, so that we also support asynchronous cancellation?
(And then have this method call into the added method passing CancellationToken.None)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supposedly, it needs some NET5_0_OR_GREATER guards to retain compatibility with older targets. Do you want to do that in this PR, or is that something that could be done in SerializableHttpContent as a separate step?

@Flash0ver Flash0ver Jun 4, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ... right ... our SerializableHttpContent, that means this also applies to EnvelopeHttpContent.

Good call!
Yes. Let's improve that in a follow-up in a separate PR, because EnvelopeHttpContent currently does not support asynchronous cancellation either, for NET5_0_OR_GREATER.

Comment thread src/Sentry/Platforms/Native/UnmanagedHttpContent.cs Outdated
Comment thread src/Sentry/Platforms/Native/UnmanagedHttpContent.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clang error building native AoT application with Sentry.AspNetCore on Linux

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.