Skip to content

Commit

Permalink
Merge pull request #916 from Microsoft/tilee/merge_develop_to_master(…
Browse files Browse the repository at this point in the history
…prep_2.8-beta2)

merge develop to master (prep 2.8-beta2)
  • Loading branch information
TimothyMothra authored Sep 14, 2018
2 parents 6e7d6d7 + a70d431 commit 25cd320
Show file tree
Hide file tree
Showing 96 changed files with 690 additions and 442 deletions.
2 changes: 2 additions & 0 deletions ApplicationInsightsSDKRules.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<Rule Id="CA1900" Action="Warning" />
<Rule Id="CA2001" Action="Warning" />
<Rule Id="CA2002" Action="Warning" />
<!-- Suppressing Message "Do not create tasks without passing a TaskScheduler" because framework manages this by default -->
<Rule Id="CA2008" Action="None" />
<Rule Id="CA2100" Action="Warning" />
<Rule Id="CA2102" Action="Warning" />
<Rule Id="CA2103" Action="Warning" />
Expand Down
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## Version 2.8.0-beta2
- [TelemetryProcessors (sampling, autocollectedmetricaggregator), TelemetryChannel (ServerTelemetryChannel) added automatically to the default ApplicationInsights.config are moved under the default telemetry sink.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/907)
If you are upgrading, and have added/modified TelemetryProcessors/TelemetryChannel, make sure to copy them to the default sink section.

## Version 2.8.0-beta1
- [Add a new distict properties collection, GlobalProperties, on TelemetryContext, and obsolete the Properties on TelemetryContext.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/820)
- [Added support for strongly typed extensibility for Telemetry types using IExtension.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/871)
Expand All @@ -13,11 +17,7 @@ message and exception type of underlying `System.Exception` object that user wan
- Added an option of creating ExceptionTelemetry object off of custom exception information rather than a System.Exception object.
- [Add support for hex values in config](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/551)

## Version 2.7.0
- Metrics: Renamed TryTrackValue(..) into TrackValue(..).
- Metrics: Removed some superfluous public constants.

## Version 2.7.0
## Version 2.7.2
- Metrics: Renamed TryTrackValue(..) into TrackValue(..).
- Metrics: Removed some superfluous public constants.

Expand Down
3 changes: 2 additions & 1 deletion Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- Need to disable WarningsAsErrors until all FxCop issues are fixed. -->
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion GlobalStaticVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<SemanticVersionMinor>8</SemanticVersionMinor>
<SemanticVersionPatch>0</SemanticVersionPatch>
<!--Valid values: beta1, beta2, EMPTY for stable -->
<PreReleaseMilestone>beta1</PreReleaseMilestone>
<PreReleaseMilestone>beta2</PreReleaseMilestone>
<!--
Date when Semantic Version was changed.
Update for every public release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Microsoft.ApplicationInsights.Channel.InMemoryChannel.BacklogSize.set -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.DeveloperMode.get -> bool?
Microsoft.ApplicationInsights.Channel.InMemoryChannel.DeveloperMode.set -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.Dispose() -> void
virtual Microsoft.ApplicationInsights.Channel.InMemoryChannel.Dispose(bool disposing) -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.EndpointAddress.get -> string
Microsoft.ApplicationInsights.Channel.InMemoryChannel.EndpointAddress.set -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.Flush() -> void
Expand Down Expand Up @@ -358,6 +359,7 @@ Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Cancel() ->
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Delay.get -> System.TimeSpan
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Delay.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Dispose() -> void
virtual Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Dispose(bool disposing) -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.IsStarted.get -> bool
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Start(System.Func<System.Threading.Tasks.Task> elapsed) -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryContextExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Microsoft.ApplicationInsights.Channel.InMemoryChannel.BacklogSize.set -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.DeveloperMode.get -> bool?
Microsoft.ApplicationInsights.Channel.InMemoryChannel.DeveloperMode.set -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.Dispose() -> void
virtual Microsoft.ApplicationInsights.Channel.InMemoryChannel.Dispose(bool disposing) -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.EndpointAddress.get -> string
Microsoft.ApplicationInsights.Channel.InMemoryChannel.EndpointAddress.set -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.Flush() -> void
Expand Down Expand Up @@ -358,6 +359,7 @@ Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Cancel() ->
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Delay.get -> System.TimeSpan
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Delay.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Dispose() -> void
virtual Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Dispose(bool disposing) -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.IsStarted.get -> bool
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Start(System.Func<System.Threading.Tasks.Task> elapsed) -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryContextExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Microsoft.ApplicationInsights.Channel.InMemoryChannel.BacklogSize.set -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.DeveloperMode.get -> bool?
Microsoft.ApplicationInsights.Channel.InMemoryChannel.DeveloperMode.set -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.Dispose() -> void
virtual Microsoft.ApplicationInsights.Channel.InMemoryChannel.Dispose(bool disposing) -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.EndpointAddress.get -> string
Microsoft.ApplicationInsights.Channel.InMemoryChannel.EndpointAddress.set -> void
Microsoft.ApplicationInsights.Channel.InMemoryChannel.Flush() -> void
Expand Down Expand Up @@ -357,6 +358,7 @@ Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Cancel() ->
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Delay.get -> System.TimeSpan
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Delay.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Dispose() -> void
virtual Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Dispose(bool disposing) -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.IsStarted.get -> bool
Microsoft.ApplicationInsights.Extensibility.Implementation.TaskTimer.Start(System.Func<System.Threading.Tasks.Task> elapsed) -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryContextExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public void ExceptionTelemetryCreatedBasedOnCustomData()

