Skip to content

Commit

Permalink
Removed deprecated .AddHttpCorrelation
Browse files Browse the repository at this point in the history
  • Loading branch information
Roeland Lutters authored and Roeland Lutters committed Mar 2, 2023
1 parent 1172409 commit 864461c
Showing 1 changed file with 0 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,6 @@ public static IServiceCollection AddHttpCorrelation(this IServiceCollection serv
return AddHttpCorrelation(services, configureOptions: (HttpCorrelationInfoOptions options) => { });
}

/// <summary>
/// Adds operation and transaction correlation to the application.
/// </summary>
/// <param name="services">The services collection containing the dependency injection services.</param>
/// <param name="configureOptions">The function to configure additional options how the correlation works.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="services"/> is <c>null</c>.</exception>
[Obsolete("Use the " + nameof(AddHttpCorrelation) + " method overload with the " + nameof(HttpCorrelationInfoOptions) + " instead")]
public static IServiceCollection AddHttpCorrelation(
this IServiceCollection services,
Action<CorrelationInfoOptions> configureOptions)
{
Guard.NotNull(services, nameof(services), "Requires a services collection to add the HTTP correlation services");

services.AddHttpContextAccessor();
services.AddCorrelation(
serviceProvider => (HttpCorrelationInfoAccessor) serviceProvider.GetRequiredService<IHttpCorrelationInfoAccessor>(),
configureOptions);
services.AddSingleton<IHttpCorrelationInfoAccessor>(serviceProvider =>
{
var httpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
return new HttpCorrelationInfoAccessor(httpContextAccessor);
});
services.AddSingleton(serviceProvider =>
{
var options = serviceProvider.GetRequiredService<IOptions<CorrelationInfoOptions>>();
var httpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
var correlationInfoAccessor = serviceProvider.GetRequiredService<IHttpCorrelationInfoAccessor>();
var logger = serviceProvider.GetService<ILogger<HttpCorrelation>>();

return new HttpCorrelation(options, httpContextAccessor, correlationInfoAccessor, logger);
});

return services;
}

/// <summary>
/// Adds operation and transaction correlation to the application.
/// </summary>
Expand Down

0 comments on commit 864461c

Please sign in to comment.