Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SentryHttpMessageHandler on MAUI not propagating traces for HttpClient requests #2931

Closed
drowe5 opened this issue Dec 1, 2023 · 4 comments · Fixed by #3360
Closed

SentryHttpMessageHandler on MAUI not propagating traces for HttpClient requests #2931

drowe5 opened this issue Dec 1, 2023 · 4 comments · Fixed by #3360
Assignees
Labels
Bug Something isn't working MAUI

Comments

@drowe5
Copy link

drowe5 commented Dec 1, 2023

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

  1. Create a MAUI app using .NET 7.0 and Sentry.Maui 3.41.3
  2. Configure Sentry as needed in MauiProgram.cs (in CreateMauiApp())
  3. 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.)

@bitsandfoxes
Copy link
Contributor

Thanks for raising this. Let me give this a try.

@bitsandfoxes bitsandfoxes added the Bug Something isn't working label Dec 4, 2023
@bitsandfoxes
Copy link
Contributor

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.

@bitsandfoxes
Copy link
Contributor

Relies on getsentry/sentry-cocoa#3490

@jamescrosswell
Copy link
Collaborator

jamescrosswell commented May 10, 2024

I can reproduce this. It seems to be due to this logic in the SentryHttpMessageHandler:

var span = _hub.GetSpan()?.StartChild(
"http.client",
$"{method} {url}" // e.g. "GET https://example.com"
);

So a span only gets created by SentryHttpMessageHandler if there is already an active transaction set on the scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working MAUI
Projects
Status: Done
Archived in project
3 participants