Skip to content

Commit e0c9397

Browse files
authored
Merge pull request #252 from Microsoft/dnduffy/Release-2-2-0-beta1
Release 2.2.0-beta1
2 parents f82dd9e + 1041a88 commit e0c9397

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1749
-451
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.user
77
*.sln.docstates
88
.vs
9+
*.sln.dotsettings
910

1011
# Build results
1112
[Dd]ebug/

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
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/).
44

5+
6+
## Version 2.2.0-beta1
7+
8+
- Add ExceptionTelemetry.Message property. If it is provided it is used instead of Exception.Message property for the ounter-most exception.
9+
- Telemetry types can be exluded from sampling by specifing ExcludedTypes property.
10+
- 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)
11+
512
## Version 2.1.0-beta4
613
- [Bug fix](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/76)
714

GlobalStaticVersion.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
Update for every public release.
77
-->
88
<SemanticVersionMajor>2</SemanticVersionMajor>
9-
<SemanticVersionMinor>1</SemanticVersionMinor>
9+
<SemanticVersionMinor>2</SemanticVersionMinor>
1010
<SemanticVersionPatch>0</SemanticVersionPatch>
11-
<PreReleaseMilestone></PreReleaseMilestone>
11+
<PreReleaseMilestone>beta1</PreReleaseMilestone>
1212
<!--
1313
Date when Semantic Version was changed.
1414
Update for every public release.
1515
-->
16-
<SemanticVersionDate>2016-03-08</SemanticVersionDate>
16+
<SemanticVersionDate>2016-06-02</SemanticVersionDate>
1717

1818
<PreReleaseVersionFileName>.PreReleaseVersion</PreReleaseVersionFileName>
1919
<PreReleaseVersionFilePath>$(MSBuildThisFileDirectory)$(PreReleaseVersionFileName)</PreReleaseVersionFilePath>

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Read about [how to use the API and see the results in the portal][api-overview].
6868

6969
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.
7070

71+
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 [[email protected]](mailto:[email protected]) with any additional questions or comments.
72+
7173
[AILandingPage]: http://azure.microsoft.com/services/application-insights/
7274
[api-overview]: https://azure.microsoft.com/documentation/articles/app-insights-api-custom-events-metrics/
7375
[ContribGuide]: https://github.com/Microsoft/ApplicationInsights-Home/blob/master/CONTRIBUTING.md

Test/CoreSDK.Test/Net40/Core.Net40.Tests.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@
6363
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
6464
<Reference Include="System.Management" />
6565
<Reference Include="System.Net" />
66+
<Reference Include="System.Net.Http" />
67+
<Reference Include="System.Net.Http.Extensions">
68+
<HintPath>..\..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
69+
<Private>True</Private>
70+
</Reference>
71+
<Reference Include="System.Net.Http.Primitives">
72+
<HintPath>..\..\..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
73+
<Private>True</Private>
74+
</Reference>
75+
<Reference Include="System.Net.Http.WebRequest" />
6676
<Reference Include="System.Runtime.Serialization" />
6777
<Reference Include="System.XML" />
6878
<Reference Include="System.Xml.Linq" />

Test/CoreSDK.Test/Net40/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
77
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
88
<package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="1.1.28" targetFramework="net45" />
9+
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
910
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" />
1011
<package id="StyleCop.MSBuild" version="4.7.50.0" targetFramework="net45" developmentDependency="true" />
1112
<package id="xunit.assert" version="2.0.0-beta-build2650" targetFramework="net45" />

Test/CoreSDK.Test/Shared/Channel/TransmissionTest.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.IO;
55
using System.Net;
6+
using System.Reflection;
67
using System.Text;
78
using System.Threading;
89
using System.Threading.Tasks;
@@ -158,13 +159,9 @@ public void ThrowsInvalidOperationExceptionWhenTransmissionIsAlreadySending()
158159
{
159160
AsyncTest.Run(async () =>
160161
{
161-
var request = new StubWebRequest();
162-
request.OnBeginGetRequestStream = (callback, state) => TaskEx.Delay(TimeSpan.FromMilliseconds(10)).AsAsyncResult(callback, request);
163-
164162
var transmission = new TestableTransmission();
165-
transmission.OnCreateRequest = uri => request;
166-
167-
Task dontWait = transmission.SendAsync();
163+
FieldInfo isSendingField = typeof(Transmission).GetField("isSending", BindingFlags.NonPublic | BindingFlags.Instance);
164+
isSendingField.SetValue(transmission, 1, BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Instance, null, null);
168165
await AssertEx.ThrowsAsync<InvalidOperationException>(() => transmission.SendAsync());
169166
});
170167
}