// ASSERT
// use internal fields to validate
Assert.AreEqual("Top level exception <--- Inner exception modified", item.Message);

Assert.AreEqual(item.Data.Data.ver, 2);
Assert.AreEqual(item.Data.Data.problemId, "ProblemId modified");
Assert.AreEqual(item.Data.Data.severityLevel, Extensibility.Implementation.External.SeverityLevel.Error);
Expand Down Expand Up @@ -134,6 +136,75 @@ public void ExceptionTelemetryCreatedBasedOnCustomData()
Assert.AreEqual(item.Data.Data.exceptions.Last().parsedStack[1].method, "DeeperInnerMethod");
}

[TestMethod]
public void ExceptionTelemetryCreatedBasedOnCustomDataConstructsFakeExceptionCorrectly()
{
// ARRANGE
var topLevelexceptionDetails = new ExceptionDetailsInfo(1, -1, "TopLevelException", "Top level exception",
true, "Top level exception stack", new[]
{
new StackFrame("Some.Assembly", "SomeFile.dll", 3, 33, "TopLevelMethod"),
new StackFrame("Some.Assembly", "SomeOtherFile.dll", 2, 22, "LowerLevelMethod"),
new StackFrame("Some.Assembly", "YetAnotherFile.dll", 1, 11, "LowLevelMethod")
});

var innerExceptionDetails = new ExceptionDetailsInfo(2, 1, "InnerException", "Inner exception", false,
"Inner exception stack", new[]
{
new StackFrame("Some.Assembly", "ImportantFile.dll", 2, 22, "InnerMethod"),
new StackFrame("Some.Assembly", "LessImportantFile.dll", 1, 11, "DeeperInnerMethod")
});

var innerInnerExceptionDetails = new ExceptionDetailsInfo(3, 1, "InnerInnerException", "Inner inner exception", false,
"Inner inner exception stack", new[]
{
new StackFrame("Some.Assembly", "ImportantInnerFile.dll", 2, 22, "InnerInnerMethod"),
new StackFrame("Some.Assembly", "LessImportantInnerFile.dll", 1, 11, "DeeperInnerInnerMethod")
});

ExceptionTelemetry item1 = new ExceptionTelemetry(new[] { topLevelexceptionDetails, innerExceptionDetails, innerInnerExceptionDetails },
SeverityLevel.Error, "ProblemId",
new Dictionary<string, string>() { ["property1"] = "value1", ["property2"] = "value2" },
new Dictionary<string, double>() { ["property1"] = 1, ["property2"] = 2 });

ExceptionTelemetry item2 = new ExceptionTelemetry(new[] { topLevelexceptionDetails, innerExceptionDetails },
SeverityLevel.Error, "ProblemId",
new Dictionary<string, string>() { ["property1"] = "value1", ["property2"] = "value2" },
new Dictionary<string, double>() { ["property1"] = 1, ["property2"] = 2 });

ExceptionTelemetry item3 = new ExceptionTelemetry(new[] { topLevelexceptionDetails },
SeverityLevel.Error, "ProblemId",
new Dictionary<string, string>() { ["property1"] = "value1", ["property2"] = "value2" },
new Dictionary<string, double>() { ["property1"] = 1, ["property2"] = 2 });

ExceptionTelemetry item4 = new ExceptionTelemetry(new ExceptionDetailsInfo[] { },
SeverityLevel.Error, "ProblemId",
new Dictionary<string, string>() { ["property1"] = "value1", ["property2"] = "value2" },
new Dictionary<string, double>() { ["property1"] = 1, ["property2"] = 2 });

// ACT
Exception exception1 = item1.Exception;
Exception exception2 = item2.Exception;
Exception exception3 = item3.Exception;
Exception exception4 = item4.Exception;

// ASSERT
Assert.AreEqual("Top level exception", exception1.Message);
Assert.AreEqual("Inner exception", exception1.InnerException.Message);
Assert.AreEqual("Inner inner exception", exception1.InnerException.InnerException.Message);
Assert.IsNull(exception1.InnerException.InnerException.InnerException);

Assert.AreEqual("Top level exception", exception2.Message);
Assert.AreEqual("Inner exception", exception2.InnerException.Message);
Assert.IsNull(exception2.InnerException.InnerException);

Assert.AreEqual("Top level exception", exception3.Message);
Assert.IsNull(exception3.InnerException);

Assert.AreEqual(string.Empty, exception4.Message);
Assert.IsNull(exception4.InnerException);
}

