From b1662aced1696dc0c9075276a96290cb298a6e9a Mon Sep 17 00:00:00 2001 From: Ramjot Singh Date: Thu, 20 Dec 2018 12:41:41 -0800 Subject: [PATCH] Taking PR comments --- .../ApplicationInsightsLoggerOptions.cs | 2 +- ...icationInsightsLoggingBuilderExtensions.cs | 22 +++++++++---------- src/ILogger/ILogger.csproj | 7 ++++-- .../ILoggerIntegrationTests.cs | 8 ++++++- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/ILogger/ApplicationInsightsLoggerOptions.cs b/src/ILogger/ApplicationInsightsLoggerOptions.cs index 48dcfee..838d9b3 100644 --- a/src/ILogger/ApplicationInsightsLoggerOptions.cs +++ b/src/ILogger/ApplicationInsightsLoggerOptions.cs @@ -22,7 +22,7 @@ namespace Microsoft.Extensions.Logging.ApplicationInsights public bool TrackExceptionsAsExceptionTelemetry { get; set; } = true; /// - /// Gets or sets a value indicating whether the Scope information is excluded from telemetry or not. + /// Gets or sets a value indicating whether the Scope information is included from telemetry or not. /// Defaults to true. /// public bool IncludeScopes { get; set; } = true; diff --git a/src/ILogger/ApplicationInsightsLoggingBuilderExtensions.cs b/src/ILogger/ApplicationInsightsLoggingBuilderExtensions.cs index 1e3c14f..80e65e2 100644 --- a/src/ILogger/ApplicationInsightsLoggingBuilderExtensions.cs +++ b/src/ILogger/ApplicationInsightsLoggingBuilderExtensions.cs @@ -48,30 +48,30 @@ namespace Microsoft.Extensions.Logging /// /// The to use. /// Application insights instrumentation key. - /// Action to configure ApplicationInsights logger. + /// Action to configure ApplicationInsights logger. /// Logging builder with Application Insights added to it. public static ILoggingBuilder AddApplicationInsights( this ILoggingBuilder builder, string instrumentationKey, - Action configureApplicationInsightsOptions) + Action configureApplicationInsightsLoggerOptions) { return builder.AddApplicationInsights( (telemetryConfiguration) => telemetryConfiguration.InstrumentationKey = instrumentationKey, - configureApplicationInsightsOptions); + configureApplicationInsightsLoggerOptions); } /// /// Adds an ApplicationInsights logger named 'ApplicationInsights' to the factory. /// /// The to use. - /// Action to configure ApplicationInsights logger. + /// Action to configure ApplicationInsights logger. public static ILoggingBuilder AddApplicationInsights( this ILoggingBuilder builder, - Action configureApplicationInsightsOptions) + Action configureApplicationInsightsLoggerOptions) { return builder.AddApplicationInsights( (telemetryConfiguration) => { }, - configureApplicationInsightsOptions); + configureApplicationInsightsLoggerOptions); } /// @@ -79,22 +79,22 @@ namespace Microsoft.Extensions.Logging /// /// The to use. /// Action to configure telemetry configuration. - /// Action to configure ApplicationInsights logger. + /// Action to configure ApplicationInsights logger. private static ILoggingBuilder AddApplicationInsights( this ILoggingBuilder builder, Action configureTelemetryConfiguration, - Action configureApplicationInsightsOptions) + Action configureApplicationInsightsLoggerOptions) { - if (configureApplicationInsightsOptions == null) + if (configureApplicationInsightsLoggerOptions == null) { - throw new ArgumentNullException(nameof(configureApplicationInsightsOptions)); + throw new ArgumentNullException(nameof(configureApplicationInsightsLoggerOptions)); } // Initialize IOptions user can keep on configuring it furthur if they want to. builder.Services.Configure(configureTelemetryConfiguration); builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); - builder.Services.Configure(configureApplicationInsightsOptions); + builder.Services.Configure(configureApplicationInsightsLoggerOptions); return builder; } diff --git a/src/ILogger/ILogger.csproj b/src/ILogger/ILogger.csproj index 4699618..e461f8d 100644 --- a/src/ILogger/ILogger.csproj +++ b/src/ILogger/ILogger.csproj @@ -30,8 +30,11 @@ Application Insights ILogger allows forwarding events from ILogger to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156 $(PackageTags) ILogger ILoggerBuilder ILoggerProvider - - + + + full + true + false diff --git a/test/ILogger.NetStandard.Tests/ILoggerIntegrationTests.cs b/test/ILogger.NetStandard.Tests/ILoggerIntegrationTests.cs index 15a32db..4c057c0 100644 --- a/test/ILogger.NetStandard.Tests/ILoggerIntegrationTests.cs +++ b/test/ILogger.NetStandard.Tests/ILoggerIntegrationTests.cs @@ -163,6 +163,9 @@ namespace Microsoft.ApplicationInsights Assert.AreEqual(" => TestScope", (itemsReceived[1] as ISupportProperties).Properties["Scope"]); Assert.AreEqual("Value", (itemsReceived[1] as ISupportProperties).Properties["Key"]); + + Assert.AreEqual("Testing", (itemsReceived[0] as TraceTelemetry).Message); + Assert.AreEqual("Exception", (itemsReceived[1] as ExceptionTelemetry).Message); } /// @@ -171,7 +174,7 @@ namespace Microsoft.ApplicationInsights /// [TestMethod] [TestCategory("ILogger")] - public void ApplicationInsightsLoggerAddsScopeWhenSwitchIsFalse() + public void ApplicationInsightsLoggerDoesNotAddScopeWhenSwitchIsFalse() { List itemsReceived = new List(); @@ -197,6 +200,9 @@ namespace Microsoft.ApplicationInsights Assert.IsFalse((itemsReceived[1] as ISupportProperties).Properties.ContainsKey("Scope")); Assert.IsFalse((itemsReceived[1] as ISupportProperties).Properties.ContainsKey("Key")); + + Assert.AreEqual("Testing", (itemsReceived[0] as TraceTelemetry).Message); + Assert.AreEqual("Exception", (itemsReceived[1] as ExceptionTelemetry).Message); } ///