Skip to content

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented May 27, 2025

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
Copy link
Contributor

github-actions bot commented Jun 3, 2025

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
_logger = logger;
}

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

@Flash0ver Flash0ver Jun 3, 2025

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
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?

Copy link
Member

@Flash0ver Flash0ver Jun 4, 2025

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.

@jpnurmi jpnurmi merged commit 723c84e into main Jun 5, 2025
35 checks passed
@jpnurmi jpnurmi deleted the feat/native-transport branch June 5, 2025 07:24
#if NET5_0_OR_GREATER
var response = client.Send(request);
#else
var response = client.SendAsync(request).GetAwaiter().GetResult();
Copy link
Member

Choose a reason for hiding this comment

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

@Flash0ver might want to add a comment here that we only go through this native transport in crashes so we dorm care about blocking and that there's no risk of deadlock since no synchronization context

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry if I was too eager to merge this. I wanted to get rid of the libcurl installation steps for #4247. :)

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

4 participants