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

Deprecation message for legacy telemetry #673

Merged
merged 25 commits into from
May 21, 2024
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 @@ -15,6 +15,7 @@

namespace Microsoft.Omex.Extensions.Activities
{
[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<ActivityEventSender> logger, IOptions<ActivityOption> options)
Expand Down
2 changes: 2 additions & 0 deletions src/Activities/Internal/EventSource/ActivityEventSource.cs
Original file line number Diff line number Diff line change
@@ -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.", DiagnosticId = "OMEX188")]
[EventSource(Name = "Microsoft-OMEX-TimedScopes-Ext")]
internal sealed class ActivityEventSource : EventSource
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Diagnostics;

namespace Microsoft.Omex.Extensions.Activities
{
/// <summary>
/// Type created to temporary combine ActivityEventSender and ActivityMetricsSender, it should be deleted after removal for ActivityEventSender
/// </summary>
[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;
Expand Down
7 changes: 5 additions & 2 deletions src/Activities/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ public static IServiceCollection AddOmexActivitySource(this IServiceCollection s

serviceCollection.TryAddSingleton<IExecutionContext, BaseExecutionContext>();

// eventually ActivityMetricsSender will be default implementation of IActivitiesEventSender and we should remove ActivityEventSender, and AggregatedActivitiesEventSender
serviceCollection.TryAddSingleton<ActivityMetricsSender>();

#pragma warning disable OMEX188 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. DiagnosticId = "OMEX188"
serviceCollection.TryAddSingleton<ActivityEventSender>();
serviceCollection.TryAddSingleton<IActivitiesEventSender, AggregatedActivitiesEventSender>();
serviceCollection.TryAddSingleton(p => ActivityEventSource.Instance);
#pragma warning restore OMEX188 // ActivityEventSender and AggregatedActivitiesEventSender are obsolete and pending for removal by 1 July 2024. DiagnosticId = "OMEX188"

serviceCollection.TryAddSingleton<ICustomBaggageDimensions>(_ => new CustomBaggageDimensions());
serviceCollection.TryAddSingleton<ICustomTagObjectsDimensions>(_ => new CustomTagObjectsDimensions());

Expand All @@ -50,7 +54,6 @@ public static IServiceCollection AddOmexActivitySource(this IServiceCollection s

serviceCollection.TryAddSingleton<IActivityListenerConfigurator, DefaultActivityListenerConfigurator>();
serviceCollection.TryAddSingleton(p => new ActivitySource(ActivitySourceName, ActivitySourceVersion));
serviceCollection.TryAddSingleton(p => ActivityEventSource.Instance);

return serviceCollection;
}
Expand Down
9 changes: 9 additions & 0 deletions src/Hosting.Services/HostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,6 +61,7 @@ public static IServiceCollection AddOmexServiceFabricDependencies<TContext>(this

collection.TryAddSingleton<IServiceContext, OmexServiceFabricContext>();
collection.TryAddSingleton<IExecutionContext, ServiceFabricExecutionContext>();

return collection.AddOmexServices();
}

Expand Down Expand Up @@ -101,16 +103,23 @@ private static IHost BuildServiceFabricService<TRunner, TService, TContext>(
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();
Gnol-VN marked this conversation as resolved.
Show resolved Hide resolved

#pragma warning disable OMEX188 // InitializationLogger using OmexLogger is obsolete. DiagnosticId = "OMEX188"
InitializationLogger.LogInitializationSucceed(serviceNameForLogging);
Gnol-VN marked this conversation as resolved.
Show resolved Hide resolved
Gnol-VN marked this conversation as resolved.
Show resolved Hide resolved
#pragma warning restore OMEX188 // InitializationLogger using OmexLogger is obsolete. DiagnosticId = "OMEX188"
Gnol-VN marked this conversation as resolved.
Show resolved Hide resolved

return host;
}
catch (Exception e)
{
#pragma warning disable OMEX188 // InitializationLogger using OmexLogger is obsolete. DiagnosticId = "OMEX188"
InitializationLogger.LogInitializationFail(serviceNameForLogging, e);
#pragma warning restore OMEX188 // InitializationLogger using OmexLogger is obsolete. DiagnosticId = "OMEX188"

throw;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Hosting/Certificates/InitializationCertificateReader.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,6 +17,8 @@ public static class InitializationCertificateReader
/// <summary>
/// Instance of CertificateReader
/// </summary>
#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.
}
}
3 changes: 3 additions & 0 deletions src/Hosting/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,8 +26,10 @@ public static IHostBuilder AddOmexServices(this IHostBuilder builder) =>
/// Add Omex Logging and ActivitySource dependencies
/// </summary>
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();

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Logging/InitializationLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license.

using System;
using System.Diagnostics;
using Microsoft.Extensions.Logging;
using Microsoft.Omex.Extensions.Abstractions;

Expand All @@ -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.
/// </summary>
[Obsolete($"{nameof(InitializationLogger)} using {nameof(OmexLogger)} is obsolete and is pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")]
public static class InitializationLogger
Gnol-VN marked this conversation as resolved.
Show resolved Hide resolved
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/Logging/Internal/EventSource/OmexLogEventSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/Logging/Internal/EventSource/OmexLogEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.Omex.Extensions.Logging
/// Service Fabric event source
/// </summary>
[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
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/Logging/Internal/OmexLoggerProvider.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.", DiagnosticId = "OMEX188")]
internal class OmexLoggerProvider : ILoggerProvider, ISupportExternalScope
{
public OmexLoggerProvider(
Expand Down
3 changes: 3 additions & 0 deletions src/Logging/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -30,6 +31,7 @@ public static IServiceCollection AddOmexServiceContext<TServiceContext>(this ISe
/// Adds Omex event logger to the factory
/// </summary>
/// <param name="builder">The extension method argument</param>
[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();
Expand All @@ -42,6 +44,7 @@ public static ILoggingBuilder AddOmexLogging(this ILoggingBuilder builder)
/// </summary>
/// <param name="serviceCollection">The extension method argument</param>
/// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained</returns>
[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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -18,6 +19,8 @@ public class ServiceFabricClientFactory
/// Creates service fabric client wrapper instance and returns it.
/// </summary>
public static IServiceFabricClientWrapper Create(ServiceFabricRestClientOptions options) =>
#pragma warning disable OMEX188 // InitializationCertificateReader using OmexLogger is obsolete. DiagnosticId = "OMEX188"
Gnol-VN marked this conversation as resolved.
Show resolved Hide resolved
new ServiceFabricClientWrapper(Options.Create(options), InitializationCertificateReader.Instance);
#pragma warning restore OMEX188 // InitializationCertificateReader using OmexLogger is obsolete. DiagnosticId = "OMEX188"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace Microsoft.Omex.Extensions.Activities.UnitTests
{
[TestClass]
[Obsolete($"{nameof(ActivityEventSender)} is obsolete and pending for removal by 1 July 2024.", DiagnosticId = "OMEX188")]
public class ActivitiesEventSourceTests
{
[DataTestMethod]
Expand Down
1 change: 1 addition & 0 deletions tests/Logging.UnitTests/OmexLogEventSenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.", DiagnosticId = "OMEX188")]
[TestClass]
public class OmexLogEventSenderTests
{
Expand Down
1 change: 1 addition & 0 deletions tests/Logging.UnitTests/OmexLoggerProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Microsoft.Omex.Extensions.Logging.UnitTests
{
[TestClass]
[Obsolete("OmexLogger is Obsolete and pending for removal on 1 July 2024.", DiagnosticId = "OMEX188")]
public class OmexLoggerProviderTests
{
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ public void AddRegexLogScrubbingRule_Scrubs(string input, string expected)

private static ILogScrubbingRule[] GetTypeRegistrations(IServiceCollection collection)
{
#pragma warning disable OMEX188 // AddOmexLogging uses OmexLogger and OmexLogEventSource which are obsolete and pending for removal by 1 July 2024. DiagnosticId = "OMEX188"
IEnumerable<ILogScrubbingRule> objects = collection
.AddOmexLogging()
#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,
Expand Down
11 changes: 9 additions & 2 deletions tests/Logging.UnitTests/ServiceCollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ public void AddOmexServiceContext_RegisterServiceContext()
public void AddOmexServiceContext_OverridesContextType()
{
IServiceCollection collection = new ServiceCollection()
.AddOmexServiceContext<MockServiceContext>()
.AddOmexLogging();
.AddOmexServiceContext<MockServiceContext>();

#pragma warning disable OMEX188 // AddOmexLogging method is obsolete. DiagnosticId = "OMEX188"
collection.AddOmexLogging();
#pragma warning restore OMEX188 // AddOmexLogging method is obsolete. DiagnosticId = "OMEX188"

IServiceContext context = ValidateTypeRegistration<IServiceContext>(collection);

Expand All @@ -35,13 +38,15 @@ public void AddOmexServiceContext_OverridesContextType()
}

[TestMethod]
[Obsolete("AddOmexLogging method is obsolete.", DiagnosticId = "OMEX188")]
public void AddOmexLoggerOnServiceCollection_RegistersLogger()
{
IServiceCollection collection = new ServiceCollection().AddOmexLogging();
ValidateTypeRegistration<ILogger<ServiceCollectionTests>>(collection);
}

[TestMethod]
[Obsolete("AddOmexLogging method is obsolete.", DiagnosticId = "OMEX188")]
public void AddOmexLoggerOnLogBuilder_RegistersLogger()
{
ILoggingBuilder builder = new MockLoggingBuilder().AddOmexLogging();
Expand All @@ -51,8 +56,10 @@ public void AddOmexLoggerOnLogBuilder_RegistersLogger()
private T ValidateTypeRegistration<T>(IServiceCollection collection)
where T : class
{
#pragma warning disable OMEX188 // AddOmexLogging method is obsolete. DiagnosticId = "OMEX188"
T obj = collection
.AddOmexLogging()
#pragma warning restore OMEX188 // AddOmexLogging method is obsolete. DiagnosticId = "OMEX188"
.BuildServiceProvider(new ServiceProviderOptions
{
ValidateOnBuild = true,
Expand Down
Loading