diff --git a/src/Activities/Microsoft.Omex.Extensions.Activities.csproj b/src/Activities/Microsoft.Omex.Extensions.Activities.csproj
index 07090e8a..0b3f5c77 100644
--- a/src/Activities/Microsoft.Omex.Extensions.Activities.csproj
+++ b/src/Activities/Microsoft.Omex.Extensions.Activities.csproj
@@ -12,6 +12,7 @@
Microsoft;Omex;Extensions;Activities
+
diff --git a/src/Activities/Option/ActivityOption.cs b/src/Activities/Option/ActivityOption.cs
index 49f5679e..60ce4b24 100644
--- a/src/Activities/Option/ActivityOption.cs
+++ b/src/Activities/Option/ActivityOption.cs
@@ -6,7 +6,7 @@ namespace Microsoft.Omex.Extensions.Activities
///
/// Monitoring option
///
- public class ActivityOption
+ internal class ActivityOption
{
///
/// Path to the setting
diff --git a/src/Activities/ServiceCollectionExtensions.cs b/src/Activities/ServiceCollectionExtensions.cs
index a0f14de5..59a855a0 100644
--- a/src/Activities/ServiceCollectionExtensions.cs
+++ b/src/Activities/ServiceCollectionExtensions.cs
@@ -45,7 +45,8 @@ namespace Microsoft.Extensions.DependencyInjection
serviceCollection
.AddOptions()
.BindConfiguration(ActivityOption.MonitoringPath)
- .ValidateDataAnnotations();
+ .ValidateDataAnnotations()
+ .ValidateOnStart();
serviceCollection.TryAddSingleton();
serviceCollection.TryAddSingleton(p => new ActivitySource(ActivitySourceName, ActivitySourceVersion));
diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs
index 9990d544..f568e86d 100644
--- a/src/Hosting.Services/HostBuilderExtensions.cs
+++ b/src/Hosting.Services/HostBuilderExtensions.cs
@@ -101,6 +101,7 @@ namespace Microsoft.Omex.Extensions.Hosting.Services
options.ValidateOnBuild = true;
options.ValidateScopes = true;
})
+ .ConfigureLogging(builder => builder.AddOmexLogging())
.Build();
InitializationLogger.LogInitializationSucceed(serviceNameForLogging);
diff --git a/src/Logging/Internal/OmexLoggerProvider.cs b/src/Logging/Internal/OmexLoggerProvider.cs
index db37bd43..17190655 100644
--- a/src/Logging/Internal/OmexLoggerProvider.cs
+++ b/src/Logging/Internal/OmexLoggerProvider.cs
@@ -8,6 +8,7 @@ using Microsoft.Omex.Extensions.Logging.Scrubbing;
namespace Microsoft.Omex.Extensions.Logging
{
+ [ProviderAlias("Omex")]
internal class OmexLoggerProvider : ILoggerProvider, ISupportExternalScope
{
public OmexLoggerProvider(
@@ -18,8 +19,8 @@ namespace Microsoft.Omex.Extensions.Logging
{
m_logsEventSender = logsEventSender;
m_defaultExternalScopeProvider = defaultExternalScopeProvider;
- m_replayer = replayer;
m_textScrubbers = textScrubbers;
+ m_replayer = replayer;
}
public ILogger CreateLogger(string categoryName) =>
@@ -30,9 +31,10 @@ namespace Microsoft.Omex.Extensions.Logging
public void SetScopeProvider(IExternalScopeProvider scopeProvider) => m_externalScopeProvider = scopeProvider;
private IExternalScopeProvider? m_externalScopeProvider;
+
+ private readonly ILogEventSender m_logsEventSender;
private readonly IExternalScopeProvider m_defaultExternalScopeProvider;
private readonly IEnumerable m_textScrubbers;
private readonly ILogEventReplayer? m_replayer;
- private readonly ILogEventSender m_logsEventSender;
}
}
diff --git a/src/Logging/OmexLoggingOptions.cs b/src/Logging/OmexLoggingOptions.cs
index 16f30d3a..140fb2df 100644
--- a/src/Logging/OmexLoggingOptions.cs
+++ b/src/Logging/OmexLoggingOptions.cs
@@ -6,7 +6,7 @@ namespace Microsoft.Omex.Extensions.Logging
///
/// Options for Omex logger
///
- public class OmexLoggingOptions
+ internal class OmexLoggingOptions
{
///
/// Should logs wrapped by the Activity be stored and replayed at a higher severity, in the event of an error.
diff --git a/src/Logging/ServiceCollectionExtensions.cs b/src/Logging/ServiceCollectionExtensions.cs
index b9bdefbc..1543ee39 100644
--- a/src/Logging/ServiceCollectionExtensions.cs
+++ b/src/Logging/ServiceCollectionExtensions.cs
@@ -4,6 +4,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Configuration;
using Microsoft.Omex.Extensions.Abstractions.Activities.Processing;
using Microsoft.Omex.Extensions.Abstractions.ExecutionContext;
using Microsoft.Omex.Extensions.Logging.Replayable;
@@ -31,6 +32,7 @@ namespace Microsoft.Omex.Extensions.Logging
/// The extension method argument
public static ILoggingBuilder AddOmexLogging(this ILoggingBuilder builder)
{
+ builder.AddConfiguration();
builder.Services.AddOmexLogging();
return builder;
}
diff --git a/tests/Activities.UnitTests/ServiceCollectionTests.cs b/tests/Activities.UnitTests/ServiceCollectionTests.cs
index bbc0e240..b5cd0aa4 100644
--- a/tests/Activities.UnitTests/ServiceCollectionTests.cs
+++ b/tests/Activities.UnitTests/ServiceCollectionTests.cs
@@ -32,11 +32,10 @@ namespace Microsoft.Omex.Extensions.Activities.UnitTests
}
[TestMethod]
- public void AddOmexActivitySource_HostedServicesRegiestered()
+ public void AddOmexActivitySource_HostedServicesRegistered()
{
Type[] types = GetRegisteredServices();
- Assert.AreEqual(2, types.Length);
CollectionAssert.Contains(types, typeof(ActivityListenerInitializerService));
CollectionAssert.Contains(types, typeof(DiagnosticsObserversInitializer));
}
@@ -47,7 +46,7 @@ namespace Microsoft.Omex.Extensions.Activities.UnitTests
Task task = CreateHost().RunAsync();
Activity? activity = new ActivitySource("Source")
- .StartActivity(nameof(AddOmexActivitySource_HostedServicesRegiestered));
+ .StartActivity(nameof(AddOmexActivitySource_HostedServicesRegistered));
NullableAssert.IsNotNull(activity, "Activity creation enabled after host started");
}
diff --git a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs
index 3cc04aa9..25b608e0 100644
--- a/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs
+++ b/tests/Hosting.Services.UnitTests/HostBuilderExtensionsTests.cs
@@ -25,7 +25,7 @@ namespace Microsoft.Omex.Extensions.Hosting.Services.UnitTests
[DataRow(typeof(IExecutionContext), typeof(ServiceFabricExecutionContext))]
[DataRow(typeof(ActivitySource), null)]
[DataRow(typeof(ILogger), null)]
- public void AddOmexServiceFabricDependencies_TypesRegistered(Type typeToResolver, Type? expectedImplementationType)
+ public void AddOmexServiceFabricDependencies_TypesRegistered(Type typeToResolve, Type? expectedImplementationType)
{
void CheckTypeRegistration() where TContext : ServiceContext
{
@@ -33,7 +33,7 @@ namespace Microsoft.Omex.Extensions.Hosting.Services.UnitTests
.AddOmexServiceFabricDependencies()
.AddSingleton(new Mock().Object)
.BuildServiceProvider()
- .GetService(typeToResolver);
+ .GetService(typeToResolve);
Assert.IsNotNull(obj, "Failed to resolve for {0}", typeof(TContext));