Skip to content

Commit

Permalink
chore: remove remaining obsolete functionality (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnmoreels authored Nov 20, 2023
1 parent d209bce commit 99fca98
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,6 @@ namespace Microsoft.Extensions.Logging
// ReSharper disable once InconsistentNaming
public static class ILoggingBuilderExtensions
{
/// <summary>
/// Clears the <see cref="ILoggerProvider"/> registrations from the given <paramref name="loggingBuilder"/>,
/// except the specific Azure Functions registrations.
/// </summary>
/// <param name="loggingBuilder">The builder containing the <see cref="ILoggerProvider"/> registrations.</param>
[Obsolete("Calling this method causes issues with correctly writing log-information to Application Insights. It is advised to no longer use it.")]
public static ILoggingBuilder ClearProvidersExceptFunctionProviders(this ILoggingBuilder loggingBuilder)
{
Guard.NotNull(loggingBuilder, nameof(loggingBuilder));

// Kudos to katrash: https://stackoverflow.com/questions/45986517/remove-console-and-debug-loggers-in-asp-net-core-2-0-when-in-production-mode
foreach (ServiceDescriptor serviceDescriptor in loggingBuilder.Services)
{
if (serviceDescriptor.ServiceType == typeof(ILoggerProvider))
{
if (serviceDescriptor.ImplementationType.FullName != "Microsoft.Azure.WebJobs.Script.Diagnostics.HostFileLoggerProvider"
&& serviceDescriptor.ImplementationType.FullName != "Microsoft.Azure.WebJobs.Script.Diagnostics.FunctionFileLoggerProvider")
{
loggingBuilder.Services.Remove(serviceDescriptor);
break;
}
}
}

return loggingBuilder;
}

/// <summary>
/// Removes Microsoft's 'ApplicationInsightsLoggerProvider' type from the registered logging providers
/// so that Arcus' Serilog Application Insights sink is the only one place telemetry is created and sent to Microsoft Application Insights.
Expand Down
61 changes: 0 additions & 61 deletions src/Arcus.Observability.Telemetry.Core/DependencyMeasurement.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using Arcus.Observability.Tests.Unit.Telemetry.AzureFunctions.Fixture;
using Microsoft.Azure.WebJobs.Script.Diagnostics;
using Arcus.Observability.Tests.Unit.Telemetry.AzureFunctions.Fixture;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Microsoft.Extensions.Logging;
using Xunit;

Expand All @@ -11,26 +8,6 @@ namespace Arcus.Observability.Tests.Unit.Telemetry.AzureFunctions
// ReSharper disable once InconsistentNaming
public class ILoggerBuilderExtensionsTests
{
[Fact]
public void ClearProvidersExceptFunctions_WithLoggerBuilderContainingProviders_RemovesNonFunctionProviders()
{
// Arrange
var services = new ServiceCollection();
services.AddSingleton<ILoggerProvider, HostFileLoggerProvider>();
services.AddSingleton<ILoggerProvider, FunctionFileLoggerProvider>();
services.AddSingleton<ILoggerProvider, TestLoggerProvider>();
var builder = new Mock<ILoggingBuilder>();
builder.Setup(b => b.Services).Returns(services);

// Act
builder.Object.ClearProvidersExceptFunctionProviders();

// Assert
Assert.NotEmpty(services);
Assert.Equal(2, services.Count);
Assert.All(services, desc => Assert.NotEqual(typeof(TestLoggerProvider), desc.ImplementationType));
}

[Fact]
public void RemoveMicrosoftApplicationInsightsLoggerProvider_WithLoggerBuilderContainingProvider_RemovesProvider()
{
Expand Down

This file was deleted.

0 comments on commit 99fca98

Please sign in to comment.