Skip to content

Commit

Permalink
Merge pull request #1490 from microsoft/develop
Browse files Browse the repository at this point in the history
merge DEVELOP to MASTER (prep 2.12 stable)
  • Loading branch information
TimothyMothra authored Dec 6, 2019
2 parents 89d3d63 + 376eb5b commit da00d03
Show file tree
Hide file tree
Showing 54 changed files with 634 additions and 512 deletions.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Fix Issue # .
<Short description of the fix.>

- [ ] I ran Unit Tests locally.
- [ ] CHANGELOG.md updated with one line description of the fix, and a link to the original issue if available.

For significant contributions please make sure you have completed the following items:

- [ ] Design discussion issue #
- [ ] Changes in public surface reviewed
- [ ] CHANGELOG.md updated with one line description of the fix, and a link to the original issue.

The PR will trigger build, unit tests, and functional tests automatically. Please follow [these](https://github.com/Microsoft/ApplicationInsights-dotnet/blob/develop/.github/CONTRIBUTING.md) instructions to build and test locally.

Notes for reviewers:

- We support [comment build triggers](https://docs.microsoft.com/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#comment-triggers)
- `/AzurePipelines run` will queue all builds
- `/AzurePipelines run <pipeline-name>` will queue a specific build
2 changes: 1 addition & 1 deletion .props/_GlobalStaticVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<SemanticVersionMajor>2</SemanticVersionMajor>
<SemanticVersionMinor>12</SemanticVersionMinor> <!-- If changing the Minor version, also update the Date value. -->
<SemanticVersionPatch>0</SemanticVersionPatch>
<PreReleaseMilestone>beta4</PreReleaseMilestone> <!--Valid values: beta1, beta2, EMPTY for stable -->
<PreReleaseMilestone></PreReleaseMilestone> <!--Valid values: beta1, beta2, EMPTY for stable -->
<!--
Date when Semantic Version was changed.
Update for every MINOR release.
Expand Down
14 changes: 0 additions & 14 deletions BASE/.github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="CompareNETObjects" Version="4.64.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" />
<PackageReference Include="Moq" Version="4.10.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="16.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="CompareNETObjects" Version="4.64.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" />
<PackageReference Include="Moq" Version="4.10.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Microsoft.ApplicationInsights.Common
{
using System;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class InterlockedThrottleTests
{
[TestMethod]
public void VerifyInterlockedWorksAsExpected()
{
int testInterval = 10;
var counter = 0;

var its = new InterlockedThrottle(TimeSpan.FromSeconds(testInterval));

its.PerformThrottledAction(() => counter++);
its.PerformThrottledAction(() => counter++);
its.PerformThrottledAction(() => counter++);
its.PerformThrottledAction(() => counter++);

Assert.AreEqual(1, counter);

Thread.Sleep(TimeSpan.FromSeconds(testInterval +1));

its.PerformThrottledAction(() => counter++);
its.PerformThrottledAction(() => counter++);
its.PerformThrottledAction(() => counter++);
its.PerformThrottledAction(() => counter++);

Assert.AreEqual(2, counter);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void AssignmentWillCastSuccessToResult()
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]

public void AvailabilityTelemetryDeepCloneCopiesAllProperties()
{
AvailabilityTelemetry telemetry = CreateAvailabilityTelemetry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ public void DependencyTelemetryGetUnsetOperationDetail()
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void DependencyTelemetryDeepCloneCopiesAllProperties()
{
DependencyTelemetry telemetry = CreateRemoteDependencyTelemetry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ public void EventTelemetryImplementsISupportAdvancedSamplingContract()
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void EventTelemetryDeepCloneCopiesAllProperties()
{
var eventTelemetry = new EventTelemetry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ public void ExceptionTelemetryHasCorrectValueOfSamplingPercentageAfterSerializat
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void ExceptionTelemetryDeepCloneCopiesAllProperties()
{
var telemetry = CreateExceptionTelemetry(CreateExceptionWithStackTrace());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ public void CountPropertyGetterReturnsOneIfNoValueIsSet()
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void MetricTelemetryDeepCloneCopiesAllProperties()
{
var metric = new MetricTelemetry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public void PageViewPerformanceTelemetryHasCorrectValueOfSamplingPercentageAfter
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void PageViewPerformanceTelemetryDeepCloneCopiesAllProperties()
{
var pageView = new PageViewPerformanceTelemetry("My Page");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ public void PageViewTelemetryHasCorrectValueOfSamplingPercentageAfterSerializati
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void PageViewTelemetryDeepCloneCopiesAllProperties()
{
var pageView = new PageViewTelemetry("My Page");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public void ContextPropertiesUsedAsTelemetryItemProperties()
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void PerformanceCounterTelemetryDeepCloneCopiesAllProperties()
{
PerformanceCounterTelemetry item = new PerformanceCounterTelemetry("someCategory", "someCounter", "an instance", 15.7);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ public void RequestTelemetryHasCorrectValueOfSamplingPercentageAfterSerializatio
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void RequestTelemetryDeepCloneCopiesAllProperties()
{
RequestTelemetry request = CreateTestTelemetry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public void SerializeWritesStateAsExpectedByEndpoint()
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void SessionStateTelemetryDeepCloneCopiesAllProperties()
{
var telemetry = new SessionStateTelemetry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ public void TraceTelemetryHasCorrectValueOfSamplingPercentageAfterSerialization(
}

[TestMethod]
[Ignore("This test throws OutOfMemoryException")]
public void TraceTelemetryDeepCloneCopiesAllProperties()
{
var trace = new TraceTelemetry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)ActivityExtensionsTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\InterlockedThrottleTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DataContracts\PageViewPerformanceTelemetryTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensibility\Implementation\DictionarySerializationWriterTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensibility\Implementation\Endpoints\EndpointContainerTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="CompareNETObjects" Version="4.64.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Net.Security" Version="4.3.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="CompareNETObjects" Version="4.59.0" />
<PackageReference Include="CompareNETObjects" Version="4.64.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions BASE/src/Common/Common/Common.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ExceptionExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)InterlockedThrottle.cs" />
</ItemGroup>
</Project>
34 changes: 34 additions & 0 deletions BASE/src/Common/Common/InterlockedThrottle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Microsoft.ApplicationInsights.Common
{
using System;
using System.Threading;

/// <summary>
/// This class will hold a timestamp and will perform a given action only if the current time has exceeded an interval.
/// </summary>
internal class InterlockedThrottle
{
private readonly TimeSpan interval;
private long timeStamp = DateTimeOffset.MinValue.Ticks;

/// <summary>
/// Initializes a new instance of the <see cref="InterlockedThrottle"/> class.
/// </summary>
/// <param name="interval">Defines the time period to perform some action.</param>
public InterlockedThrottle(TimeSpan interval) => this.interval = interval;

/// <summary>
/// Will execute the action only if the time period has elapsed.
/// </summary>
/// <param name="action">Action to be executed.</param>
public void PerformThrottledAction(Action action)
{
var now = DateTimeOffset.UtcNow;
if (now.Ticks > Interlocked.Read(ref this.timeStamp))
{
Interlocked.Exchange(ref this.timeStamp, now.Add(this.interval).Ticks);
action();
}
}
}
}
12 changes: 12 additions & 0 deletions BASE/src/Microsoft.ApplicationInsights/Channel/InMemoryChannel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace Microsoft.ApplicationInsights.Channel
{
using System;
using System.Diagnostics;
using Microsoft.ApplicationInsights.Common;
using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing;

/// <summary>
Expand All @@ -11,6 +13,9 @@ public class InMemoryChannel : ITelemetryChannel
{
private readonly TelemetryBuffer buffer;
private readonly InMemoryTransmitter transmitter;

private readonly InterlockedThrottle throttleEmptyIkeyLog = new InterlockedThrottle(interval: TimeSpan.FromSeconds(30));

private bool? developerMode = false;
private int bufferSize;

Expand Down Expand Up @@ -139,6 +144,13 @@ public void Send(ITelemetry item)
{
CoreEventSource.Log.ItemRejectedNoInstrumentationKey(item.ToString());
}
else
{
if (!Debugger.IsAttached)
{
this.throttleEmptyIkeyLog.PerformThrottledAction(() => CoreEventSource.Log.TelemetryChannelNoInstrumentationKey());
}
}

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,12 @@ public void InitializationIsSkippedForSampledItem(string appDomainName = "Incorr
[Event(55, Message = "TelemetryConfigurationFactory overwrote the InstrumentationKey with a value from an Environment Variable: {0}", Level = EventLevel.Informational)]
public void TelemetryConfigurationFactoryFoundInstrumentationKeyEnvironmentVariable(string variableName, string appDomainName = "Incorrect") => this.WriteEvent(55, variableName, this.nameProvider.Name);

[Event(56, Message = "TelemetryConfigurationFactory could not find an InstrumentationKey. This needs to be manually set.", Level = EventLevel.Warning, Keywords = Keywords.UserActionable)]
[Event(56, Message = "TelemetryConfigurationFactory did not find an InstrumentationKey in your config file. This needs to be set in either your config file or at application startup.", Level = EventLevel.Warning, Keywords = Keywords.UserActionable)]
public void TelemetryConfigurationFactoryNoInstrumentationKey(string appDomainName = "Incorrect") => this.WriteEvent(56, this.nameProvider.Name);

[Event(57, Message = "TelemetryChannel found a telemetry item without an InstrumentationKey. This is a required field and must be set in either your config file or at application startup.", Level = EventLevel.Error, Keywords = Keywords.UserActionable)]
public void TelemetryChannelNoInstrumentationKey(string appDomainName = "Incorrect") => this.WriteEvent(57, this.nameProvider.Name);

/// <summary>
/// Keywords for the PlatformEventSource.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,12 @@ public void SamplingConfigErrorBothTypes(string appDomainName = "Incorrect")
this.WriteEvent(73, this.ApplicationName);
}

[Event(74, Message = "TelemetryChannel found a telemetry item without an InstrumentationKey. This is a required field and must be set in either your config file or at application startup.", Level = EventLevel.Error, Keywords = Keywords.UserActionable)]
public void TelemetryChannelNoInstrumentationKey(string appDomainName = "Incorrect")
{
this.WriteEvent(74, this.ApplicationName);
}

private static string GetApplicationName()
{
//// We want to add application name to all events BUT
Expand Down
11 changes: 11 additions & 0 deletions BASE/src/ServerTelemetryChannel/ServerTelemetryChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
{
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Common;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation;

Expand All @@ -17,6 +19,8 @@ public sealed class ServerTelemetryChannel : ITelemetryChannel, ITelemetryModule
internal TelemetryBuffer TelemetryBuffer;
internal Transmitter Transmitter;

private readonly InterlockedThrottle throttleEmptyIkeyLog = new InterlockedThrottle(interval: TimeSpan.FromSeconds(30));

private bool? developerMode;
private int telemetryBufferCapacity;
private ITelemetryProcessor telemetryProcessor;
Expand Down Expand Up @@ -269,6 +273,13 @@ public void Send(ITelemetry item)
{
TelemetryChannelEventSource.Log.ItemRejectedNoInstrumentationKey(item.ToString());
}
else
{
if (!Debugger.IsAttached)
{
this.throttleEmptyIkeyLog.PerformThrottledAction(() => TelemetryChannelEventSource.Log.TelemetryChannelNoInstrumentationKey());
}
}

return;
}
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## VNext


## Version 2.12.0
- [Fix IndexOutOfRangeException in W3CUtilities.TryGetTraceId](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1327)
- [Fix UpdateRequestTelemetryFromRequest throwing UriFormatException](https://github.com/microsoft/ApplicationInsights-dotnet/issues/1328)
- [Add ETW log for missing Instrumentation Key](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1331)
- [Remove HttpContext lock from AzureAppServiceRoleNameFromHostNameHeaderInitializer](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1340)

## Version 2.12.0-beta4
- [Add support for collecting convention-based Azure SDK activities.](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1300)
- [Log4Net includes Message for ExceptionTelemetry](https://github.com/microsoft/ApplicationInsights-dotnet/pull/1315)
Expand Down
18 changes: 0 additions & 18 deletions NETCORE/.github/ISSUE_TEMPLATE.md

This file was deleted.

Loading

0 comments on commit da00d03

Please sign in to comment.