Skip to content

Commit

Permalink
Merge pull request #252 from Microsoft/dnduffy/Release-2-2-0-beta1
Browse files Browse the repository at this point in the history
Release 2.2.0-beta1
  • Loading branch information
dnduffy authored Jul 13, 2016
2 parents f82dd9e + 1041a88 commit e0c9397
Show file tree
Hide file tree
Showing 42 changed files with 1,749 additions and 451 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.user
*.sln.docstates
.vs
*.sln.dotsettings

# Build results
[Dd]ebug/
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

This changelog will be used to generate documentation on [release notes page](http://azure.microsoft.com/en-us/documentation/articles/app-insights-release-notes-dotnet/).


## Version 2.2.0-beta1

- Add ExceptionTelemetry.Message property. If it is provided it is used instead of Exception.Message property for the ounter-most exception.
- Telemetry types can be exluded from sampling by specifing ExcludedTypes property.
- ServerTelemetryChannel: changed backoff logic to be less aggressive, added diagnostics event when backoff logic kicks in and added more tracing. (Done to address issues when data stopps flowing till application gets restarted)

## Version 2.1.0-beta4
- [Bug fix](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/76)

Expand Down
6 changes: 3 additions & 3 deletions GlobalStaticVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
Update for every public release.
-->
<SemanticVersionMajor>2</SemanticVersionMajor>
<SemanticVersionMinor>1</SemanticVersionMinor>
<SemanticVersionMinor>2</SemanticVersionMinor>
<SemanticVersionPatch>0</SemanticVersionPatch>
<PreReleaseMilestone></PreReleaseMilestone>
<PreReleaseMilestone>beta1</PreReleaseMilestone>
<!--
Date when Semantic Version was changed.
Update for every public release.
-->
<SemanticVersionDate>2016-03-08</SemanticVersionDate>
<SemanticVersionDate>2016-06-02</SemanticVersionDate>

<PreReleaseVersionFileName>.PreReleaseVersion</PreReleaseVersionFileName>
<PreReleaseVersionFilePath>$(MSBuildThisFileDirectory)$(PreReleaseVersionFileName)</PreReleaseVersionFilePath>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Read about [how to use the API and see the results in the portal][api-overview].

We strongly welcome and encourage contributions to this project. Please read the [contributor's guide][ContribGuide] located in the ApplicationInsights-Home repository. If making a large change we request that you open an [issue][GitHubIssue] first. We follow the [Git Flow][GitFlow] approach to branching.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

[AILandingPage]: http://azure.microsoft.com/services/application-insights/
[api-overview]: https://azure.microsoft.com/documentation/articles/app-insights-api-custom-events-metrics/
[ContribGuide]: https://github.com/Microsoft/ApplicationInsights-Home/blob/master/CONTRIBUTING.md
Expand Down
10 changes: 10 additions & 0 deletions Test/CoreSDK.Test/Net40/Core.Net40.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
<Reference Include="System.Management" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
Expand Down
1 change: 1 addition & 0 deletions Test/CoreSDK.Test/Net40/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
<package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="1.1.28" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" />
<package id="StyleCop.MSBuild" version="4.7.50.0" targetFramework="net45" developmentDependency="true" />
<package id="xunit.assert" version="2.0.0-beta-build2650" targetFramework="net45" />
Expand Down
9 changes: 3 additions & 6 deletions Test/CoreSDK.Test/Shared/Channel/TransmissionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -158,13 +159,9 @@ public void ThrowsInvalidOperationExceptionWhenTransmissionIsAlreadySending()
{
AsyncTest.Run(async () =>
{
var request = new StubWebRequest();
request.OnBeginGetRequestStream = (callback, state) => TaskEx.Delay(TimeSpan.FromMilliseconds(10)).AsAsyncResult(callback, request);
var transmission = new TestableTransmission();
transmission.OnCreateRequest = uri => request;
Task dontWait = transmission.SendAsync();
FieldInfo isSendingField = typeof(Transmission).GetField("isSending", BindingFlags.NonPublic | BindingFlags.Instance);
isSendingField.SetValue(transmission, 1, BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Instance, null, null);
await AssertEx.ThrowsAsync<InvalidOperationException>(() => transmission.SendAsync());
});
}
Expand Down
50 changes: 50 additions & 0 deletions Test/CoreSDK.Test/Shared/DataContracts/ExceptionTelemetryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,56 @@ public void SerializeWritesItemVersionAsExpectedByEndpoint()
Assert.Equal(2, item.Data.BaseData.Ver);
}

[TestMethod]
public void SerializeUsesExceptionMessageIfTelemetryMessageNotProvided()
{
ExceptionTelemetry original = CreateExceptionTelemetry(new ArgumentException("Test"));
var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(original);

Assert.Equal("Test", item.Data.BaseData.Exceptions[0].Message);
}

[TestMethod]
public void SerializeTelemetryMessageAsOuterExceptionMessage()
{
ExceptionTelemetry original = CreateExceptionTelemetry(new ArgumentException("Test"));
original.Message = "Custom";
var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(original);

Assert.Equal("Custom", item.Data.BaseData.Exceptions[0].Message);
}

[TestMethod]
public void SerializeUsesExceptionMessageForInnerExceptions()
{
Exception outerException = new ArgumentException("Outer", new Exception("Inner"));
ExceptionTelemetry original = CreateExceptionTelemetry(outerException);

original.Message = "Custom";
var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(original);

Assert.Equal("Custom", item.Data.BaseData.Exceptions[0].Message);
Assert.Equal("Inner", item.Data.BaseData.Exceptions[1].Message);
}

[TestMethod]
public void SerializeUsesExceptionMessageForInnerAggregateExceptions()
{
Exception innerException1 = new ArgumentException("Inner1");
Exception innerException2 = new ArgumentException("Inner2");

AggregateException aggregateException = new AggregateException("AggregateException", new [] {innerException1, innerException2});

ExceptionTelemetry original = CreateExceptionTelemetry(aggregateException);

original.Message = "Custom";
var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(original);

Assert.Equal("Custom", item.Data.BaseData.Exceptions[0].Message);
Assert.Equal("Inner1", item.Data.BaseData.Exceptions[1].Message);
Assert.Equal("Inner2", item.Data.BaseData.Exceptions[2].Message);
}

[TestMethod]
public void SerializeWritesItemHandledAtAsExpectedByEndpoint()
{
Expand Down
79 changes: 77 additions & 2 deletions Test/CoreSDK.Test/Shared/TelemetryClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
#if CORE_PCL || NET45 || NET46
using System.Diagnostics.Tracing;
#endif
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Text;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.Extensibility.Implementation;
using Microsoft.ApplicationInsights.Extensibility.Implementation.Platform;
using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing;
using Microsoft.ApplicationInsights.TestFramework;
Expand Down Expand Up @@ -733,14 +738,21 @@ public void TrackWhenChannelIsNullWillThrowInvalidOperationException()
[TestMethod]
public void TrackAddsSdkVerionByDefault()
{
// split version by 4 numbers manually so we do not do the same as in the product code and actually test it
string versonStr = Assembly.GetAssembly(typeof(TelemetryConfiguration)).GetCustomAttributes(false)
.OfType<AssemblyFileVersionAttribute>()
.First()
.Version;
string[] versionParts = new Version(versonStr).ToString().Split('.');

var configuration = new TelemetryConfiguration { TelemetryChannel = new StubTelemetryChannel(), InstrumentationKey = Guid.NewGuid().ToString() };
var client = new TelemetryClient(configuration);

client.Context.InstrumentationKey = "Test";
EventTelemetry eventTelemetry = new EventTelemetry("test");
client.Track(eventTelemetry);

Assert.StartsWith("dotnet: ", eventTelemetry.Context.Internal.SdkVersion);
Assert.Equal("dotnet:"+ string.Join(".", versionParts[0], versionParts[1], versionParts[2]) + "-" + versionParts[3], eventTelemetry.Context.Internal.SdkVersion);
}

[TestMethod]
Expand Down Expand Up @@ -779,7 +791,70 @@ public void AllTelemetryIsSentWithDefaultSamplingRate()

Assert.Equal(ItemsToGenerate, sentTelemetry.Count);
}


#endregion

#region ValidateEndpoint

[TestMethod]
public void SendEventToValidateEndpoint()
{
EventTelemetry telemetry1 = new EventTelemetry();
MetricTelemetry telemetry2 = new MetricTelemetry();
DependencyTelemetry telemetry3 = new DependencyTelemetry();
ExceptionTelemetry telemetry4 = new ExceptionTelemetry();
MetricTelemetry telemetry5 = new MetricTelemetry();
PageViewTelemetry telemetry6 = new PageViewTelemetry();
PerformanceCounterTelemetry telemetry7 = new PerformanceCounterTelemetry();
RequestTelemetry telemetry8 = new RequestTelemetry();
SessionStateTelemetry telemetry9 = new SessionStateTelemetry();
TraceTelemetry telemetry10 = new TraceTelemetry();

var telemetryItems = new List<ITelemetry>
{
telemetry1,
telemetry2,
telemetry3,
telemetry4,
telemetry5,
telemetry6,
telemetry7,
telemetry8,
telemetry9,
telemetry10
};

// ChuckNorrisTeamUnitTests resource in Prototypes5
var config = new TelemetryConfiguration { InstrumentationKey = "fafa4b10-03d3-4bb0-98f4-364f0bdf5df8" };
var telemetryClient = new TelemetryClient(config);

telemetryClient.Initialize(telemetry1);
telemetryClient.Initialize(telemetry2);
telemetryClient.Initialize(telemetry3);
telemetryClient.Initialize(telemetry4);
telemetryClient.Initialize(telemetry5);
telemetryClient.Initialize(telemetry6);
telemetryClient.Initialize(telemetry7);
telemetryClient.Initialize(telemetry8);
telemetryClient.Initialize(telemetry9);
telemetryClient.Initialize(telemetry10);

string json = JsonSerializer.SerializeAsString(telemetryItems);

HttpClient client = new HttpClient();
var result = client.PostAsync(
"https://dc.services.visualstudio.com/v2/validate",
new ByteArrayContent(Encoding.UTF8.GetBytes(json))).GetAwaiter().GetResult();

if (result.StatusCode != HttpStatusCode.OK)
{
var response = result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
Trace.WriteLine(response);
}

Assert.Equal(HttpStatusCode.OK, result.StatusCode);
}

#endregion

private TelemetryClient InitializeTelemetryClient(ICollection<ITelemetry> sentTelemetry)
Expand Down
17 changes: 13 additions & 4 deletions Test/CoreSDK.Test/TestFramework/Shared/TestEventListener.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Microsoft.ApplicationInsights.TestFramework
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
#if CORE_PCL || NET45 || NET46
using System.Diagnostics.Tracing;
Expand All @@ -12,12 +13,12 @@

internal class TestEventListener : EventListener
{
private readonly Queue<EventWrittenEventArgs> events;
private readonly ConcurrentQueue<EventWrittenEventArgs> events;
private readonly AutoResetEvent eventWritten;

public TestEventListener()
{
this.events = new Queue<EventWrittenEventArgs>();
this.events = new ConcurrentQueue<EventWrittenEventArgs>();
this.eventWritten = new AutoResetEvent(false);
this.OnOnEventWritten = e =>
{
Expand All @@ -40,8 +41,16 @@ public IEnumerable<EventWrittenEventArgs> Messages
}

while (this.events.Count != 0)
{
yield return this.events.Dequeue();
{
EventWrittenEventArgs nextEvent;
if (this.events.TryDequeue(out nextEvent))
{
yield return nextEvent;
}
else
{
throw new InvalidOperationException();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Threading;

using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
Expand Down Expand Up @@ -194,6 +196,20 @@ public void SamplingPercentageAdjustsForSpikyProductionRate()
Assert.True(sentTelemetry.Count < targetItemCount + tolerance);
}

[TestMethod]
public void AdaptiveSamplingSetsExcludedTypesOnInternalSamplingProcessor()
{
var tc = new TelemetryConfiguration { TelemetryChannel = new StubTelemetryChannel() };
var channelBuilder = new TelemetryProcessorChainBuilder(tc);
channelBuilder.UseAdaptiveSampling(5, "request;");
channelBuilder.Build();

var fieldInfo = typeof(AdaptiveSamplingTelemetryProcessor).GetField("samplingProcessor", BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic);
SamplingTelemetryProcessor internalProcessor = (SamplingTelemetryProcessor) fieldInfo.GetValue(tc.TelemetryProcessorChain.FirstTelemetryProcessor);

Assert.Equal("request;", internalProcessor.ExcludedTypes);
}

private void TraceSamplingPercentageEvaluation(
double afterSamplingTelemetryItemRatePerSecond,
double currentSamplingPercentage,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace Microsoft.ApplicationInsights.WindowsServer.Channel.Helpers
{
using System.Globalization;

public static class BackendResponseHelper
{
public static string CreateBackendResponse(int itemsReceived, int itemsAccepted, string[] errorCodes,
int indexStartWith = 0)
{
string singleItem = "{{" +
"\"index\": {0}," +
"\"statusCode\": {1}," +
"\"message\": \"Explanation\"" +
"}}";

string errorList = string.Empty;
for (int i = 0; i < errorCodes.Length; ++i)
{
string errorCode = errorCodes[i];
if (!string.IsNullOrEmpty(errorList))
{
errorList += ",";
}

errorList += string.Format(CultureInfo.InvariantCulture, singleItem, indexStartWith + i, errorCode);
}

return
"{" +
"\"itemsReceived\": " + itemsReceived + "," +
"\"itemsAccepted\": " + itemsAccepted + "," +
"\"errors\": [" + errorList + "]" +
"}";
}
}
}
Loading

0 comments on commit e0c9397

Please sign in to comment.