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

Fixed: SentryHttpMessageHandler added when AddHttpClient is before UseSentry #2390

Merged
merged 3 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## Unreleased

## Fixes
### Fixes

- SentryHttpMessageHandler added when AddHttpClient is before UseSentry ([#2390](https://github.com/getsentry/sentry-dotnet/pull/2390))
- Set the native sdk name for Android ([#2389](https://github.com/getsentry/sentry-dotnet/pull/2389))

## 3.33.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public static IServiceCollection AddSentry<TOptions>(this IServiceCollection ser

// Custom handler for HttpClientFactory.
// Must be singleton: https://github.com/getsentry/sentry-dotnet/issues/785
services.TryAddSingleton<IHttpMessageHandlerBuilderFilter, SentryHttpMessageHandlerBuilderFilter>();
// Must use AddSingleton: https://github.com/getsentry/sentry-dotnet/issues/2373
services.AddSingleton<IHttpMessageHandlerBuilderFilter, SentryHttpMessageHandlerBuilderFilter>();

return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ public Action<HttpMessageHandlerBuilder> Configure(Action<HttpMessageHandlerBuil
handlerBuilder =>
{
var hub = _getHub();
handlerBuilder.AdditionalHandlers.Add(new SentryHttpMessageHandler(hub));
if (!handlerBuilder.AdditionalHandlers.Any(h => h is SentryHttpMessageHandler))
{
handlerBuilder.AdditionalHandlers.Add(
new SentryHttpMessageHandler(hub)
);
}

next(handlerBuilder);
};
}