Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #668 from Microsoft/develop
Browse files Browse the repository at this point in the history
Dev to master for 2.3.0-beta2
  • Loading branch information
cijothomas authored May 3, 2018
2 parents 63f1905 + ae979f0 commit 4be93dd
Show file tree
Hide file tree
Showing 18 changed files with 263 additions and 461 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Version 2.3.0-beta2
- [Update System.Net.Http version referred to 4.3.2 as older version has known security vulnerability. ](https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/666)
- [Added ApplicationInsightsServiceOptions flag to turn off AutoCollectedMetricExtractor. ](https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/664)
- [Added two AdaptiveSamplingTelemetryProcessors one for Event and one for non Event types to be consistent with default Web SDK behaviour. ](https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/663)
- [RequestCollection is refactored to be implemented as an ITelemetryModule. This makes it possible to configure it like every other auto-collection modules. ](https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/650)
- [Fixed race condition on dispose to close #651](https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/652)
-Removed DomainNameRoleInstanceTelemetryInitializer as it is deprecated.
-Reuse AzureWebAppRoleEnvironmentTelemetryInitializer from WindowsServer repo instead of outdated implementation in this repo.
- Updated Web/Base SDK version dependency to 2.6.0-beta4

## Version 2.3.0-beta1
- Changed behavior for `TelemetryConfiguration.Active` and `TelemetryConfiguration` dependency injection singleton: with this version every WebHost has its own `TelemetryConfiguration` instance. Changes done for `TelemetryConfiguration.Active` do not affect telemetry reported by the SDK; use `TelemetryConfiguration` instance obtained through the dependency injection. [Fix NullReferenceException when sending http requests in scenario with multiple web hosts sharing the same process](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/613)
- Updated Javascript Snippet with latest from [Github/ApplicationInsights-JS](https://github.com/Microsoft/ApplicationInsights-JS)
Expand All @@ -15,6 +25,7 @@
- [QuickPulseTelemetryModule is constructed via DI, make it possible for users to configure it.] (https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/639)
- [Remove CorrelationIdLookupHelper. Use TelemetryConfiguration.ApplicationIdProvider instead.](https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/636) With this change you can update URL to query application ID from which enables environments with reverse proxy configuration to access Application Insights ednpoints.
- [AutocollectedMetricsExtractor is added by default to the TelemetryConfiguration](https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/604)
- Updated Web/Base SDK version dependency to 2.6.0-beta3

## Version 2.2.1
- Updated Web/Base SDK version dependency to 2.5.1 which addresses a bug.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ public static IServiceCollection AddApplicationInsightsTelemetry(this IServiceCo
{
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();

services.AddSingleton<ITelemetryInitializer, ApplicationInsights.AspNetCore.TelemetryInitializers.AzureWebAppRoleEnvironmentTelemetryInitializer>();
services.AddSingleton<ITelemetryInitializer, ApplicationInsights.AspNetCore.TelemetryInitializers.DomainNameRoleInstanceTelemetryInitializer>();
services.AddSingleton<ITelemetryInitializer, AzureWebAppRoleEnvironmentTelemetryInitializer>();
services.AddSingleton<ITelemetryInitializer, ComponentVersionTelemetryInitializer>();
services.AddSingleton<ITelemetryInitializer, ClientIpHeaderTelemetryInitializer>();
services.AddSingleton<ITelemetryInitializer, OperationNameTelemetryInitializer>();
Expand All @@ -146,7 +145,7 @@ public static IServiceCollection AddApplicationInsightsTelemetry(this IServiceCo
services.AddSingleton<ITelemetryInitializer, AspNetCoreEnvironmentTelemetryInitializer>();
services.AddSingleton<ITelemetryInitializer, HttpDependenciesParsingTelemetryInitializer>();
services.TryAddSingleton<ITelemetryChannel, ServerTelemetryChannel>();
services.AddApplicationInsightsTelemetryProcessor<AutocollectedMetricsExtractor>();

services.AddSingleton<ITelemetryModule, DependencyTrackingTelemetryModule>();
services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module) => {
var excludedDomains = module.ExcludeComponentCorrelationHttpHeadersOnDomains;
Expand All @@ -168,15 +167,14 @@ public static IServiceCollection AddApplicationInsightsTelemetry(this IServiceCo
services.AddSingleton<ITelemetryModule, AppServicesHeartbeatTelemetryModule>();
services.AddSingleton<ITelemetryModule, AzureInstanceMetadataTelemetryModule>();
services.AddSingleton<ITelemetryModule, QuickPulseTelemetryModule>();
services.AddSingleton<ITelemetryModule, RequestTrackingTelemetryModule>();
services.AddSingleton<TelemetryConfiguration>(provider => provider.GetService<IOptions<TelemetryConfiguration>>().Value);

services.TryAddSingleton<IApplicationIdProvider, ApplicationInsightsApplicationIdProvider>();

services.AddSingleton<TelemetryClient>();

services.AddSingleton<ApplicationInsightsInitializer, ApplicationInsightsInitializer>();
services.AddSingleton<IApplicationInsightDiagnosticListener, HostingDiagnosticListener>();
services.AddSingleton<IApplicationInsightDiagnosticListener, MvcDiagnosticsListener>();
services.AddSingleton<ApplicationInsightsDebugLogger, ApplicationInsightsDebugLogger>();

// Using startup filter instead of starting DiagnosticListeners directly because
// AspNetCoreHostingDiagnosticListener injects TelemetryClient that injects TelemetryConfiguration
Expand Down Expand Up @@ -357,8 +355,8 @@ internal static void AddTelemetryConfiguration(IConfiguration config, Applicatio

private static bool IsApplicationInsightsAdded(IServiceCollection services)
{
// We treat ApplicationInsightsInitializer as a marker that AI services were added to service collection
return services.Any(service => service.ServiceType == typeof(ApplicationInsightsInitializer));
// We treat ApplicationInsightsDebugLogger as a marker that AI services were added to service collection
return services.Any(service => service.ServiceType == typeof(ApplicationInsightsDebugLogger));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public ApplicationInsightsServiceOptions()
this.EnableDebugLogger = true;
this.EnableAuthenticationTrackingJavaScript = false;
this.EnableHeartbeat = true;
this.AddAutoCollectedMetricExtractor = true;
this.ApplicationVersion = Assembly.GetEntryAssembly()?.GetName().Version.ToString();
}

Expand Down Expand Up @@ -69,5 +70,10 @@ public ApplicationInsightsServiceOptions()
/// Gets or sets a value indicating whether heartbeats are enabled.
/// </summary>
public bool EnableHeartbeat { get; set; }

/// <summary>
/// Gets or sets a value indicating whether AutoCollectedMetricExtractor are added or not.
/// </summary>
public bool AddAutoCollectedMetricExtractor { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace Microsoft.ApplicationInsights.AspNetCore
{
using System;
using System.Diagnostics;
using Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

/// <summary>
/// Class used to enable Application Insight loggers while debugging.
/// </summary>
internal class ApplicationInsightsDebugLogger
{
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationInsightsDebugLogger"/> class.
/// </summary>
public ApplicationInsightsDebugLogger(
IOptions<ApplicationInsightsServiceOptions> options,
ILoggerFactory loggerFactory,
IServiceProvider serviceProvider)
{
// Add default logger factory for debug mode only if enabled and instrumentation key not set
if (options.Value.EnableDebugLogger && string.IsNullOrEmpty(options.Value.InstrumentationKey))
{
// Do not use extension method here or it will disable debug logger we currently adding
var enableDebugLogger = true;
loggerFactory.AddApplicationInsights(serviceProvider, (s, level) => enableDebugLogger && Debugger.IsAttached, () => enableDebugLogger = false);
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Microsoft.ApplicationInsights.AspNetCore
{
using System;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -15,8 +16,11 @@ public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
{
return app =>
{
var appInsightsInitializer = app.ApplicationServices.GetService<ApplicationInsightsInitializer>();
appInsightsInitializer.Start();
// Attemping to resolve TelemetryConfiguration triggers configuration of the same
// via <see cref="TelemetryConfigurationOptionsSetup"/> class which triggers
// initialization of TelemetryModules and construction of TelemetryProcessor pipeline.
var tc = app.ApplicationServices.GetService<TelemetryConfiguration>();
var applicationInsightsDebugLogger = app.ApplicationServices.GetService<ApplicationInsightsDebugLogger>();
next(app);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public void Configure(TelemetryConfiguration configuration)
configuration.TelemetryChannel = this.telemetryChannel ?? configuration.TelemetryChannel;
(configuration.TelemetryChannel as ITelemetryModule)?.Initialize(configuration);

this.AddAutoCollectedMetricExtractor(configuration);
this.AddQuickPulse(configuration);
this.AddSampling(configuration);
this.DisableHeartBeatIfConfigured();
Expand Down Expand Up @@ -149,7 +150,16 @@ private void AddSampling(TelemetryConfiguration configuration)
{
if (this.applicationInsightsServiceOptions.EnableAdaptiveSampling)
{
configuration.TelemetryProcessorChainBuilder.UseAdaptiveSampling();
configuration.TelemetryProcessorChainBuilder.UseAdaptiveSampling(5, excludedTypes: "Event");
configuration.TelemetryProcessorChainBuilder.UseAdaptiveSampling(5, includedTypes: "Event");
}
}

private void AddAutoCollectedMetricExtractor(TelemetryConfiguration configuration)
{
if (this.applicationInsightsServiceOptions.AddAutoCollectedMetricExtractor)
{
configuration.TelemetryProcessorChainBuilder.Use(next => new AutocollectedMetricsExtractor(next));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<Description>Application Insights for ASP.NET Core web applications. See https://azure.microsoft.com/documentation/articles/app-insights-asp-net-five/ for more information. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156</Description>
<Copyright>Copyright © Microsoft. All Rights Reserved.</Copyright>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<AssemblyTitle>Application Insights for ASP.NET Core Web Applications</AssemblyTitle>
<VersionPrefix>2.3.0-beta1</VersionPrefix>
<VersionPrefix>2.3.0-beta2</VersionPrefix>
<Authors>Microsoft</Authors>
<TargetFrameworks>net451;net46;netstandard1.6</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.6</TargetFrameworks>
Expand Down Expand Up @@ -72,15 +72,15 @@
<PackageReference Include="System.Threading.Tasks.Analyzers" Version="1.2.0-beta2">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.6.0-beta3" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.0-beta3" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.6.0-beta3" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.6.0-beta3" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.6.0-beta3" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.6.0-beta4" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.0-beta4" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.6.0-beta4" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.6.0-beta4" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.6.0-beta4" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' OR '$(TargetFramework)' == 'net46' ">
<PackageReference Include="System.Net.Http" Version="4.3.1" />
<PackageReference Include="System.Net.Http" Version="4.3.2" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 4be93dd

Please sign in to comment.