Skip to content

Commit 8cb6da6

Browse files
authored
Merge pull request #445 from Microsoft/develop
Merge develop to master for 2.3.0beta3
2 parents 794e2d0 + 9470bc7 commit 8cb6da6

File tree

165 files changed

+1996
-1923
lines changed

Some content is hidden

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

165 files changed

+1996
-1923
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
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+
## Version 2.3.0-beta3
6+
- [Added overloads of TelemetryClientExtensions.StartOperation.] (https://github.com/Microsoft/ApplicationInsights-dotnet/issues/163)
7+
- Fire new ETW events for Operation Start/Stop.
8+
59
## Version 2.3.0-beta2
610
- Added constructor overloads for TelemetryConfiguration and added creation of a default InMemoryChannel when no channel is specified for a new instance.
711
TelemetryClient will no longer create an InMemoryChannel on the configuration instance if TelemetryChannel is null, instead the configuration instances will always have a channel when created.

GlobalStaticVersion.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<SemanticVersionMajor>2</SemanticVersionMajor>
99
<SemanticVersionMinor>3</SemanticVersionMinor>
1010
<SemanticVersionPatch>0</SemanticVersionPatch>
11-
<PreReleaseMilestone>beta2</PreReleaseMilestone>
11+
<PreReleaseMilestone>beta3</PreReleaseMilestone>
1212
<!--
1313
Date when Semantic Version was changed.
1414
Update for every public release.

Microsoft.ApplicationInsights.Channels.sln

Lines changed: 0 additions & 261 deletions
This file was deleted.

Microsoft.ApplicationInsights.sln

Lines changed: 166 additions & 79 deletions
Large diffs are not rendered by default.

Package.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
</Target>
4949
<Target Name="Gitlink" AfterTargets="Build" BeforeTargets="BuildNugetPackage">
5050
<Exec Command='$(PackagesDir)\gitlink.2.2.0\lib\net45\GitLink.exe $(MSBuildThisFileDirectory) -f "Microsoft.ApplicationInsights.sln" -u https://github.com/Microsoft/ApplicationInsights-dotnet -c "$(Configuration)" -p "$(Platform)"' IgnoreExitCode='true' />
51-
<Exec Command='$(PackagesDir)\gitlink.2.2.0\lib\net45\GitLink.exe $(MSBuildThisFileDirectory) -f "Microsoft.ApplicationInsights.Channels.sln" -u https://github.com/Microsoft/ApplicationInsights-dotnet -c "$(Configuration)" -p "$(Platform)"' IgnoreExitCode='true' />
5251
</Target>
5352
<UsingTask TaskName="GetFileVersionInfo" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildFrameworkToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
5453
<ParameterGroup>

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@
6464
<Project>{4b0bc3b7-c7fc-4333-9e28-5790d9153f07}</Project>
6565
<Name>ApplicationInsightsTypes</Name>
6666
</ProjectReference>
67-
<ProjectReference Include="..\TestFramework\Net40\TestFramework.Net40.csproj">
68-
<Project>{804af8fd-87f5-48ae-90c8-70433018b76e}</Project>
69-
<Name>TestFramework.Net40</Name>
70-
</ProjectReference>
7167
</ItemGroup>
7268
<ItemGroup>
7369
<None Include="packages.config">
@@ -78,15 +74,16 @@
7874
<Folder Include="Extensibility\Implementation\Tracing\" />
7975
</ItemGroup>
8076
<Import Project="..\Shared\Core.Shared.Tests.projitems" Label="Shared" />
77+
<Import Project="..\..\TestFramework\Shared\TestFramework.Shared.projitems" Label="Shared" />
8178
<Import Project="..\Operation.CC.Shared.Tests\Operation.CC.Tests.Shared.projitems" Label="Shared" />
8279
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'Common.targets'))\Common.targets" />
8380
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
8481
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82+
<Import Project="..\..\..\..\packages\StyleCop.MSBuild.4.7.55.0\build\StyleCop.MSBuild.Targets" Condition="Exists('..\..\..\..\packages\StyleCop.MSBuild.4.7.55.0\build\StyleCop.MSBuild.Targets')" />
8583
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
8684
<PropertyGroup>
8785
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
8886
</PropertyGroup>
89-
<Error Condition="!Exists('..\..\..\..\packages\StyleCop.MSBuild.4.7.50.0\build\StyleCop.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\StyleCop.MSBuild.4.7.50.0\build\StyleCop.MSBuild.Targets'))" />
87+
<Error Condition="!Exists('..\..\..\..\packages\StyleCop.MSBuild.4.7.55.0\build\StyleCop.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\StyleCop.MSBuild.4.7.55.0\build\StyleCop.MSBuild.Targets'))" />
9088
</Target>
91-
<Import Project="..\..\..\..\packages\StyleCop.MSBuild.4.7.50.0\build\StyleCop.MSBuild.Targets" Condition="Exists('..\..\..\..\packages\StyleCop.MSBuild.4.7.50.0\build\StyleCop.MSBuild.Targets')" />
9289
</Project>