Test/CoreSDK.Test/Shared/DataContracts/ExceptionTelemetryTest.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,56 @@ public void SerializeWritesItemVersionAsExpectedByEndpoint()
110110
Assert.Equal(2, item.Data.BaseData.Ver);
111111
}
112112

113+
[TestMethod]
114+
public void SerializeUsesExceptionMessageIfTelemetryMessageNotProvided()
115+
{
116+
ExceptionTelemetry original = CreateExceptionTelemetry(new ArgumentException("Test"));
117+
var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(original);
118+
119+
Assert.Equal("Test", item.Data.BaseData.Exceptions[0].Message);
120+
}
121+
122+
[TestMethod]
123+
public void SerializeTelemetryMessageAsOuterExceptionMessage()
124+
{
125+
ExceptionTelemetry original = CreateExceptionTelemetry(new ArgumentException("Test"));
126+
original.Message = "Custom";
127+
var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(original);
128+
129+
Assert.Equal("Custom", item.Data.BaseData.Exceptions[0].Message);
130+
}
131+
132+
[TestMethod]
133+
public void SerializeUsesExceptionMessageForInnerExceptions()
134+
{
135+
Exception outerException = new ArgumentException("Outer", new Exception("Inner"));
136+
ExceptionTelemetry original = CreateExceptionTelemetry(outerException);
137+
138+
original.Message = "Custom";
139+
var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(original);
140+
141+
Assert.Equal("Custom", item.Data.BaseData.Exceptions[0].Message);
142+
Assert.Equal("Inner", item.Data.BaseData.Exceptions[1].Message);
143+
}
144+
145+
[TestMethod]
146+
public void SerializeUsesExceptionMessageForInnerAggregateExceptions()
147+
{
148+
Exception innerException1 = new ArgumentException("Inner1");
149+
Exception innerException2 = new ArgumentException("Inner2");
150+
151+
AggregateException aggregateException = new AggregateException("AggregateException", new [] {innerException1, innerException2});
152+
153+
ExceptionTelemetry original = CreateExceptionTelemetry(aggregateException);
154+
155+
original.Message = "Custom";
156+
var item = TelemetryItemTestHelper.SerializeDeserializeTelemetryItem<ExceptionTelemetry, DataPlatformModel.ExceptionData>(original);
157+
158+
Assert.Equal("Custom", item.Data.BaseData.Exceptions[0].Message);
159+
Assert.Equal("Inner1", item.Data.BaseData.Exceptions[1].Message);
160+
Assert.Equal("Inner2", item.Data.BaseData.Exceptions[2].Message);
161+
}
162+
113163
[TestMethod]
114164
public void SerializeWritesItemHandledAtAsExpectedByEndpoint()
115165
{

Test/CoreSDK.Test/Shared/TelemetryClientTest.cs

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
using System;
44
using System.Collections.Generic;
55
using System.ComponentModel;
6+
using System.Diagnostics;
67
#if CORE_PCL || NET45 || NET46
78
using System.Diagnostics.Tracing;
89
#endif
910
using System.Linq;
11+
using System.Net;
12+
using System.Net.Http;
1013
using System.Reflection;
14+
using System.Text;
1115
using Microsoft.ApplicationInsights.Channel;
1216
using Microsoft.ApplicationInsights.DataContracts;
1317
using Microsoft.ApplicationInsights.Extensibility;
18+
using Microsoft.ApplicationInsights.Extensibility.Implementation;
1419
using Microsoft.ApplicationInsights.Extensibility.Implementation.Platform;
1520
using Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing;
1621
using Microsoft.ApplicationInsights.TestFramework;
@@ -733,14 +738,21 @@ public void TrackWhenChannelIsNullWillThrowInvalidOperationException()
733738
[TestMethod]
734739
public void TrackAddsSdkVerionByDefault()
735740
{
741+
// split version by 4 numbers manually so we do not do the same as in the product code and actually test it
742+
string versonStr = Assembly.GetAssembly(typeof(TelemetryConfiguration)).GetCustomAttributes(false)
743+
.OfType<AssemblyFileVersionAttribute>()
744+
.First()
745+
.Version;
746+
string[] versionParts = new Version(versonStr).ToString().Split('.');
747+
736748
var configuration = new TelemetryConfiguration { TelemetryChannel = new StubTelemetryChannel(), InstrumentationKey = Guid.NewGuid().ToString() };
737749
var client = new TelemetryClient(configuration);
738750

739751
client.Context.InstrumentationKey = "Test";
740752
EventTelemetry eventTelemetry = new EventTelemetry("test");
741753
client.Track(eventTelemetry);
742754

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

746758
[TestMethod]
@@ -779,7 +791,70 @@ public void AllTelemetryIsSentWithDefaultSamplingRate()
779791

780792
Assert.Equal(ItemsToGenerate, sentTelemetry.Count);
781793
}
782-
794+
795+
#endregion
796+
797+
#region ValidateEndpoint
798+
799+
[TestMethod]
800+
public void SendEventToValidateEndpoint()
801+
{
802+
EventTelemetry telemetry1 = new EventTelemetry();
803+
MetricTelemetry telemetry2 = new MetricTelemetry();
804+
DependencyTelemetry telemetry3 = new DependencyTelemetry();
805+
ExceptionTelemetry telemetry4 = new ExceptionTelemetry();
806+
MetricTelemetry telemetry5 = new MetricTelemetry();
807+
PageViewTelemetry telemetry6 = new PageViewTelemetry();
808+
PerformanceCounterTelemetry telemetry7 = new PerformanceCounterTelemetry();
809+
RequestTelemetry telemetry8 = new RequestTelemetry();
810+
SessionStateTelemetry telemetry9 = new SessionStateTelemetry();
811+
TraceTelemetry telemetry10 = new TraceTelemetry();
812+
813+
var telemetryItems = new List<ITelemetry>
814+
{
815+
telemetry1,
816+
telemetry2,
817+
telemetry3,
818+
telemetry4,
819+
telemetry5,
820+
telemetry6,
821+
telemetry7,
822+
telemetry8,
823+
telemetry9,
824+
telemetry10
825+
};
826+
827+
// ChuckNorrisTeamUnitTests resource in Prototypes5
828+
var config = new TelemetryConfiguration { InstrumentationKey = "fafa4b10-03d3-4bb0-98f4-364f0bdf5df8" };
829+
var telemetryClient = new TelemetryClient(config);
830+
831+
telemetryClient.Initialize(telemetry1);
832+
telemetryClient.Initialize(telemetry2);
833+
telemetryClient.Initialize(telemetry3);
834+
telemetryClient.Initialize(telemetry4);
835+
telemetryClient.Initialize(telemetry5);
836+
telemetryClient.Initialize(telemetry6);
837+
telemetryClient.Initialize(telemetry7);
838+
telemetryClient.Initialize(telemetry8);
839+
telemetryClient.Initialize(telemetry9);
840+
telemetryClient.Initialize(telemetry10);
841+
842+
string json = JsonSerializer.SerializeAsString(telemetryItems);
843+
844+
HttpClient client = new HttpClient();
845+
var result = client.PostAsync(
846+
"https://dc.services.visualstudio.com/v2/validate",
847+
new ByteArrayContent(Encoding.UTF8.GetBytes(json))).GetAwaiter().GetResult();
848+
849+
if (result.StatusCode != HttpStatusCode.OK)
850+
{
851+
var response = result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
852+
Trace.WriteLine(response);
853+
}
854+
855+
Assert.Equal(HttpStatusCode.OK, result.StatusCode);
856+
}
857+
783858
#endregion
784859

785860
private TelemetryClient InitializeTelemetryClient(ICollection<ITelemetry> sentTelemetry)

Test/CoreSDK.Test/TestFramework/Shared/TestEventListener.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Microsoft.ApplicationInsights.TestFramework
22
{
33
using System;
4+
using System.Collections.Concurrent;
45
using System.Collections.Generic;
56
#if CORE_PCL || NET45 || NET46
67
using System.Diagnostics.Tracing;
@@ -12,12 +13,12 @@
1213

1314
internal class TestEventListener : EventListener
1415
{
15-
private readonly Queue<EventWrittenEventArgs> events;
16+
private readonly ConcurrentQueue<EventWrittenEventArgs> events;
1617
private readonly AutoResetEvent eventWritten;
1718

1819
public TestEventListener()
1920
{
20-
this.events = new Queue<EventWrittenEventArgs>();
21+
this.events = new ConcurrentQueue<EventWrittenEventArgs>();
2122
this.eventWritten = new AutoResetEvent(false);
2223
this.OnOnEventWritten = e =>
2324
{
@@ -40,8 +41,16 @@ public IEnumerable<EventWrittenEventArgs> Messages
4041
}
4142

4243
while (this.events.Count != 0)
43-
{
44-
yield return this.events.Dequeue();
44+
{
45+
EventWrittenEventArgs nextEvent;
46+
if (this.events.TryDequeue(out nextEvent))
47+
{
48+
yield return nextEvent;
49+
}
50+
else
51+
{
52+
throw new InvalidOperationException();
53+
}
4554
}
4655
}
4756
}

0 commit comments

Comments
 (0)