Skip to content
New issue

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

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

Already on GitHub? # to your account

chore: remove remaining obsolete functionality #557

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
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.