Test/CoreSDK.Test/Net40/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<package id="gitlink" version="2.2.0" targetFramework="net45" />
44
<package id="Microsoft.Diagnostics.Tracing.EventSource.Redist" version="1.1.28" targetFramework="net45" />
55
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
6-
<package id="StyleCop.MSBuild" version="4.7.50.0" targetFramework="net45" developmentDependency="true" />
6+
<package id="StyleCop.MSBuild" version="4.7.55.0" targetFramework="net45" developmentDependency="true" />
77
<package id="xunit.assert" version="2.0.0-beta-build2650" targetFramework="net45" />
88
</packages>

Test/CoreSDK.Test/Net45/Core.Net45.Tests.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@
5757
<Project>{4b0bc3b7-c7fc-4333-9e28-5790d9153f07}</Project>
5858
<Name>ApplicationInsightsTypes</Name>
5959
</ProjectReference>
60-
<ProjectReference Include="..\TestFramework\Net45\TestFramework.Net45.csproj">
61-
<Name>TestFramework.Net45</Name>
62-
</ProjectReference>
6360
</ItemGroup>
6461
<ItemGroup>
6562
<None Include="packages.config" />
@@ -68,6 +65,7 @@
6865
<Folder Include="Extensibility\Implementation\Tracing\" />
6966
</ItemGroup>
7067
<Import Project="..\Shared\Core.Shared.Tests.projitems" Label="Shared" />
68+
<Import Project="..\..\TestFramework\Shared\TestFramework.Shared.projitems" Label="Shared" />
7169
<Import Project="..\Operation.CC.Shared.Tests\Operation.CC.Tests.Shared.projitems" Label="Shared" />
7270
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
7371
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Test/CoreSDK.Test/Net46/Core.Net46.Tests.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@
5656
<Project>{4b0bc3b7-c7fc-4333-9e28-5790d9153f07}</Project>
5757
<Name>ApplicationInsightsTypes</Name>
5858
</ProjectReference>
59-
<ProjectReference Include="..\TestFramework\Net46\TestFramework.Net46.csproj">
60-
<Project>{d7d4e3f5-ec0d-47c9-90cc-56f612976122}</Project>
61-
<Name>TestFramework.Net46</Name>
62-
</ProjectReference>
6359
</ItemGroup>
6460
<ItemGroup>
6561
<None Include="packages.config" />
@@ -68,6 +64,7 @@
6864
<Folder Include="Extensibility\Implementation\Tracing\" />
6965
</ItemGroup>
7066
<Import Project="..\Shared\Core.Shared.Tests.projitems" Label="Shared" />
67+
<Import Project="..\..\TestFramework\Shared\TestFramework.Shared.projitems" Label="Shared" />
7168
<Import Project="..\Operation.AL.Shared.Tests\Operation.AL.Tests.Shared.projitems" Label="Shared" />
7269
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
7370
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Test/CoreSDK.Test/Net46/Extensibility/Implementation/RichPayloadEventSourceTest.cs

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ public void RichPayloadEventSourceSessionStateSentTest()
132132
#pragma warning restore 618
133133
}
134134

135-
/// <summary>
136-
/// Tests tracking session state telemetry.
137-
/// </summary>
135+
/// <summary>
136+
/// Tests tracking session state telemetry.
137+
/// </summary>
138138
[TestMethod]
139139
public void RichPayloadEventSourceSessionPerformanceCounterTest()
140140
{
@@ -147,6 +147,79 @@ public void RichPayloadEventSourceSessionPerformanceCounterTest()
147147
#pragma warning restore 618
148148
}
149149

