From d363c0f17aeaed8ebe0ab8b4f37e0d2f6f488a95 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 11:34:24 +0100 Subject: [PATCH 01/21] Deprecation message for logger --- src/Hosting.Services/HostBuilderExtensions.cs | 8 +++++++- .../Certificates/InitializationCertificateReader.cs | 2 ++ src/Hosting/ServiceCollectionExtensions.cs | 3 +++ src/Logging/InitializationLogger.cs | 3 ++- src/Logging/Internal/OmexLoggerProvider.cs | 2 ++ src/Logging/ServiceCollectionExtensions.cs | 13 +++++++++++-- .../HostBuilderExtensionsTests.cs | 2 ++ .../Hosting.UnitTests/HostBuilderExtensionsTests.cs | 1 + tests/Logging.UnitTests/OmexLogEventSenderTests.cs | 1 + tests/Logging.UnitTests/OmexLoggerProviderTests.cs | 1 + .../Scrubbing/ServiceCollectionExtensionsTests.cs | 2 ++ tests/Logging.UnitTests/ServiceCollectionTests.cs | 11 +++++++++-- 12 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index f568e86d4..4585c3af1 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -41,6 +41,7 @@ public static IHost BuildStatefulService( /// /// Registering Dependency Injection classes that will provide Service Fabric specific information for logging /// + [Obsolete($"This method also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598")] public static IServiceCollection AddOmexServiceFabricDependencies(this IServiceCollection collection) where TContext : ServiceContext { @@ -87,12 +88,14 @@ private static IHost BuildServiceFabricService( IHost host = builder .ConfigureServices((context, collection) => { +#pragma warning disable CS0618 // Type or member is obsolete collection .Configure(options => { options.ServiceTypeName = serviceName; }) .AddOmexServiceFabricDependencies() +#pragma warning restore CS0618 // Type or member is obsolete .AddSingleton() .AddHostedService(); }) @@ -101,16 +104,19 @@ private static IHost BuildServiceFabricService( options.ValidateOnBuild = true; options.ValidateScopes = true; }) - .ConfigureLogging(builder => builder.AddOmexLogging()) .Build(); +#pragma warning disable CS0618 // InitializationLogger using OmexLogger is obsolete. Code: 8913598 InitializationLogger.LogInitializationSucceed(serviceNameForLogging); +#pragma warning restore CS0618 // InitializationLogger using OmexLogger is obsolete. Code: 8913598 return host; } catch (Exception e) { +#pragma warning disable CS0618 // InitializationLogger is obsolete. Code: 8913598 InitializationLogger.LogInitializationFail(serviceNameForLogging, e); +#pragma warning restore CS0618 // InitializationLogger is obsolete. Code: 8913598 throw; } } diff --git a/src/Hosting/Certificates/InitializationCertificateReader.cs b/src/Hosting/Certificates/InitializationCertificateReader.cs index ffb403002..af37eec97 100644 --- a/src/Hosting/Certificates/InitializationCertificateReader.cs +++ b/src/Hosting/Certificates/InitializationCertificateReader.cs @@ -16,6 +16,8 @@ public static class InitializationCertificateReader /// /// Instance of CertificateReader /// +#pragma warning disable CS0618 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. Code: 8913598 public static ICertificateReader Instance { get; } = new CertificateReader(new CertificateStore(), InitializationLogger.Instance); +#pragma warning restore CS0618 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. Code: 8913598 } } diff --git a/src/Hosting/ServiceCollectionExtensions.cs b/src/Hosting/ServiceCollectionExtensions.cs index 44e1d8cb2..450b29f0a 100644 --- a/src/Hosting/ServiceCollectionExtensions.cs +++ b/src/Hosting/ServiceCollectionExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; @@ -17,6 +18,7 @@ public static class ServiceCollectionExtensions /// /// Add Omex Logging and ActivitySource dependencies /// + [Obsolete($"Please do not use {nameof(AddOmexServices)} if you just want to use Legacy OmexLogger and ActivityEventSender because they are deprecated. Consider using a different telemetry solution. This method is pending for removal by 1 July 2024. Code: 8913598.")] public static IHostBuilder AddOmexServices(this IHostBuilder builder) => builder .ConfigureServices((context, collection) => collection.AddOmexServices()); @@ -24,6 +26,7 @@ public static IHostBuilder AddOmexServices(this IHostBuilder builder) => /// /// Add Omex Logging and ActivitySource dependencies /// + [Obsolete($"Please do not use {nameof(AddOmexServices)} if you just want to use Legacy OmexLogger and ActivityEventSender because they are deprecated. Consider using a different telemetry solution. This method is pending for removal by 1 July 2024. Code: 8913598.")] public static IServiceCollection AddOmexServices(this IServiceCollection collection) => collection .AddOmexLogging() diff --git a/src/Logging/InitializationLogger.cs b/src/Logging/InitializationLogger.cs index 5f82e8dc4..86cc0508e 100644 --- a/src/Logging/InitializationLogger.cs +++ b/src/Logging/InitializationLogger.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System; -using System.Diagnostics; using Microsoft.Extensions.Logging; using Microsoft.Omex.Extensions.Abstractions; @@ -12,6 +11,7 @@ namespace Microsoft.Omex.Extensions.Logging /// InitializationLogger is the logger to be used before the proper ILogger from DI is set. /// Not to be used as main logger. /// + [Obsolete($"{nameof(InitializationLogger)} using {nameof(OmexLogger)} is obsolete and is pending for removal by 1 July 2024. Code: 8913598.")] public static class InitializationLogger { /// @@ -56,6 +56,7 @@ public static void LogInitializationSucceed(string serviceNameForLogging, string /// Service name for logging /// Exception to log /// Message to log + [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. Code: 8913598.")] public static void LogInitializationFail(string serviceNameForLogging, Exception? ex = null, string message = "") { ServiceInitializationEventSource.Instance.LogHostFailed(ex?.ToString() ?? string.Empty, serviceNameForLogging, message); diff --git a/src/Logging/Internal/OmexLoggerProvider.cs b/src/Logging/Internal/OmexLoggerProvider.cs index 17190655b..044aaec6b 100644 --- a/src/Logging/Internal/OmexLoggerProvider.cs +++ b/src/Logging/Internal/OmexLoggerProvider.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Collections.Generic; using Microsoft.Extensions.Logging; using Microsoft.Omex.Extensions.Logging.Replayable; @@ -9,6 +10,7 @@ namespace Microsoft.Omex.Extensions.Logging { [ProviderAlias("Omex")] + [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different logging solution. Code: 8913598.")] internal class OmexLoggerProvider : ILoggerProvider, ISupportExternalScope { public OmexLoggerProvider( diff --git a/src/Logging/ServiceCollectionExtensions.cs b/src/Logging/ServiceCollectionExtensions.cs index 1543ee39a..960fda972 100644 --- a/src/Logging/ServiceCollectionExtensions.cs +++ b/src/Logging/ServiceCollectionExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; @@ -30,6 +31,7 @@ public static IServiceCollection AddOmexServiceContext(this ISe /// Adds Omex event logger to the factory /// /// The extension method argument + [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger. Code: 8913598.")] public static ILoggingBuilder AddOmexLogging(this ILoggingBuilder builder) { builder.AddConfiguration(); @@ -42,6 +44,7 @@ public static ILoggingBuilder AddOmexLogging(this ILoggingBuilder builder) /// /// The extension method argument /// The so that additional calls can be chained + [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger. Code: 8913598.")] public static IServiceCollection AddOmexLogging(this IServiceCollection serviceCollection) { serviceCollection.AddLogging(); @@ -50,14 +53,20 @@ public static IServiceCollection AddOmexLogging(this IServiceCollection serviceC serviceCollection.TryAddTransient(); serviceCollection.TryAddTransient(); + AddOmexLegacyLogging(serviceCollection); + + return serviceCollection; + } + + [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger. Code: 8913598.")] + private static void AddOmexLegacyLogging(IServiceCollection serviceCollection) + { serviceCollection.TryAddSingleton(_ => OmexLogEventSource.Instance); serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(); serviceCollection.TryAddEnumerable(ServiceDescriptor.Transient()); serviceCollection.TryAddEnumerable(ServiceDescriptor.Singleton()); - - return serviceCollection; } } } diff --git a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs index 25b608e04..761749dd0 100644 --- a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs +++ b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs @@ -29,8 +29,10 @@ public void AddOmexServiceFabricDependencies_TypesRegistered(Type typeToResolve, { void CheckTypeRegistration() where TContext : ServiceContext { +#pragma warning disable CS0618 // Type or member is obsolete object? obj = new ServiceCollection() .AddOmexServiceFabricDependencies() +#pragma warning restore CS0618 // Type or member is obsolete .AddSingleton(new Mock().Object) .BuildServiceProvider() .GetService(typeToResolve); diff --git a/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs index 005af3e48..a9175e1c5 100644 --- a/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs +++ b/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs @@ -19,6 +19,7 @@ public class HostBuilderExtensionsTests [DataTestMethod] [DataRow(typeof(ILogger))] [DataRow(typeof(ActivitySource))] + [Obsolete("Obsolete")] public void AddOmexServices_TypesRegistered(Type type) { object? collectionObj = new ServiceCollection() diff --git a/tests/Logging.UnitTests/OmexLogEventSenderTests.cs b/tests/Logging.UnitTests/OmexLogEventSenderTests.cs index f5fd44ca6..d980bab42 100644 --- a/tests/Logging.UnitTests/OmexLogEventSenderTests.cs +++ b/tests/Logging.UnitTests/OmexLogEventSenderTests.cs @@ -15,6 +15,7 @@ namespace Microsoft.Omex.Extensions.Logging.UnitTests { + [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. Code: 8913598.")] [TestClass] public class OmexLogEventSenderTests { diff --git a/tests/Logging.UnitTests/OmexLoggerProviderTests.cs b/tests/Logging.UnitTests/OmexLoggerProviderTests.cs index c1326fe07..d88f2e718 100644 --- a/tests/Logging.UnitTests/OmexLoggerProviderTests.cs +++ b/tests/Logging.UnitTests/OmexLoggerProviderTests.cs @@ -11,6 +11,7 @@ namespace Microsoft.Omex.Extensions.Logging.UnitTests { [TestClass] + [Obsolete] public class OmexLoggerProviderTests { [TestMethod] diff --git a/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs b/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs index 0f622ef52..f9c110645 100644 --- a/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs +++ b/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs @@ -142,8 +142,10 @@ public void AddRegexLogScrubbingRule_Scrubs(string input, string expected) private static ILogScrubbingRule[] GetTypeRegistrations(IServiceCollection collection) { +#pragma warning disable CS0618 // Type or member is obsolete IEnumerable objects = collection .AddOmexLogging() +#pragma warning restore CS0618 // Type or member is obsolete .BuildServiceProvider(new ServiceProviderOptions { ValidateOnBuild = true, diff --git a/tests/Logging.UnitTests/ServiceCollectionTests.cs b/tests/Logging.UnitTests/ServiceCollectionTests.cs index d5cb96989..0ebb14b4e 100644 --- a/tests/Logging.UnitTests/ServiceCollectionTests.cs +++ b/tests/Logging.UnitTests/ServiceCollectionTests.cs @@ -24,8 +24,11 @@ public void AddOmexServiceContext_RegisterServiceContext() public void AddOmexServiceContext_OverridesContextType() { IServiceCollection collection = new ServiceCollection() - .AddOmexServiceContext() - .AddOmexLogging(); + .AddOmexServiceContext(); + +#pragma warning disable CS0618 // Type or member is obsolete + collection.AddOmexLogging(); +#pragma warning restore CS0618 // Type or member is obsolete IServiceContext context = ValidateTypeRegistration(collection); @@ -35,6 +38,7 @@ public void AddOmexServiceContext_OverridesContextType() } [TestMethod] + [Obsolete] public void AddOmexLoggerOnServiceCollection_RegistersLogger() { IServiceCollection collection = new ServiceCollection().AddOmexLogging(); @@ -42,6 +46,7 @@ public void AddOmexLoggerOnServiceCollection_RegistersLogger() } [TestMethod] + [Obsolete] public void AddOmexLoggerOnLogBuilder_RegistersLogger() { ILoggingBuilder builder = new MockLoggingBuilder().AddOmexLogging(); @@ -51,8 +56,10 @@ public void AddOmexLoggerOnLogBuilder_RegistersLogger() private T ValidateTypeRegistration(IServiceCollection collection) where T : class { +#pragma warning disable CS0618 // Type or member is obsolete T obj = collection .AddOmexLogging() +#pragma warning restore CS0618 // Type or member is obsolete .BuildServiceProvider(new ServiceProviderOptions { ValidateOnBuild = true, From 1311c88732e03e17108f6dd169b30183f10733c8 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 12:11:35 +0100 Subject: [PATCH 02/21] Update commit --- .../Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs | 4 ++-- tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs | 2 +- tests/Logging.UnitTests/OmexLoggerProviderTests.cs | 2 +- .../Scrubbing/ServiceCollectionExtensionsTests.cs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs index 761749dd0..0e79b9b8a 100644 --- a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs +++ b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs @@ -29,10 +29,10 @@ public void AddOmexServiceFabricDependencies_TypesRegistered(Type typeToResolve, { void CheckTypeRegistration() where TContext : ServiceContext { -#pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 object? obj = new ServiceCollection() .AddOmexServiceFabricDependencies() -#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 .AddSingleton(new Mock().Object) .BuildServiceProvider() .GetService(typeToResolve); diff --git a/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs index a9175e1c5..dc2e571e1 100644 --- a/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs +++ b/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs @@ -19,7 +19,7 @@ public class HostBuilderExtensionsTests [DataTestMethod] [DataRow(typeof(ILogger))] [DataRow(typeof(ActivitySource))] - [Obsolete("Obsolete")] + [Obsolete("AddOmexServices is Obsolete and pending for removal on 1 July 2024. Code: 8913598.")] public void AddOmexServices_TypesRegistered(Type type) { object? collectionObj = new ServiceCollection() diff --git a/tests/Logging.UnitTests/OmexLoggerProviderTests.cs b/tests/Logging.UnitTests/OmexLoggerProviderTests.cs index d88f2e718..56d51d1d5 100644 --- a/tests/Logging.UnitTests/OmexLoggerProviderTests.cs +++ b/tests/Logging.UnitTests/OmexLoggerProviderTests.cs @@ -11,7 +11,7 @@ namespace Microsoft.Omex.Extensions.Logging.UnitTests { [TestClass] - [Obsolete] + [Obsolete("OmexLogger is Obsolete and pending for removal on 1 July 2024. Code: 8913598.")] public class OmexLoggerProviderTests { [TestMethod] diff --git a/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs b/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs index f9c110645..5271ea4ce 100644 --- a/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs +++ b/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs @@ -142,10 +142,10 @@ public void AddRegexLogScrubbingRule_Scrubs(string input, string expected) private static ILogScrubbingRule[] GetTypeRegistrations(IServiceCollection collection) { -#pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0618 // AddOmexLogging uses OmexLogger and OmexLogEventSource which are obsolete and pending for removal by 1 July 2024. Code: 8913598. IEnumerable objects = collection .AddOmexLogging() -#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0618 // AddOmexLogging uses OmexLogger and OmexLogEventSource which are obsolete and pending for removal by 1 July 2024. Code: 8913598. .BuildServiceProvider(new ServiceProviderOptions { ValidateOnBuild = true, From 3542d79f5c209f2cb4fe58db69f1f498c9829937 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 12:52:41 +0100 Subject: [PATCH 03/21] Update --- src/Hosting.Services/HostBuilderExtensions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index 4585c3af1..cbf8252a2 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -114,9 +114,10 @@ private static IHost BuildServiceFabricService( } catch (Exception e) { -#pragma warning disable CS0618 // InitializationLogger is obsolete. Code: 8913598 +#pragma warning disable CS0618 // InitializationLogger using OmexLogger is obsolete. Code: 8913598 InitializationLogger.LogInitializationFail(serviceNameForLogging, e); -#pragma warning restore CS0618 // InitializationLogger is obsolete. Code: 8913598 +#pragma warning restore CS0618 // InitializationLogger using OmexLogger is obsolete. Code: 8913598 + throw; } } From 1ae0d23f6501030a1f18ee709245d84c356fec0a Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 12:58:51 +0100 Subject: [PATCH 04/21] Update comment --- src/Hosting.Services/HostBuilderExtensions.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index cbf8252a2..3de0f64d2 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -41,7 +41,7 @@ public static IHost BuildStatefulService( /// /// Registering Dependency Injection classes that will provide Service Fabric specific information for logging /// - [Obsolete($"This method also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598")] + [Obsolete($"This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598")] public static IServiceCollection AddOmexServiceFabricDependencies(this IServiceCollection collection) where TContext : ServiceContext { @@ -88,14 +88,15 @@ private static IHost BuildServiceFabricService( IHost host = builder .ConfigureServices((context, collection) => { -#pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 + collection.AddOmexServiceFabricDependencies(); +#pragma warning restore CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 + collection .Configure(options => { options.ServiceTypeName = serviceName; }) - .AddOmexServiceFabricDependencies() -#pragma warning restore CS0618 // Type or member is obsolete .AddSingleton() .AddHostedService(); }) From 49f8020c952a6d5a42904878f4f0b807ee130e93 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 14:45:43 +0100 Subject: [PATCH 05/21] Deprecate ActivityEventSender --- src/Activities/Internal/EventSource/ActivityEventSender.cs | 1 + src/Activities/Internal/EventSource/ActivityEventSource.cs | 2 ++ .../EventSource/AggregatedActivitiesEventSender.cs | 2 ++ src/Activities/ServiceCollectionExtensions.cs | 7 +++++-- .../Internal/ActivitiesEventSourceTests.cs | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Activities/Internal/EventSource/ActivityEventSender.cs b/src/Activities/Internal/EventSource/ActivityEventSender.cs index ad7806bc1..0575a2bd1 100644 --- a/src/Activities/Internal/EventSource/ActivityEventSender.cs +++ b/src/Activities/Internal/EventSource/ActivityEventSender.cs @@ -15,6 +15,7 @@ namespace Microsoft.Omex.Extensions.Activities { + [Obsolete($"{nameof(ActivityEventSender)} is obsolete and pending for removal by 1 July 2024. Code: 8913598")] internal sealed class ActivityEventSender : IActivitiesEventSender { public ActivityEventSender(ActivityEventSource eventSource, IExecutionContext executionContext, ILogger logger, IOptions options) diff --git a/src/Activities/Internal/EventSource/ActivityEventSource.cs b/src/Activities/Internal/EventSource/ActivityEventSource.cs index 09ef5be55..fa324bfe9 100644 --- a/src/Activities/Internal/EventSource/ActivityEventSource.cs +++ b/src/Activities/Internal/EventSource/ActivityEventSource.cs @@ -1,12 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Diagnostics.Tracing; using Microsoft.Omex.Extensions.Abstractions.EventSources; namespace Microsoft.Omex.Extensions.Activities { // Renamed from Microsoft-OMEX-TimedScopes to avoid conflict with sources in other libraries + [Obsolete($"{nameof(ActivityEventSource)} is obsolete and pending for removal by 1 July 2024. Code: 8913598")] [EventSource(Name = "Microsoft-OMEX-TimedScopes-Ext")] internal sealed class ActivityEventSource : EventSource { diff --git a/src/Activities/Internal/EventSource/AggregatedActivitiesEventSender.cs b/src/Activities/Internal/EventSource/AggregatedActivitiesEventSender.cs index 3cf09469e..434785db8 100644 --- a/src/Activities/Internal/EventSource/AggregatedActivitiesEventSender.cs +++ b/src/Activities/Internal/EventSource/AggregatedActivitiesEventSender.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Diagnostics; namespace Microsoft.Omex.Extensions.Activities @@ -8,6 +9,7 @@ namespace Microsoft.Omex.Extensions.Activities /// /// Type created to temporary combine ActivityEventSender and ActivityMetricsSender, it should be deleted after removal for ActivityEventSender /// + [Obsolete($"{nameof(AggregatedActivitiesEventSender)} is obsolete and pending for removal by 1 July 2024. On the removal, only {nameof(ActivityMetricsSender)} is available to send metrics by OpenTelemetry. Code: 8913598")] internal sealed class AggregatedActivitiesEventSender : IActivitiesEventSender { private readonly ActivityEventSender m_etwSender; diff --git a/src/Activities/ServiceCollectionExtensions.cs b/src/Activities/ServiceCollectionExtensions.cs index 59a855a0b..94316164b 100644 --- a/src/Activities/ServiceCollectionExtensions.cs +++ b/src/Activities/ServiceCollectionExtensions.cs @@ -35,10 +35,14 @@ public static IServiceCollection AddOmexActivitySource(this IServiceCollection s serviceCollection.TryAddSingleton(); - // eventually ActivityMetricsSender will be default implementation of IActivitiesEventSender and we should remove ActivityEventSender, and AggregatedActivitiesEventSender serviceCollection.TryAddSingleton(); + +#pragma warning disable CS0612 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. Code: 8913598")] serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(); + serviceCollection.TryAddSingleton(p => ActivityEventSource.Instance); +#pragma warning restore CS0612 // Type or member is obsolete + serviceCollection.TryAddSingleton(_ => new CustomBaggageDimensions()); serviceCollection.TryAddSingleton(_ => new CustomTagObjectsDimensions()); @@ -50,7 +54,6 @@ public static IServiceCollection AddOmexActivitySource(this IServiceCollection s serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(p => new ActivitySource(ActivitySourceName, ActivitySourceVersion)); - serviceCollection.TryAddSingleton(p => ActivityEventSource.Instance); return serviceCollection; } diff --git a/tests/Activities.UnitTests/Internal/ActivitiesEventSourceTests.cs b/tests/Activities.UnitTests/Internal/ActivitiesEventSourceTests.cs index 4ae392230..21593eb80 100644 --- a/tests/Activities.UnitTests/Internal/ActivitiesEventSourceTests.cs +++ b/tests/Activities.UnitTests/Internal/ActivitiesEventSourceTests.cs @@ -17,6 +17,7 @@ namespace Microsoft.Omex.Extensions.Activities.UnitTests { [TestClass] + [Obsolete($"{nameof(ActivityEventSender)} is obsolete and pending for removal by 1 July 2024. Code: 8913598")] public class ActivitiesEventSourceTests { [DataTestMethod] From 613cd34fd23520adfda538e51b4019356f36876d Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 14:49:19 +0100 Subject: [PATCH 06/21] Update comment --- tests/Logging.UnitTests/ServiceCollectionTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Logging.UnitTests/ServiceCollectionTests.cs b/tests/Logging.UnitTests/ServiceCollectionTests.cs index 0ebb14b4e..a74d267a6 100644 --- a/tests/Logging.UnitTests/ServiceCollectionTests.cs +++ b/tests/Logging.UnitTests/ServiceCollectionTests.cs @@ -46,7 +46,7 @@ public void AddOmexLoggerOnServiceCollection_RegistersLogger() } [TestMethod] - [Obsolete] + [Obsolete("AddOmexLogging method is obsolete. Code: 8913598")] public void AddOmexLoggerOnLogBuilder_RegistersLogger() { ILoggingBuilder builder = new MockLoggingBuilder().AddOmexLogging(); @@ -56,10 +56,10 @@ public void AddOmexLoggerOnLogBuilder_RegistersLogger() private T ValidateTypeRegistration(IServiceCollection collection) where T : class { -#pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0618 // AddOmexLogging method is obsolete. Code: 8913598 T obj = collection .AddOmexLogging() -#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0618 // AddOmexLogging method is obsolete. Code: 8913598 .BuildServiceProvider(new ServiceProviderOptions { ValidateOnBuild = true, From 5edd8817f7a5b50d941f420cc2b67c78c83dbffd Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 14:55:51 +0100 Subject: [PATCH 07/21] fix wrong pragma code --- src/Activities/ServiceCollectionExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Activities/ServiceCollectionExtensions.cs b/src/Activities/ServiceCollectionExtensions.cs index 94316164b..452c76ec6 100644 --- a/src/Activities/ServiceCollectionExtensions.cs +++ b/src/Activities/ServiceCollectionExtensions.cs @@ -37,11 +37,11 @@ public static IServiceCollection AddOmexActivitySource(this IServiceCollection s serviceCollection.TryAddSingleton(); -#pragma warning disable CS0612 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. Code: 8913598")] +#pragma warning disable CS0618 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. Code: 8913598. serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(p => ActivityEventSource.Instance); -#pragma warning restore CS0612 // Type or member is obsolete +#pragma warning restore CS0618 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. Code: 8913598. serviceCollection.TryAddSingleton(_ => new CustomBaggageDimensions()); serviceCollection.TryAddSingleton(_ => new CustomTagObjectsDimensions()); From 21f03c6bd5f274e46a24e0c25ae85a5430c9c925 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 15:07:07 +0100 Subject: [PATCH 08/21] add message --- tests/Logging.UnitTests/ServiceCollectionTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Logging.UnitTests/ServiceCollectionTests.cs b/tests/Logging.UnitTests/ServiceCollectionTests.cs index a74d267a6..0a96eb12a 100644 --- a/tests/Logging.UnitTests/ServiceCollectionTests.cs +++ b/tests/Logging.UnitTests/ServiceCollectionTests.cs @@ -26,9 +26,9 @@ public void AddOmexServiceContext_OverridesContextType() IServiceCollection collection = new ServiceCollection() .AddOmexServiceContext(); -#pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0618 // AddOmexLogging method is obsolete. Code: 8913598 collection.AddOmexLogging(); -#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0618 // AddOmexLogging method is obsolete. Code: 8913598 IServiceContext context = ValidateTypeRegistration(collection); @@ -38,7 +38,7 @@ public void AddOmexServiceContext_OverridesContextType() } [TestMethod] - [Obsolete] + [Obsolete("AddOmexLogging method is obsolete. Code: 8913598")] public void AddOmexLoggerOnServiceCollection_RegistersLogger() { IServiceCollection collection = new ServiceCollection().AddOmexLogging(); From 97e74e5e38a997c5352cebef45de460db191ecf8 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 16:20:20 +0100 Subject: [PATCH 09/21] resolve comment --- src/Hosting.Services/HostBuilderExtensions.cs | 11 ++++++++++- .../Internal/EventSource/EmptyServiceContext.cs | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index 3de0f64d2..cb4246478 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using Microsoft.Omex.Extensions.Abstractions; using Microsoft.Omex.Extensions.Abstractions.Accessors; using Microsoft.Omex.Extensions.Abstractions.ExecutionContext; @@ -41,7 +42,6 @@ public static IHost BuildStatefulService( /// /// Registering Dependency Injection classes that will provide Service Fabric specific information for logging /// - [Obsolete($"This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598")] public static IServiceCollection AddOmexServiceFabricDependencies(this IServiceCollection collection) where TContext : ServiceContext { @@ -61,7 +61,16 @@ public static IServiceCollection AddOmexServiceFabricDependencies(this collection.TryAddSingleton(); collection.TryAddSingleton(); + + collection.AddLogging(); + + collection.TryAddTransient(); + collection.TryAddTransient(); + collection.TryAddTransient(); + +#pragma warning disable CS0618 // This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 return collection.AddOmexServices(); +#pragma warning restore CS0618 // This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 } private static IHost BuildServiceFabricService( diff --git a/src/Logging/Internal/EventSource/EmptyServiceContext.cs b/src/Logging/Internal/EventSource/EmptyServiceContext.cs index f0b6f0d42..f29a9ceaf 100644 --- a/src/Logging/Internal/EventSource/EmptyServiceContext.cs +++ b/src/Logging/Internal/EventSource/EmptyServiceContext.cs @@ -8,10 +8,16 @@ namespace Microsoft.Omex.Extensions.Logging /// /// IServiceContext without any information /// - internal class EmptyServiceContext : IServiceContext + public class EmptyServiceContext : IServiceContext { + /// + /// PartitionId + /// public Guid PartitionId => Guid.Empty; + /// + /// ReplicaOrInstanceId + /// public long ReplicaOrInstanceId => 0; } } From ffcd71fb6f230f16820233b56aeddac9e02592d3 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Fri, 10 May 2024 16:28:40 +0100 Subject: [PATCH 10/21] Update OMEX188 --- .../Internal/EventSource/ActivityEventSender.cs | 2 +- .../Internal/EventSource/ActivityEventSource.cs | 2 +- .../EventSource/AggregatedActivitiesEventSender.cs | 2 +- src/Activities/ServiceCollectionExtensions.cs | 4 ++-- src/Hosting.Services/HostBuilderExtensions.cs | 14 ++++++-------- .../InitializationCertificateReader.cs | 4 ++-- src/Hosting/ServiceCollectionExtensions.cs | 4 ++-- src/Logging/InitializationLogger.cs | 4 ++-- src/Logging/Internal/OmexLoggerProvider.cs | 2 +- src/Logging/ServiceCollectionExtensions.cs | 6 +++--- .../Internal/ActivitiesEventSourceTests.cs | 2 +- .../HostBuilderExtensionsTests.cs | 4 ++-- .../HostBuilderExtensionsTests.cs | 2 +- tests/Logging.UnitTests/OmexLogEventSenderTests.cs | 2 +- tests/Logging.UnitTests/OmexLoggerProviderTests.cs | 2 +- .../Scrubbing/ServiceCollectionExtensionsTests.cs | 4 ++-- tests/Logging.UnitTests/ServiceCollectionTests.cs | 12 ++++++------ 17 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/Activities/Internal/EventSource/ActivityEventSender.cs b/src/Activities/Internal/EventSource/ActivityEventSender.cs index 0575a2bd1..96a95b3bc 100644 --- a/src/Activities/Internal/EventSource/ActivityEventSender.cs +++ b/src/Activities/Internal/EventSource/ActivityEventSender.cs @@ -15,7 +15,7 @@ namespace Microsoft.Omex.Extensions.Activities { - [Obsolete($"{nameof(ActivityEventSender)} is obsolete and pending for removal by 1 July 2024. Code: 8913598")] + [Obsolete($"{nameof(ActivityEventSender)} is obsolete and pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] internal sealed class ActivityEventSender : IActivitiesEventSender { public ActivityEventSender(ActivityEventSource eventSource, IExecutionContext executionContext, ILogger logger, IOptions options) diff --git a/src/Activities/Internal/EventSource/ActivityEventSource.cs b/src/Activities/Internal/EventSource/ActivityEventSource.cs index fa324bfe9..15b526ed7 100644 --- a/src/Activities/Internal/EventSource/ActivityEventSource.cs +++ b/src/Activities/Internal/EventSource/ActivityEventSource.cs @@ -8,7 +8,7 @@ namespace Microsoft.Omex.Extensions.Activities { // Renamed from Microsoft-OMEX-TimedScopes to avoid conflict with sources in other libraries - [Obsolete($"{nameof(ActivityEventSource)} is obsolete and pending for removal by 1 July 2024. Code: 8913598")] + [Obsolete($"{nameof(ActivityEventSource)} is obsolete and pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] [EventSource(Name = "Microsoft-OMEX-TimedScopes-Ext")] internal sealed class ActivityEventSource : EventSource { diff --git a/src/Activities/Internal/EventSource/AggregatedActivitiesEventSender.cs b/src/Activities/Internal/EventSource/AggregatedActivitiesEventSender.cs index 434785db8..814ea0e09 100644 --- a/src/Activities/Internal/EventSource/AggregatedActivitiesEventSender.cs +++ b/src/Activities/Internal/EventSource/AggregatedActivitiesEventSender.cs @@ -9,7 +9,7 @@ namespace Microsoft.Omex.Extensions.Activities /// /// Type created to temporary combine ActivityEventSender and ActivityMetricsSender, it should be deleted after removal for ActivityEventSender /// - [Obsolete($"{nameof(AggregatedActivitiesEventSender)} is obsolete and pending for removal by 1 July 2024. On the removal, only {nameof(ActivityMetricsSender)} is available to send metrics by OpenTelemetry. Code: 8913598")] + [Obsolete($"{nameof(AggregatedActivitiesEventSender)} is obsolete and pending for removal by 1 July 2024. On the removal, only {nameof(ActivityMetricsSender)} is available to send metrics by OpenTelemetry.", DiagnosticId = "OMEX188")] internal sealed class AggregatedActivitiesEventSender : IActivitiesEventSender { private readonly ActivityEventSender m_etwSender; diff --git a/src/Activities/ServiceCollectionExtensions.cs b/src/Activities/ServiceCollectionExtensions.cs index 452c76ec6..3d76eb720 100644 --- a/src/Activities/ServiceCollectionExtensions.cs +++ b/src/Activities/ServiceCollectionExtensions.cs @@ -37,11 +37,11 @@ public static IServiceCollection AddOmexActivitySource(this IServiceCollection s serviceCollection.TryAddSingleton(); -#pragma warning disable CS0618 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. Code: 8913598. +#pragma warning disable OMEX188 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. DiagnosticId = "OMEX188" serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(p => ActivityEventSource.Instance); -#pragma warning restore CS0618 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. Code: 8913598. +#pragma warning restore OMEX188 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. DiagnosticId = "OMEX188" serviceCollection.TryAddSingleton(_ => new CustomBaggageDimensions()); serviceCollection.TryAddSingleton(_ => new CustomTagObjectsDimensions()); diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index cb4246478..bee1714df 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -68,9 +68,9 @@ public static IServiceCollection AddOmexServiceFabricDependencies(this collection.TryAddTransient(); collection.TryAddTransient(); -#pragma warning disable CS0618 // This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 +#pragma warning disable OMEX188 // This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. DiagnosticId = "OMEX188" return collection.AddOmexServices(); -#pragma warning restore CS0618 // This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 +#pragma warning restore OMEX188 // This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. DiagnosticId = "OMEX188" } private static IHost BuildServiceFabricService( @@ -97,9 +97,7 @@ private static IHost BuildServiceFabricService( IHost host = builder .ConfigureServices((context, collection) => { -#pragma warning disable CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 collection.AddOmexServiceFabricDependencies(); -#pragma warning restore CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 collection .Configure(options => @@ -116,17 +114,17 @@ private static IHost BuildServiceFabricService( }) .Build(); -#pragma warning disable CS0618 // InitializationLogger using OmexLogger is obsolete. Code: 8913598 +#pragma warning disable OMEX188 // InitializationLogger using OmexLogger is obsolete. DiagnosticId = "OMEX188" InitializationLogger.LogInitializationSucceed(serviceNameForLogging); -#pragma warning restore CS0618 // InitializationLogger using OmexLogger is obsolete. Code: 8913598 +#pragma warning restore OMEX188 // InitializationLogger using OmexLogger is obsolete. DiagnosticId = "OMEX188" return host; } catch (Exception e) { -#pragma warning disable CS0618 // InitializationLogger using OmexLogger is obsolete. Code: 8913598 +#pragma warning disable OMEX188 // InitializationLogger using OmexLogger is obsolete. DiagnosticId = "OMEX188" InitializationLogger.LogInitializationFail(serviceNameForLogging, e); -#pragma warning restore CS0618 // InitializationLogger using OmexLogger is obsolete. Code: 8913598 +#pragma warning restore OMEX188 // InitializationLogger using OmexLogger is obsolete. DiagnosticId = "OMEX188" throw; } diff --git a/src/Hosting/Certificates/InitializationCertificateReader.cs b/src/Hosting/Certificates/InitializationCertificateReader.cs index af37eec97..5b69dfbed 100644 --- a/src/Hosting/Certificates/InitializationCertificateReader.cs +++ b/src/Hosting/Certificates/InitializationCertificateReader.cs @@ -16,8 +16,8 @@ public static class InitializationCertificateReader /// /// Instance of CertificateReader /// -#pragma warning disable CS0618 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. Code: 8913598 +#pragma warning disable OMEX188 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. DiagnosticId = "OMEX188" public static ICertificateReader Instance { get; } = new CertificateReader(new CertificateStore(), InitializationLogger.Instance); -#pragma warning restore CS0618 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. Code: 8913598 +#pragma warning restore OMEX188 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. DiagnosticId = "OMEX188" } } diff --git a/src/Hosting/ServiceCollectionExtensions.cs b/src/Hosting/ServiceCollectionExtensions.cs index 450b29f0a..0bd5b481a 100644 --- a/src/Hosting/ServiceCollectionExtensions.cs +++ b/src/Hosting/ServiceCollectionExtensions.cs @@ -18,7 +18,7 @@ public static class ServiceCollectionExtensions /// /// Add Omex Logging and ActivitySource dependencies /// - [Obsolete($"Please do not use {nameof(AddOmexServices)} if you just want to use Legacy OmexLogger and ActivityEventSender because they are deprecated. Consider using a different telemetry solution. This method is pending for removal by 1 July 2024. Code: 8913598.")] + [Obsolete($"Please do not use {nameof(AddOmexServices)} if you just want to use Legacy OmexLogger and ActivityEventSender because they are deprecated. Consider using a different telemetry solution. This method is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public static IHostBuilder AddOmexServices(this IHostBuilder builder) => builder .ConfigureServices((context, collection) => collection.AddOmexServices()); @@ -26,7 +26,7 @@ public static IHostBuilder AddOmexServices(this IHostBuilder builder) => /// /// Add Omex Logging and ActivitySource dependencies /// - [Obsolete($"Please do not use {nameof(AddOmexServices)} if you just want to use Legacy OmexLogger and ActivityEventSender because they are deprecated. Consider using a different telemetry solution. This method is pending for removal by 1 July 2024. Code: 8913598.")] + [Obsolete($"Please do not use {nameof(AddOmexServices)} if you just want to use Legacy OmexLogger and ActivityEventSender because they are deprecated. Consider using a different telemetry solution. This method is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public static IServiceCollection AddOmexServices(this IServiceCollection collection) => collection .AddOmexLogging() diff --git a/src/Logging/InitializationLogger.cs b/src/Logging/InitializationLogger.cs index 86cc0508e..673a3d239 100644 --- a/src/Logging/InitializationLogger.cs +++ b/src/Logging/InitializationLogger.cs @@ -11,7 +11,7 @@ namespace Microsoft.Omex.Extensions.Logging /// InitializationLogger is the logger to be used before the proper ILogger from DI is set. /// Not to be used as main logger. /// - [Obsolete($"{nameof(InitializationLogger)} using {nameof(OmexLogger)} is obsolete and is pending for removal by 1 July 2024. Code: 8913598.")] + [Obsolete($"{nameof(InitializationLogger)} using {nameof(OmexLogger)} is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public static class InitializationLogger { /// @@ -56,7 +56,7 @@ public static void LogInitializationSucceed(string serviceNameForLogging, string /// Service name for logging /// Exception to log /// Message to log - [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. Code: 8913598.")] + [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public static void LogInitializationFail(string serviceNameForLogging, Exception? ex = null, string message = "") { ServiceInitializationEventSource.Instance.LogHostFailed(ex?.ToString() ?? string.Empty, serviceNameForLogging, message); diff --git a/src/Logging/Internal/OmexLoggerProvider.cs b/src/Logging/Internal/OmexLoggerProvider.cs index 044aaec6b..2aa49c4a5 100644 --- a/src/Logging/Internal/OmexLoggerProvider.cs +++ b/src/Logging/Internal/OmexLoggerProvider.cs @@ -10,7 +10,7 @@ namespace Microsoft.Omex.Extensions.Logging { [ProviderAlias("Omex")] - [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different logging solution. Code: 8913598.")] + [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different logging solution.", DiagnosticId = "OMEX188")] internal class OmexLoggerProvider : ILoggerProvider, ISupportExternalScope { public OmexLoggerProvider( diff --git a/src/Logging/ServiceCollectionExtensions.cs b/src/Logging/ServiceCollectionExtensions.cs index 960fda972..5e53087a3 100644 --- a/src/Logging/ServiceCollectionExtensions.cs +++ b/src/Logging/ServiceCollectionExtensions.cs @@ -31,7 +31,7 @@ public static IServiceCollection AddOmexServiceContext(this ISe /// Adds Omex event logger to the factory /// /// The extension method argument - [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger. Code: 8913598.")] + [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger.", DiagnosticId = "OMEX188")] public static ILoggingBuilder AddOmexLogging(this ILoggingBuilder builder) { builder.AddConfiguration(); @@ -44,7 +44,7 @@ public static ILoggingBuilder AddOmexLogging(this ILoggingBuilder builder) /// /// The extension method argument /// The so that additional calls can be chained - [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger. Code: 8913598.")] + [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger.", DiagnosticId = "OMEX188")] public static IServiceCollection AddOmexLogging(this IServiceCollection serviceCollection) { serviceCollection.AddLogging(); @@ -58,7 +58,7 @@ public static IServiceCollection AddOmexLogging(this IServiceCollection serviceC return serviceCollection; } - [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger. Code: 8913598.")] + [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger.", DiagnosticId = "OMEX188")] private static void AddOmexLegacyLogging(IServiceCollection serviceCollection) { serviceCollection.TryAddSingleton(_ => OmexLogEventSource.Instance); diff --git a/tests/Activities.UnitTests/Internal/ActivitiesEventSourceTests.cs b/tests/Activities.UnitTests/Internal/ActivitiesEventSourceTests.cs index 21593eb80..748ddc91e 100644 --- a/tests/Activities.UnitTests/Internal/ActivitiesEventSourceTests.cs +++ b/tests/Activities.UnitTests/Internal/ActivitiesEventSourceTests.cs @@ -17,7 +17,7 @@ namespace Microsoft.Omex.Extensions.Activities.UnitTests { [TestClass] - [Obsolete($"{nameof(ActivityEventSender)} is obsolete and pending for removal by 1 July 2024. Code: 8913598")] + [Obsolete($"{nameof(ActivityEventSender)} is obsolete and pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public class ActivitiesEventSourceTests { [DataTestMethod] diff --git a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs index 0e79b9b8a..4872351ce 100644 --- a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs +++ b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs @@ -29,10 +29,10 @@ public void AddOmexServiceFabricDependencies_TypesRegistered(Type typeToResolve, { void CheckTypeRegistration() where TContext : ServiceContext { -#pragma warning disable CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 +#pragma warning disable CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. DiagnosticId = "OMEX188" object? obj = new ServiceCollection() .AddOmexServiceFabricDependencies() -#pragma warning restore CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. Code: 8913598 +#pragma warning restore CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. DiagnosticId = "OMEX188" .AddSingleton(new Mock().Object) .BuildServiceProvider() .GetService(typeToResolve); diff --git a/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs index dc2e571e1..7b8333289 100644 --- a/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs +++ b/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs @@ -19,7 +19,7 @@ public class HostBuilderExtensionsTests [DataTestMethod] [DataRow(typeof(ILogger))] [DataRow(typeof(ActivitySource))] - [Obsolete("AddOmexServices is Obsolete and pending for removal on 1 July 2024. Code: 8913598.")] + [Obsolete("AddOmexServices is Obsolete and pending for removal on 1 July 2024.", DiagnosticId = "OMEX188")] public void AddOmexServices_TypesRegistered(Type type) { object? collectionObj = new ServiceCollection() diff --git a/tests/Logging.UnitTests/OmexLogEventSenderTests.cs b/tests/Logging.UnitTests/OmexLogEventSenderTests.cs index d980bab42..0651c706f 100644 --- a/tests/Logging.UnitTests/OmexLogEventSenderTests.cs +++ b/tests/Logging.UnitTests/OmexLogEventSenderTests.cs @@ -15,7 +15,7 @@ namespace Microsoft.Omex.Extensions.Logging.UnitTests { - [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. Code: 8913598.")] + [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] [TestClass] public class OmexLogEventSenderTests { diff --git a/tests/Logging.UnitTests/OmexLoggerProviderTests.cs b/tests/Logging.UnitTests/OmexLoggerProviderTests.cs index 56d51d1d5..3d0997818 100644 --- a/tests/Logging.UnitTests/OmexLoggerProviderTests.cs +++ b/tests/Logging.UnitTests/OmexLoggerProviderTests.cs @@ -11,7 +11,7 @@ namespace Microsoft.Omex.Extensions.Logging.UnitTests { [TestClass] - [Obsolete("OmexLogger is Obsolete and pending for removal on 1 July 2024. Code: 8913598.")] + [Obsolete("OmexLogger is Obsolete and pending for removal on 1 July 2024.", DiagnosticId = "OMEX188")] public class OmexLoggerProviderTests { [TestMethod] diff --git a/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs b/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs index 5271ea4ce..9b67a16d5 100644 --- a/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs +++ b/tests/Logging.UnitTests/Scrubbing/ServiceCollectionExtensionsTests.cs @@ -142,10 +142,10 @@ public void AddRegexLogScrubbingRule_Scrubs(string input, string expected) private static ILogScrubbingRule[] GetTypeRegistrations(IServiceCollection collection) { -#pragma warning disable CS0618 // AddOmexLogging uses OmexLogger and OmexLogEventSource which are obsolete and pending for removal by 1 July 2024. Code: 8913598. +#pragma warning disable OMEX188 // AddOmexLogging uses OmexLogger and OmexLogEventSource which are obsolete and pending for removal by 1 July 2024. DiagnosticId = "OMEX188" IEnumerable objects = collection .AddOmexLogging() -#pragma warning restore CS0618 // AddOmexLogging uses OmexLogger and OmexLogEventSource which are obsolete and pending for removal by 1 July 2024. Code: 8913598. +#pragma warning restore OMEX188 // AddOmexLogging uses OmexLogger and OmexLogEventSource which are obsolete and pending for removal by 1 July 2024. DiagnosticId = "OMEX188" .BuildServiceProvider(new ServiceProviderOptions { ValidateOnBuild = true, diff --git a/tests/Logging.UnitTests/ServiceCollectionTests.cs b/tests/Logging.UnitTests/ServiceCollectionTests.cs index 0a96eb12a..9eca29b15 100644 --- a/tests/Logging.UnitTests/ServiceCollectionTests.cs +++ b/tests/Logging.UnitTests/ServiceCollectionTests.cs @@ -26,9 +26,9 @@ public void AddOmexServiceContext_OverridesContextType() IServiceCollection collection = new ServiceCollection() .AddOmexServiceContext(); -#pragma warning disable CS0618 // AddOmexLogging method is obsolete. Code: 8913598 +#pragma warning disable OMEX188 // AddOmexLogging method is obsolete. DiagnosticId = "OMEX188" collection.AddOmexLogging(); -#pragma warning restore CS0618 // AddOmexLogging method is obsolete. Code: 8913598 +#pragma warning restore OMEX188 // AddOmexLogging method is obsolete. DiagnosticId = "OMEX188" IServiceContext context = ValidateTypeRegistration(collection); @@ -38,7 +38,7 @@ public void AddOmexServiceContext_OverridesContextType() } [TestMethod] - [Obsolete("AddOmexLogging method is obsolete. Code: 8913598")] + [Obsolete("AddOmexLogging method is obsolete.", DiagnosticId = "OMEX188")] public void AddOmexLoggerOnServiceCollection_RegistersLogger() { IServiceCollection collection = new ServiceCollection().AddOmexLogging(); @@ -46,7 +46,7 @@ public void AddOmexLoggerOnServiceCollection_RegistersLogger() } [TestMethod] - [Obsolete("AddOmexLogging method is obsolete. Code: 8913598")] + [Obsolete("AddOmexLogging method is obsolete.", DiagnosticId = "OMEX188")] public void AddOmexLoggerOnLogBuilder_RegistersLogger() { ILoggingBuilder builder = new MockLoggingBuilder().AddOmexLogging(); @@ -56,10 +56,10 @@ public void AddOmexLoggerOnLogBuilder_RegistersLogger() private T ValidateTypeRegistration(IServiceCollection collection) where T : class { -#pragma warning disable CS0618 // AddOmexLogging method is obsolete. Code: 8913598 +#pragma warning disable OMEX188 // AddOmexLogging method is obsolete. DiagnosticId = "OMEX188" T obj = collection .AddOmexLogging() -#pragma warning restore CS0618 // AddOmexLogging method is obsolete. Code: 8913598 +#pragma warning restore OMEX188 // AddOmexLogging method is obsolete. DiagnosticId = "OMEX188" .BuildServiceProvider(new ServiceProviderOptions { ValidateOnBuild = true, From da0a4c6f8b86243a3e883be0264fb63c72922906 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Mon, 13 May 2024 15:27:44 +0100 Subject: [PATCH 11/21] resolve comments --- src/Hosting/Certificates/InitializationCertificateReader.cs | 4 ++-- .../ServiceFabricClientFactory.cs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Hosting/Certificates/InitializationCertificateReader.cs b/src/Hosting/Certificates/InitializationCertificateReader.cs index 5b69dfbed..d3f90dd67 100644 --- a/src/Hosting/Certificates/InitializationCertificateReader.cs +++ b/src/Hosting/Certificates/InitializationCertificateReader.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using Microsoft.Omex.Extensions.Logging; namespace Microsoft.Omex.Extensions.Hosting.Certificates @@ -11,13 +12,12 @@ namespace Microsoft.Omex.Extensions.Hosting.Certificates /// /// Please prefer using instance resolved from DI container. /// + [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public static class InitializationCertificateReader { /// /// Instance of CertificateReader /// -#pragma warning disable OMEX188 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. DiagnosticId = "OMEX188" public static ICertificateReader Instance { get; } = new CertificateReader(new CertificateStore(), InitializationLogger.Instance); -#pragma warning restore OMEX188 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. DiagnosticId = "OMEX188" } } diff --git a/src/ServiceFabricGuest.Abstractions/ServiceFabricClientFactory.cs b/src/ServiceFabricGuest.Abstractions/ServiceFabricClientFactory.cs index 080669cfe..7b0dcacf2 100644 --- a/src/ServiceFabricGuest.Abstractions/ServiceFabricClientFactory.cs +++ b/src/ServiceFabricGuest.Abstractions/ServiceFabricClientFactory.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using Microsoft.Extensions.Options; using Microsoft.Omex.Extensions.Hosting.Certificates; @@ -12,6 +13,7 @@ namespace Microsoft.Omex.Extensions.ServiceFabricGuest.Abstractions /// /// Please prefer using instance resolved from DI container. /// + [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public class ServiceFabricClientFactory { /// From 3f84d35a0631d5ea75596383311651087a96b5eb Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Mon, 13 May 2024 17:51:41 +0100 Subject: [PATCH 12/21] resolve comment --- .../ServiceFabricClientFactory.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ServiceFabricGuest.Abstractions/ServiceFabricClientFactory.cs b/src/ServiceFabricGuest.Abstractions/ServiceFabricClientFactory.cs index 7b0dcacf2..a2ed31ee2 100644 --- a/src/ServiceFabricGuest.Abstractions/ServiceFabricClientFactory.cs +++ b/src/ServiceFabricGuest.Abstractions/ServiceFabricClientFactory.cs @@ -13,13 +13,14 @@ namespace Microsoft.Omex.Extensions.ServiceFabricGuest.Abstractions /// /// Please prefer using instance resolved from DI container. /// - [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public class ServiceFabricClientFactory { /// /// Creates service fabric client wrapper instance and returns it. /// public static IServiceFabricClientWrapper Create(ServiceFabricRestClientOptions options) => +#pragma warning disable OMEX188 // InitializationCertificateReader using OmexLogger is obsolete. DiagnosticId = "OMEX188" new ServiceFabricClientWrapper(Options.Create(options), InitializationCertificateReader.Instance); +#pragma warning restore OMEX188 // InitializationCertificateReader using OmexLogger is obsolete. DiagnosticId = "OMEX188" } } From a89fcc05589a62a7d122c3830233f4531dd63e81 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Mon, 13 May 2024 17:52:51 +0100 Subject: [PATCH 13/21] resolve comment --- src/Logging/InitializationLogger.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Logging/InitializationLogger.cs b/src/Logging/InitializationLogger.cs index 673a3d239..44d0b978c 100644 --- a/src/Logging/InitializationLogger.cs +++ b/src/Logging/InitializationLogger.cs @@ -56,7 +56,6 @@ public static void LogInitializationSucceed(string serviceNameForLogging, string /// Service name for logging /// Exception to log /// Message to log - [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public static void LogInitializationFail(string serviceNameForLogging, Exception? ex = null, string message = "") { ServiceInitializationEventSource.Instance.LogHostFailed(ex?.ToString() ?? string.Empty, serviceNameForLogging, message); From 323d23648b4298e77c98b38de632592da992fcad Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Tue, 14 May 2024 15:16:58 +0100 Subject: [PATCH 14/21] Update --- src/Hosting.Services/HostBuilderExtensions.cs | 2 -- src/Logging/ServiceCollectionExtensions.cs | 10 ++-------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index bee1714df..7b88451c8 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -64,9 +64,7 @@ public static IServiceCollection AddOmexServiceFabricDependencies(this collection.AddLogging(); - collection.TryAddTransient(); collection.TryAddTransient(); - collection.TryAddTransient(); #pragma warning disable OMEX188 // This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. DiagnosticId = "OMEX188" return collection.AddOmexServices(); diff --git a/src/Logging/ServiceCollectionExtensions.cs b/src/Logging/ServiceCollectionExtensions.cs index 5e53087a3..fc731b7d8 100644 --- a/src/Logging/ServiceCollectionExtensions.cs +++ b/src/Logging/ServiceCollectionExtensions.cs @@ -53,20 +53,14 @@ public static IServiceCollection AddOmexLogging(this IServiceCollection serviceC serviceCollection.TryAddTransient(); serviceCollection.TryAddTransient(); - AddOmexLegacyLogging(serviceCollection); - - return serviceCollection; - } - - [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger.", DiagnosticId = "OMEX188")] - private static void AddOmexLegacyLogging(IServiceCollection serviceCollection) - { serviceCollection.TryAddSingleton(_ => OmexLogEventSource.Instance); serviceCollection.TryAddSingleton(); serviceCollection.TryAddSingleton(); serviceCollection.TryAddEnumerable(ServiceDescriptor.Transient()); serviceCollection.TryAddEnumerable(ServiceDescriptor.Singleton()); + + return serviceCollection; } } } From 49bfaea16b1c27064463f55b61f3be9bcc379ab9 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Tue, 14 May 2024 15:20:40 +0100 Subject: [PATCH 15/21] Update --- src/Hosting/Certificates/InitializationCertificateReader.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Hosting/Certificates/InitializationCertificateReader.cs b/src/Hosting/Certificates/InitializationCertificateReader.cs index d3f90dd67..ca2ac21ce 100644 --- a/src/Hosting/Certificates/InitializationCertificateReader.cs +++ b/src/Hosting/Certificates/InitializationCertificateReader.cs @@ -12,12 +12,13 @@ namespace Microsoft.Omex.Extensions.Hosting.Certificates /// /// Please prefer using instance resolved from DI container. /// - [Obsolete("InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public static class InitializationCertificateReader { /// /// Instance of CertificateReader /// +#pragma warning disable OMEX188 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. public static ICertificateReader Instance { get; } = new CertificateReader(new CertificateStore(), InitializationLogger.Instance); +#pragma warning restore OMEX188 // InitializationLogger using OmexLogger is obsolete and is pending for removal by 1 July 2024. } } From 970f8292788d4aab18854c35d83ecda0be4e3277 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Wed, 15 May 2024 09:40:39 +0100 Subject: [PATCH 16/21] Resolve comment --- src/Hosting/ServiceCollectionExtensions.cs | 4 ++-- tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Hosting/ServiceCollectionExtensions.cs b/src/Hosting/ServiceCollectionExtensions.cs index 0bd5b481a..5e23f8e09 100644 --- a/src/Hosting/ServiceCollectionExtensions.cs +++ b/src/Hosting/ServiceCollectionExtensions.cs @@ -18,7 +18,6 @@ public static class ServiceCollectionExtensions /// /// Add Omex Logging and ActivitySource dependencies /// - [Obsolete($"Please do not use {nameof(AddOmexServices)} if you just want to use Legacy OmexLogger and ActivityEventSender because they are deprecated. Consider using a different telemetry solution. This method is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public static IHostBuilder AddOmexServices(this IHostBuilder builder) => builder .ConfigureServices((context, collection) => collection.AddOmexServices()); @@ -26,10 +25,11 @@ public static IHostBuilder AddOmexServices(this IHostBuilder builder) => /// /// Add Omex Logging and ActivitySource dependencies /// - [Obsolete($"Please do not use {nameof(AddOmexServices)} if you just want to use Legacy OmexLogger and ActivityEventSender because they are deprecated. Consider using a different telemetry solution. This method is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] public static IServiceCollection AddOmexServices(this IServiceCollection collection) => +#pragma warning disable OMEX188 // OmexLogger and OmexLogEventSource are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger. collection .AddOmexLogging() +#pragma warning restore OMEX188 // OmexLogger and OmexLogEventSource are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger. .AddOmexActivitySource(); /// diff --git a/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs index 7b8333289..005af3e48 100644 --- a/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs +++ b/tests/Hosting.UnitTests/HostBuilderExtensionsTests.cs @@ -19,7 +19,6 @@ public class HostBuilderExtensionsTests [DataTestMethod] [DataRow(typeof(ILogger))] [DataRow(typeof(ActivitySource))] - [Obsolete("AddOmexServices is Obsolete and pending for removal on 1 July 2024.", DiagnosticId = "OMEX188")] public void AddOmexServices_TypesRegistered(Type type) { object? collectionObj = new ServiceCollection() From b79791baf642e129d82db2ba136044fd094deb59 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Thu, 16 May 2024 17:17:57 +0100 Subject: [PATCH 17/21] revert EmptyServiceContext.cs --- src/Logging/Internal/EventSource/EmptyServiceContext.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Logging/Internal/EventSource/EmptyServiceContext.cs b/src/Logging/Internal/EventSource/EmptyServiceContext.cs index f29a9ceaf..f0b6f0d42 100644 --- a/src/Logging/Internal/EventSource/EmptyServiceContext.cs +++ b/src/Logging/Internal/EventSource/EmptyServiceContext.cs @@ -8,16 +8,10 @@ namespace Microsoft.Omex.Extensions.Logging /// /// IServiceContext without any information /// - public class EmptyServiceContext : IServiceContext + internal class EmptyServiceContext : IServiceContext { - /// - /// PartitionId - /// public Guid PartitionId => Guid.Empty; - /// - /// ReplicaOrInstanceId - /// public long ReplicaOrInstanceId => 0; } } From 927e71872ed736e3768edbb65c0c94fc0b167825 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Thu, 16 May 2024 17:36:06 +0100 Subject: [PATCH 18/21] revert --- src/Hosting.Services/HostBuilderExtensions.cs | 6 ------ .../HostBuilderExtensionsTests.cs | 2 -- 2 files changed, 8 deletions(-) diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index 7b88451c8..556f9ac6b 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -62,13 +62,7 @@ public static IServiceCollection AddOmexServiceFabricDependencies(this collection.TryAddSingleton(); collection.TryAddSingleton(); - collection.AddLogging(); - - collection.TryAddTransient(); - -#pragma warning disable OMEX188 // This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. DiagnosticId = "OMEX188" return collection.AddOmexServices(); -#pragma warning restore OMEX188 // This method also adds Legacy OmexLogger and ActivityEventSender which are deprecated. They are pending for removal by 1 July 2024. Consider adding a different telemetry solution. DiagnosticId = "OMEX188" } private static IHost BuildServiceFabricService( diff --git a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs index 4872351ce..25b608e04 100644 --- a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs +++ b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs @@ -29,10 +29,8 @@ public void AddOmexServiceFabricDependencies_TypesRegistered(Type typeToResolve, { void CheckTypeRegistration() where TContext : ServiceContext { -#pragma warning disable CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. DiagnosticId = "OMEX188" object? obj = new ServiceCollection() .AddOmexServiceFabricDependencies() -#pragma warning restore CS0618 // AddOmexServiceFabricDependencies also adds Legacy OmexLogger and ActivityEventSender and they are deprecated. This legacy telemetry is pending for removal by 1 July 2024. Consider adding a different telemetry solution. DiagnosticId = "OMEX188" .AddSingleton(new Mock().Object) .BuildServiceProvider() .GetService(typeToResolve); From 660efa6bbe1356295b7f6dd32005816a3bc2834b Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Thu, 16 May 2024 17:37:12 +0100 Subject: [PATCH 19/21] revert --- src/Hosting.Services/HostBuilderExtensions.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index 556f9ac6b..f0643219f 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -89,13 +89,12 @@ private static IHost BuildServiceFabricService( IHost host = builder .ConfigureServices((context, collection) => { - collection.AddOmexServiceFabricDependencies(); - collection .Configure(options => { options.ServiceTypeName = serviceName; }) + .AddOmexServiceFabricDependencies() .AddSingleton() .AddHostedService(); }) From e4cdfb348bacc52163fd828d3366bb6bed2872b2 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Thu, 16 May 2024 17:44:40 +0100 Subject: [PATCH 20/21] Update --- src/Logging/Internal/EventSource/OmexLogEventSender.cs | 1 + src/Logging/Internal/EventSource/OmexLogEventSource.cs | 1 + src/Logging/ServiceCollectionExtensions.cs | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Logging/Internal/EventSource/OmexLogEventSender.cs b/src/Logging/Internal/EventSource/OmexLogEventSender.cs index 4d112b48a..1cb810177 100644 --- a/src/Logging/Internal/EventSource/OmexLogEventSender.cs +++ b/src/Logging/Internal/EventSource/OmexLogEventSender.cs @@ -11,6 +11,7 @@ namespace Microsoft.Omex.Extensions.Logging { + [Obsolete($"{nameof(OmexLogEventSender)} is obsolete and pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] internal sealed class OmexLogEventSender : ILogEventSender { static OmexLogEventSender() diff --git a/src/Logging/Internal/EventSource/OmexLogEventSource.cs b/src/Logging/Internal/EventSource/OmexLogEventSource.cs index 247820a6b..50678e51a 100644 --- a/src/Logging/Internal/EventSource/OmexLogEventSource.cs +++ b/src/Logging/Internal/EventSource/OmexLogEventSource.cs @@ -8,6 +8,7 @@ namespace Microsoft.Omex.Extensions.Logging { // Renamed from Microsoft-OMEX-Logs to avoid conflict with sources in other libraries + [Obsolete($"{nameof(OmexLogEventSource)} is obsolete and pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] [EventSource(Name = "Microsoft-OMEX-Logs-Ext")] internal sealed class OmexLogEventSource : EventSource { diff --git a/src/Logging/ServiceCollectionExtensions.cs b/src/Logging/ServiceCollectionExtensions.cs index fc731b7d8..70dc2b111 100644 --- a/src/Logging/ServiceCollectionExtensions.cs +++ b/src/Logging/ServiceCollectionExtensions.cs @@ -31,7 +31,7 @@ public static IServiceCollection AddOmexServiceContext(this ISe /// Adds Omex event logger to the factory /// /// The extension method argument - [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger.", DiagnosticId = "OMEX188")] + [Obsolete("OmexLogger and OmexLogEventSource are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger.", DiagnosticId = "OMEX188")] public static ILoggingBuilder AddOmexLogging(this ILoggingBuilder builder) { builder.AddConfiguration(); @@ -44,7 +44,7 @@ public static ILoggingBuilder AddOmexLogging(this ILoggingBuilder builder) /// /// The extension method argument /// The so that additional calls can be chained - [Obsolete($"{nameof(OmexLogger)} and {nameof(OmexLogEventSource)} are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger.", DiagnosticId = "OMEX188")] + [Obsolete("OmexLogger and OmexLogEventSource are obsolete and pending for removal by 1 July 2024. Please consider using a different Logger.", DiagnosticId = "OMEX188")] public static IServiceCollection AddOmexLogging(this IServiceCollection serviceCollection) { serviceCollection.AddLogging(); From 7d98bbf1586e011c42f209424878dfd6ff350e16 Mon Sep 17 00:00:00 2001 From: Long Do Thanh Date: Tue, 21 May 2024 10:22:37 +0100 Subject: [PATCH 21/21] Resolve comment --- src/Hosting.Services/HostBuilderExtensions.cs | 3 +++ .../Internal/EventSource/ServiceInitializationEventSource.cs | 1 + 2 files changed, 4 insertions(+) diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index f0643219f..6fb4ede52 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -103,6 +103,9 @@ private static IHost BuildServiceFabricService( options.ValidateOnBuild = true; options.ValidateScopes = true; }) +#pragma warning disable OMEX188 // AddOmexLogging using OmexLogger is obsolete. DiagnosticId = "OMEX188" + .ConfigureLogging(builder => builder.AddOmexLogging()) +#pragma warning restore OMEX188 // AddOmexLogging using OmexLogger is obsolete. DiagnosticId = "OMEX188" .Build(); #pragma warning disable OMEX188 // InitializationLogger using OmexLogger is obsolete. DiagnosticId = "OMEX188" diff --git a/src/Logging/Internal/EventSource/ServiceInitializationEventSource.cs b/src/Logging/Internal/EventSource/ServiceInitializationEventSource.cs index db9c18399..1bb7f6da3 100644 --- a/src/Logging/Internal/EventSource/ServiceInitializationEventSource.cs +++ b/src/Logging/Internal/EventSource/ServiceInitializationEventSource.cs @@ -11,6 +11,7 @@ namespace Microsoft.Omex.Extensions.Logging /// Service Fabric event source /// [EventSource(Name = "Microsoft-OMEX-HostLogs")] + [Obsolete($"{nameof(ServiceInitializationEventSource)} is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")] internal sealed class ServiceInitializationEventSource : EventSource { ///