Skip to content

Commit

Permalink
Merge pull request #1074 from Microsoft/dmitmatv_stable_upd1
Browse files Browse the repository at this point in the history
Stable 2.9 - second merge
  • Loading branch information
Dmitry-Matveev authored Jan 28, 2019
2 parents 82b96de + 802d94b commit 219d72f
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 13 deletions.
Binary file modified NuGet.exe
Binary file not shown.
12 changes: 6 additions & 6 deletions NugetAudit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Param(

$requiredCopyright = "$([char]0x00A9) Microsoft Corporation. All rights reserved.";#"© Microsoft Corporation. All rights reserved.";
$expectedProjectUrl = "https://go.microsoft.com/fwlink/?LinkId=392727"; # Application Insights Project Url
$expectedLicenseUrl = "https://licenses.nuget.org/MIT"; # MIT license Url
$expectedLicense = "MIT"; # MIT license Url
$expectedOwner = "AppInsightsSdk"; # Application Insights Nuget Account
$expectedTags = @("Azure","Monitoring");

Expand Down Expand Up @@ -175,13 +175,13 @@ function Get-IsValidProjectUrl([xml]$nuspecXml) {
Test-Condition ($projectUrl -eq $expectedProjectUrl) $message $requirement;
}

function Get-IsValidLicenseUrl([xml]$nuspecXml) {
$licenseUrl = $nuspecXml.package.metadata.licenseUrl;
function Get-IsValidLicense([xml]$nuspecXml) {
$license = $nuspecXml.package.metadata.license.InnerText;

$message = "License Url: $licenseUrl";
$message = "License Url: $license";
$requirement = "Must match expected."

Test-Condition ($licenseUrl -eq $expectedLicenseUrl) $message $requirement;
Test-Condition ($license -eq $expectedLicense) $message $requirement;
}

function Get-IsValidLicenseAcceptance([xml]$nuspecXml) {
Expand Down Expand Up @@ -290,7 +290,7 @@ function Start-EvaluateNupkg ($nupkgPath) {
Get-IsValidAuthors $nuspecXml;
Get-IsValidOwners $nuspecXml;
Get-IsValidProjectUrl $nuspecXml;
Get-IsValidLicenseUrl $nuspecXml;
Get-IsValidLicense $nuspecXml;
Get-IsValidLicenseAcceptance $nuspecXml;
Get-IsValidCopyright $nuspecXml;
Get-IsValidLogoUrl $nuspecXml $unzipPath;
Expand Down
4 changes: 2 additions & 2 deletions Nupkg.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PropertyGroup Condition="$(OS) == 'Windows_NT'">
<!-- Including this file will generate both the *.nupkg and *.symbols.nupkg -->
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<IncludeSymbols>True</IncludeSymbols>
Expand All @@ -15,7 +15,7 @@
<Authors>Microsoft</Authors>
<Owners>Microsoft,AppInsightsSdk</Owners>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageLicenseUrl>https://go.microsoft.com/fwlink/?LinkID=510709</PackageLicenseUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://go.microsoft.com/fwlink/?LinkId=392727</PackageProjectUrl>
<PackageIconUrl>http://appanacdn.blob.core.windows.net/cdn/icons/aic.png</PackageIconUrl>
<RepositoryUrl>https://github.com/Microsoft/ApplicationInsights-dotnet</RepositoryUrl>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Microsoft.ApplicationInsights.W3C
using Microsoft.ApplicationInsights.DataContracts;

namespace Microsoft.ApplicationInsights.W3C
{
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -250,5 +252,148 @@ public void RequestedFlagIsRespected()
Assert.AreEqual($"00-{TraceId}-{a.GetSpanId()}-02", a.GetTraceparent(), notReq);
}
}

[TestMethod]
public void UpdateValidRequestTelemetryWithForceFalse()
{
var traceId = W3CUtilities.GenerateTraceId();
var parentSpanId = W3CUtilities.GenerateSpanId();
var spanId = W3CUtilities.GenerateSpanId();

var telemetry = new RequestTelemetry();
telemetry.Context.Operation.Id = traceId;
telemetry.Context.Operation.ParentId = $"|{traceId}.{parentSpanId}.";
telemetry.Id = $"|{traceId}.{spanId}.";

var a = new Activity("foo").Start();
a.SetTraceparent($"00-{traceId}-{spanId}-01");

a.UpdateTelemetry(telemetry, false);

Assert.AreEqual(traceId, telemetry.Context.Operation.Id);

#if NET45 || NET46
Assert.AreEqual($"|{traceId}.{parentSpanId}.", telemetry.Context.Operation.ParentId);
Assert.AreEqual($"|{traceId}.{spanId}.", telemetry.Id);
#else
Assert.AreEqual($"|{traceId}.{spanId}.", telemetry.Context.Operation.ParentId);
Assert.AreEqual($"|{traceId}.{a.GetSpanId()}.", telemetry.Id);
#endif
}

[TestMethod]
public void UpdateValidRequestTelemetryWithForceInvalidIdFalse()
{
var traceId = W3CUtilities.GenerateTraceId();
var parentSpanId = W3CUtilities.GenerateSpanId();
var spanId = W3CUtilities.GenerateSpanId();

var telemetry = new RequestTelemetry();
telemetry.Context.Operation.Id = traceId;
telemetry.Context.Operation.ParentId = $"|{traceId}.{parentSpanId}.";
telemetry.Id = "|123.456.";

var a = new Activity("foo").Start();
a.SetTraceparent($"00-{traceId}-{spanId}-01");

a.UpdateTelemetry(telemetry, false);

Assert.AreEqual(traceId, telemetry.Context.Operation.Id);
Assert.AreEqual($"|{traceId}.{spanId}.", telemetry.Context.Operation.ParentId);
Assert.AreEqual($"|{traceId}.{a.GetSpanId()}.", telemetry.Id);
}

[TestMethod]
public void UpdateValidRequestTelemetryWithForceTrue()
{
var traceId = W3CUtilities.GenerateTraceId();
var parentSpanId = W3CUtilities.GenerateSpanId();
var spanId = W3CUtilities.GenerateSpanId();

var telemetry = new RequestTelemetry();
telemetry.Context.Operation.Id = traceId;
telemetry.Context.Operation.ParentId = $"|{traceId}.{parentSpanId}.";
telemetry.Id = $"|{traceId}.{spanId}.";

var a = new Activity("foo").Start();
a.SetTraceparent($"00-{traceId}-{spanId}-01");

a.UpdateTelemetry(telemetry, true);

Assert.AreEqual(traceId, telemetry.Context.Operation.Id);
Assert.AreEqual($"|{traceId}.{spanId}.", telemetry.Context.Operation.ParentId);
Assert.AreEqual($"|{traceId}.{a.GetSpanId()}.", telemetry.Id);
}

[TestMethod]
public void UpdateValidDependencyTelemetryWithForceFalse()
{
var traceId = W3CUtilities.GenerateTraceId();
var parentSpanId = W3CUtilities.GenerateSpanId();
var spanId = W3CUtilities.GenerateSpanId();

var telemetry = new DependencyTelemetry();
telemetry.Context.Operation.Id = traceId;
telemetry.Context.Operation.ParentId = $"|{traceId}.{parentSpanId}.";
telemetry.Id = $"|{traceId}.{spanId}.";

var a = new Activity("foo").Start();
a.SetTraceparent($"00-{traceId}-{spanId}-01");

a.UpdateTelemetry(telemetry, false);

Assert.AreEqual(traceId, telemetry.Context.Operation.Id);
#if NET45 || NET46
Assert.AreEqual($"|{traceId}.{parentSpanId}.", telemetry.Context.Operation.ParentId);
Assert.AreEqual($"|{traceId}.{spanId}.", telemetry.Id);
#else
Assert.AreEqual($"|{traceId}.{spanId}.", telemetry.Context.Operation.ParentId);
Assert.AreEqual($"|{traceId}.{a.GetSpanId()}.", telemetry.Id);
#endif
}

[TestMethod]
public void UpdateValidDependencyTelemetryWithForceInvalidIdFalse()
{
var traceId = W3CUtilities.GenerateTraceId();
var parentSpanId = W3CUtilities.GenerateSpanId();
var spanId = W3CUtilities.GenerateSpanId();

var telemetry = new DependencyTelemetry();
telemetry.Context.Operation.Id = traceId;
telemetry.Context.Operation.ParentId = $"|{traceId}.{parentSpanId}.";
telemetry.Id = "|123.456.";

var a = new Activity("foo").Start();
a.SetTraceparent($"00-{traceId}-{spanId}-01");

a.UpdateTelemetry(telemetry, false);

Assert.AreEqual(traceId, telemetry.Context.Operation.Id);
Assert.AreEqual($"|{traceId}.{spanId}.", telemetry.Context.Operation.ParentId);
Assert.AreEqual($"|{traceId}.{a.GetSpanId()}.", telemetry.Id);
}

[TestMethod]
public void UpdateValidDependencyTelemetryTelemetryWithForceTrue()
{
var traceId = W3CUtilities.GenerateTraceId();
var parentSpanId = W3CUtilities.GenerateSpanId();
var spanId = W3CUtilities.GenerateSpanId();

var telemetry = new DependencyTelemetry();
telemetry.Context.Operation.Id = traceId;
telemetry.Context.Operation.ParentId = $"|{traceId}.{parentSpanId}.";
telemetry.Id = $"|{traceId}.{spanId}.";

var a = new Activity("foo").Start();
a.SetTraceparent($"00-{traceId}-{spanId}-01");

a.UpdateTelemetry(telemetry, true);

Assert.AreEqual(traceId, telemetry.Context.Operation.Id);
Assert.AreEqual($"|{traceId}.{spanId}.", telemetry.Context.Operation.ParentId);
Assert.AreEqual($"|{traceId}.{a.GetSpanId()}.", telemetry.Id);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility.Implementation;
using Microsoft.ApplicationInsights.Extensibility.W3C;
using Microsoft.ApplicationInsights.W3C;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
Expand Down Expand Up @@ -218,7 +217,7 @@ public void InitializerOnNestedActivitities()
}

[TestMethod]
public void InitializerOnSqlDepenedency()
public void InitializerOnSqlDependency()
{
Activity requestActivity = new Activity("request")
.Start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public static void UpdateTelemetry(this Activity activity, ITelemetry telemetry,

if (initializeFromCurrent)
{
#if NET45
#if NET45 || NET46
// on .NET Fx Activities are not always reliable, this code prevents update
// of the telemetry that was forcibly updated during Activity lifetime
// ON .NET Core there is no such problem
Expand Down Expand Up @@ -366,7 +366,7 @@ private static Activity UpdateContextFromParent(this Activity activity)
return activity;
}

#if NET45
#if NET45 || NET46
private static bool IsValidTelemetryId(string id, string operationId)
{
return id.Length == 51 &&
Expand Down

0 comments on commit 219d72f

Please sign in to comment.