sentry-dotnet
sentry-dotnet copied to clipboard
SentryHttpMessageHandler on MAUI not propagating traces for HttpClient requests
Package
Sentry.Maui
.NET Flavor
.NET
.NET Version
7.0.49
OS
iOS
SDK Version
3.41.3
Self-Hosted Sentry Version
No response
Steps to Reproduce
- Create a MAUI app using .NET 7.0 and Sentry.Maui 3.41.3
- Configure Sentry as needed in MauiProgram.cs (in CreateMauiApp())
- Write a function as described on the Automatic Instrumentation page
var httpHandler = new SentryHttpMessageHandler();
var httpClient = new HttpClient(httpHandler);
var response = await httpClient.GetStringAsync("https://example.com");
4.Run the application in iOS Simulator on Mac (M1) running Sonoma 14.0
Expected Result
The transaction will show up in the on the web (presumably under either Performance or Discover) sections.
Actual Result
Transaction is not visible anywhere on the web (though other manually created Transactions as described in Custom Instrumentation do appear as expected.)
Thanks for raising this. Let me give this a try.
Sorry for the delay but I can reproduce this locally. Interestingly, the SDK does set the traceheader as expected but I suspect the underlying native SDK is overwriting it.
Relies on https://github.com/getsentry/sentry-cocoa/issues/3490
I can reproduce this. It seems to be due to this logic in the SentryHttpMessageHandler
:
https://github.com/getsentry/sentry-dotnet/blob/043cb5f8b5e177bbc0b644e1706d2e8c7360488a/src/Sentry/SentryHttpMessageHandler.cs#L66-L69
So a span only gets created by SentryHttpMessageHandler
if there is already an active transaction set on the scope.