150+
/// <summary>
151+
/// Tests start/stop events for Operations.
152+
/// </summary>
153+
[TestMethod]
154+
public void RichPayloadEventSourceOperationStartStopTest()
155+
{
156+
if (IsRunningOnEnvironmentSupportingRichPayloadEventSource())
157+
{
158+
var client = CreateTelemetryClient();
159+
160+
using (var listener = new TestFramework.TestEventListener())
161+
{
162+
listener.EnableEvents(RichPayloadEventSource.Log.EventSourceInternal, EventLevel.Informational, RichPayloadEventSource.Keywords.Operations);
163+
164+
// Simulate a Start/Stop request operation
165+
var requestTelemetry = new RequestTelemetry { Name = "Request" };
166+
using (client.StartOperation(requestTelemetry))
167+
{
168+
}
169+
170+
// Expect exactly two events (start and stop)
171+
var actualEvents = listener.Messages.Where(m => m.Keywords.HasFlag(RichPayloadEventSource.Keywords.Operations)).Take(2).ToArray();
172+
173+
VerifyOperationEvent(requestTelemetry, RequestTelemetry.TelemetryName, EventOpcode.Start, actualEvents[0]);
174+
VerifyOperationEvent(requestTelemetry, RequestTelemetry.TelemetryName, EventOpcode.Stop, actualEvents[1]);
175+
}
176+
}
177+
else
178+
{
179+
// 4.5 doesn't have RichPayload events
180+
Assert.IsNull(RichPayloadEventSource.Log.EventSourceInternal);
181+
}
182+
}
183+
184+
/// <summary>
185+
/// Tests start/stop events for nested operations.
186+
/// </summary>
187+
[TestMethod]
188+
public void RichPayloadEventSourceNestedOperationStartStopTest()
189+
{
190+
if (IsRunningOnEnvironmentSupportingRichPayloadEventSource())
191+
{
192+
var client = CreateTelemetryClient();
193+
194+
using (var listener = new TestFramework.TestEventListener())
195+
{
196+
listener.EnableEvents(RichPayloadEventSource.Log.EventSourceInternal, EventLevel.Informational, RichPayloadEventSource.Keywords.Operations);
197+
198+
// Simulate a Start/Stop request operation
199+
var requestTelemetry = new RequestTelemetry { Name = "Request" };
200+
var nestedOperation = new DependencyTelemetry { Name = "Dependency" };
201+
using (client.StartOperation(requestTelemetry))
202+
{
203+
using (client.StartOperation(nestedOperation))
204+
{
205+
}
206+
}
207+
208+
// Expect exactly four events (start, start, stop, stop)
209+
var actualEvents = listener.Messages.Where(m=>m.Keywords.HasFlag(RichPayloadEventSource.Keywords.Operations)).Take(4).ToArray();
210+
211+
VerifyOperationEvent(requestTelemetry, RequestTelemetry.TelemetryName, EventOpcode.Start, actualEvents[0]);
212+
VerifyOperationEvent(nestedOperation, OperationTelemetry.TelemetryName, EventOpcode.Start, actualEvents[1]);
213+
VerifyOperationEvent(nestedOperation, OperationTelemetry.TelemetryName, EventOpcode.Stop, actualEvents[2]);
214+
VerifyOperationEvent(requestTelemetry, RequestTelemetry.TelemetryName, EventOpcode.Stop, actualEvents[3]);
215+
}
216+
}
217+
else
218+
{
219+
// 4.5 doesn't have RichPayload events
220+
Assert.IsNull(RichPayloadEventSource.Log.EventSourceInternal);
221+
}
222+
}
150223

151224
/// <summary>
152225
/// Tests sanitizing telemetry event
@@ -163,8 +236,7 @@ public void RichPayloadEventSourceSanitizeTest()
163236
ResponseCode = "200"
164237
};
165238

166-
var client = new TelemetryClient();
167-
client.InstrumentationKey = Guid.NewGuid().ToString();
239+
var client = CreateTelemetryClient();
168240

169241
using (var listener = new Microsoft.ApplicationInsights.TestFramework.TestEventListener())
170242
{
@@ -182,6 +254,16 @@ public void RichPayloadEventSourceSanitizeTest()
182254
}
183255

184256

257+
private TelemetryClient CreateTelemetryClient()
258+
{
259+
// The default InMemoryChannel creates a worker thread which, if left running, causes
260+
// System.AppDomainUnloadedException from the test runner.
261+
var channel = new TestFramework.StubTelemetryChannel();
262+
var configuration = new TelemetryConfiguration(Guid.NewGuid().ToString(), channel);
263+
var client = new TelemetryClient(configuration) { InstrumentationKey = configuration.InstrumentationKey };
264+
return client;
265+
}
266+
185267
/// <summary>
186268
/// Helper method to setup shared context and call the desired tracking for testing.
187269
/// </summary>
@@ -192,8 +274,7 @@ private void DoTracking(EventKeywords keywords, ITelemetry item, Type dataType,
192274
{
193275
if (IsRunningOnEnvironmentSupportingRichPayloadEventSource())
194276
{
195-
var client = new TelemetryClient();
196-
client.InstrumentationKey = Guid.NewGuid().ToString();
277+
var client = CreateTelemetryClient();
197278

198279
using (var listener = new Microsoft.ApplicationInsights.TestFramework.TestEventListener())
199280
{
@@ -285,6 +366,25 @@ private static void VerifyEventPayload(IEnumerable<PropertyInfo> expectedPropert
285366
}
286367
}
287368

369+
private static void VerifyOperationEvent(OperationTelemetry expectedOperation, string expectedName, EventOpcode expectedOpCode, EventWrittenEventArgs actualEvent)
370+
{
371+
Assert.AreEqual(expectedOpCode, actualEvent.Opcode);
372+
#if !NET45
373+
Assert.AreEqual(expectedName, actualEvent.EventName);
374+
#endif
375+
VerifyOperationPayload(expectedOperation, actualEvent.Payload);
376+
}
377+
378+
private static void VerifyOperationPayload(OperationTelemetry expected, IReadOnlyList<object> actualPayload)
379+
{
380+
Assert.IsNotNull(actualPayload);
381+
Assert.AreEqual(4, actualPayload.Count);
382+
Assert.AreEqual(expected.Context.InstrumentationKey, actualPayload[0]);
383+
Assert.AreEqual(expected.Id, actualPayload[1]);
384+
Assert.AreEqual(expected.Name, actualPayload[2]);
385+
Assert.AreEqual(expected.Context.Operation.Id, actualPayload[3]);
386+
}
387+
288388
private static Type GetEnumerableType(Type type)
289389
{
290390
foreach (Type intType in type.GetInterfaces())

0 commit comments

Comments
 (0)