[TestMethod]
public void ExceptionTelemetryExceptionDetailsUpdate()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ private void DoTracking(EventKeywords keywords, ITelemetry item, Type dataType,
object value = tag["Value"];
if (!string.IsNullOrWhiteSpace(key))
{
if (key == "ai.user.id")
if (string.Equals(key, "ai.user.id", StringComparison.Ordinal))
{
Assert.AreEqual("testUserId", value);
++keysFound;
}
else if (key == "ai.operation.id")
else if (string.Equals(key, "ai.operation.id", StringComparison.Ordinal))
{
Assert.AreEqual(item.Context.Operation.Id, value);
++keysFound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ public void Dependency_TelemetryMarkedAsProcessedCorrectly()

client.TrackRequest("Test Request", DateTimeOffset.Now, TimeSpan.FromMilliseconds(10), "200", success: true);
#pragma warning disable CS0612 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
client.TrackDependency("Test Dependency Call 1", "Test Command", DateTimeOffset.Now, TimeSpan.FromMilliseconds(10), success: true);
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CS0612 // Type or member is obsolete
client.TrackDependency("Test Dependency Type", "Test Dependency Call 2", "Test Command", DateTimeOffset.Now, TimeSpan.FromMilliseconds(10), true);
client.TrackDependency("Test Dependency Type", "Test Target", "Test Dependency Call 3", "Test Data", DateTimeOffset.Now, TimeSpan.FromMilliseconds(11), "201", success: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ public void ObsoleteTrackDependencySendsDependencyTelemetryWithGivenNameCommandn

var timestamp = DateTimeOffset.Now;
#pragma warning disable CS0612 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
client.TrackDependency("name", "command name", timestamp, TimeSpan.FromSeconds(42), false);
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CS0612 // Type or member is obsolete

var dependency = (DependencyTelemetry)sentTelemetry.Single();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,33 @@ public class GetBackendResponse
[TestMethod]
public void ReturnNullIfArgumentIsNull()
{
var manager = new BackoffLogicManager(TimeSpan.Zero);
Assert.IsNull(manager.GetBackendResponse(null));
Assert.IsNull(BackoffLogicManager.GetBackendResponse(null));
}

[TestMethod]
public void ReturnNullIfArgumentEmpty()
{
var manager = new BackoffLogicManager(TimeSpan.Zero);
Assert.IsNull(manager.GetBackendResponse(string.Empty));
Assert.IsNull(BackoffLogicManager.GetBackendResponse(string.Empty));
}

[TestMethod]
public void IfContentCannotBeParsedNullIsReturned()
{
var manager = new BackoffLogicManager(TimeSpan.Zero);
Assert.IsNull(manager.GetBackendResponse("ab}{"));
Assert.IsNull(BackoffLogicManager.GetBackendResponse("ab}{"));
}

[TestMethod]
public void IfContentIsUnexpectedJsonNullIsReturned()
{
var manager = new BackoffLogicManager(TimeSpan.Zero);
Assert.IsNull(manager.GetBackendResponse("[1,2]"));
Assert.IsNull(BackoffLogicManager.GetBackendResponse("[1,2]"));
}

[TestMethod]
public void BackendResponseIsReturnedForCorrectContent()
{
string content = BackendResponseHelper.CreateBackendResponse(itemsReceived: 100, itemsAccepted: 1, errorCodes: new[] {"206"}, indexStartWith: 84);

var manager = new BackoffLogicManager(TimeSpan.Zero);
var backendResponse = manager.GetBackendResponse(content);
var backendResponse = BackoffLogicManager.GetBackendResponse(content);

Assert.AreEqual(1, backendResponse.ItemsAccepted);
Assert.AreEqual(100, backendResponse.ItemsReceived);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ public static string GetEmptyConfig()
}
}

public static IEnumerable<XElement> GetTelemetryChannel(XDocument config)
public static IEnumerable<XElement> GetTelemetryChannelFromDefaultSink(XDocument config)
{
return config.Descendants(XmlNamespace + "TelemetryChannel");
var allSinks = config.Descendants(XmlNamespace + "TelemetrySinks").Descendants(XmlNamespace + "Add");
var defaultSink = allSinks?.FirstOrDefault(element => element.Attribute("Name").Value == "default");
return (defaultSink == null) ? Enumerable.Empty<XElement>() : defaultSink?.Descendants(XmlNamespace + "TelemetryChannel");
}

public static IEnumerable<XElement> GetTelemetryProcessors(XDocument config)
public static IEnumerable<XElement> GetTelemetryProcessorsFromDefaultSink(XDocument config)
{
var processors = config.Descendants(XmlNamespace + "TelemetryProcessors");
return processors?.Nodes().Cast<XElement>();
var allSinks = config.Descendants(XmlNamespace + "TelemetrySinks").Descendants(XmlNamespace + "Add");
var defaultSink = allSinks?.FirstOrDefault(element => element.Attribute("Name").Value == "default");
var processors = defaultSink?.Descendants(XmlNamespace + "TelemetryProcessors");
return (processors == null) ? Enumerable.Empty<XElement>() : processors.Nodes().Cast<XElement>();
}

public static string GetPartialTypeName(Type typeToFind)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel
{
using System;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand All @@ -12,10 +14,10 @@ public void InstallAddsServerTelemetryChannel()
{
string emptyConfig = ConfigurationHelpers.GetEmptyConfig();
XDocument configAfterTransform = ConfigurationHelpers.InstallTransform(emptyConfig);

Trace.WriteLine(configAfterTransform.ToString());
var typeToFind = typeof(ServerTelemetryChannel);

var node = ConfigurationHelpers.GetTelemetryChannel(configAfterTransform)
var node = ConfigurationHelpers.GetTelemetryChannelFromDefaultSink(configAfterTransform)
.FirstOrDefault(element => element.Attribute("Type").Value == ConfigurationHelpers.GetPartialTypeName(typeToFind));

Assert.IsNotNull(node);
Expand All @@ -25,11 +27,10 @@ public void InstallAddsServerTelemetryChannel()
public void UninstallRemovesTelemetryChannel()
{
string emptyConfig = ConfigurationHelpers.GetEmptyConfig();
XDocument configAfterInstall = ConfigurationHelpers.InstallTransform(emptyConfig);

XDocument configAfterInstall = ConfigurationHelpers.InstallTransform(emptyConfig);
XDocument configAfterUninstall = ConfigurationHelpers.UninstallTransform(configAfterInstall.ToString());

Assert.AreEqual(0, ConfigurationHelpers.GetTelemetryChannel(configAfterUninstall).ToList().Count);
Trace.WriteLine(configAfterUninstall.ToString());
Assert.AreEqual(0, ConfigurationHelpers.GetTelemetryChannelFromDefaultSink(configAfterUninstall).ToList().Count);
}
}
}
Loading

0 comments on commit 25cd320

Please sign in to comment.