-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add AspNetCore environment initializer, AuthScript support, Prevent debug logging if instrumentation key exists, Disable debug logger if other loggers are being added to ILoggerFactory * Fix nullref while retrieving ApplicationVersion * Rev package version * Do not use extension method to add debug logger * Fix spelling * Fix param comments * Comments
- Loading branch information
Showing
14 changed files
with
266 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Microsoft.ApplicationInsights.AspNetCore/Logging/Implementation/DebugLoggerControl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Microsoft.ApplicationInsights.AspNetCore.Logging | ||
{ | ||
using Microsoft.Extensions.Logging; | ||
|
||
/// <summary> | ||
/// Class to control default debug logger and disable it if logger was added to <see cref="ILoggerFactory"/> explicetely. | ||
/// </summary> | ||
internal class DebugLoggerControl | ||
{ | ||
public DebugLoggerControl() | ||
{ | ||
EnableDebugLogger = true; | ||
} | ||
|
||
/// <summary> | ||
/// This property gets set to <code>false</code> by <see cref="ApplicationInsightsLoggerFactoryExtensions.AddApplicationInsights"/>. | ||
/// </summary> | ||
public bool EnableDebugLogger { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Microsoft.ApplicationInsights.AspNetCore/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ionInsights.AspNetCore/TelemetryInitializers/AspNetCoreEnvironmentTelemetryInitializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers | ||
{ | ||
using Microsoft.ApplicationInsights.Channel; | ||
using Microsoft.ApplicationInsights.Extensibility; | ||
using Microsoft.AspNetCore.Hosting; | ||
|
||
/// <summary> | ||
/// <see cref="ITelemetryInitializer"/> implementation that stamps ASP.NET Core environment name | ||
/// on telemetries. | ||
/// </summary> | ||
internal class AspNetCoreEnvironmentTelemetryInitializer: ITelemetryInitializer | ||
{ | ||
private const string AspNetCoreEnvironmentPropertyName = "AspNetCoreEnvironment"; | ||
private readonly IHostingEnvironment environment; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AspNetCoreEnvironmentTelemetryInitializer"/> class. | ||
/// </summary> | ||
public AspNetCoreEnvironmentTelemetryInitializer(IHostingEnvironment environment) | ||
{ | ||
this.environment = environment; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public void Initialize(ITelemetry telemetry) | ||
{ | ||
if (environment != null && !telemetry.Context.Properties.ContainsKey(AspNetCoreEnvironmentPropertyName)) | ||
{ | ||
telemetry.Context.Properties.Add(AspNetCoreEnvironmentPropertyName, environment.EnvironmentName); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.