Skip to content

Commit

Permalink
moving App Insights to 2.14.0 (#2509)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettsam authored Jun 5, 2020
1 parent 2593d4f commit 6e15511
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.12.2" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.12.2" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.14.0" />
<PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.14.0" />
<PackageReference Include="Microsoft.ApplicationInsights.SnapshotCollector" Version="1.3.7" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.12.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.12.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" Version="2.14.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" Version="2.14.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.12.2" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.12.2" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.14.0" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.14.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.0" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ public async Task ApplicationInsights_EventHubTrackingByWebJobs_SingleLink(bool
true,
"0",
traceId,
$"|{traceId}.{parentSpanId}.");
parentSpanId);

Assert.Equal(sampledIn ? SamplingDecision.SampledIn : SamplingDecision.None, functionRequest.ProactiveSamplingDecision);

Expand Down Expand Up @@ -945,7 +945,7 @@ await TestHelpers.Await(() =>
success,
"204",
"4bf92f3577b34da6a3ce929d0e0e4736",
"|4bf92f3577b34da6a3ce929d0e0e4736.00f067aa0ba902b7.");
"00f067aa0ba902b7");

Assert.DoesNotContain("MS_HttpRequest", functionRequest.Properties.Keys);
// Make sure operation ids match
Expand Down Expand Up @@ -1105,7 +1105,7 @@ await TestHelpers.Await(() =>
true,
"204",
"4bf92f3577b34da6a3ce929d0e0e4736",
"|4bf92f3577b34da6a3ce929d0e0e4736.00f067aa0ba902b7.");
"00f067aa0ba902b7");

Assert.Equal(_expectedResponseCode.ToString(), functionRequest.ResponseCode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.Extensibility.W3C;
using Microsoft.ApplicationInsights.SnapshotCollector;
using Microsoft.ApplicationInsights.WindowsServer.Channel.Implementation;
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -88,7 +87,7 @@ public async Task LogFunctionResult_Succeeded_SendsCorrectTelemetry()
string expectedOperationId, expectedRequestId;
using (logger.BeginFunctionScope(CreateFunctionInstance(_invocationId), _hostInstanceId))
{
expectedRequestId = $"|{Activity.Current.TraceId.ToHexString()}.{Activity.Current.SpanId.ToHexString()}.";
expectedRequestId = Activity.Current.SpanId.ToHexString();
expectedOperationId = Activity.Current.TraceId.ToHexString();

// sleep briefly to provide a non-zero Duration
Expand Down Expand Up @@ -124,7 +123,7 @@ public void LogFunctionResult_Failed_SendsCorrectTelemetry()
string expectedOperationId, expectedRequestId;
using (logger.BeginFunctionScope(CreateFunctionInstance(_invocationId), _hostInstanceId))
{
expectedRequestId = $"|{Activity.Current.TraceId.ToHexString()}.{Activity.Current.SpanId.ToHexString()}.";
expectedRequestId = Activity.Current.SpanId.ToHexString();
expectedOperationId = Activity.Current.TraceId.ToHexString();

logger.LogFunctionResult(result);
Expand Down Expand Up @@ -217,7 +216,7 @@ public void Log_NoProperties_CreatesTraceAndCorrelates()
logger.LogTrace("Trace");
logger.LogWarning("Warning");

expectedRequestId = $"|{Activity.Current.TraceId.ToHexString()}.{Activity.Current.SpanId.ToHexString()}.";
expectedRequestId = Activity.Current.SpanId.ToHexString();
expectedOperationId = Activity.Current.TraceId.ToHexString();
}

Expand Down Expand Up @@ -285,7 +284,7 @@ public void Log_WithException_CreatesExceptionAndCorrelates()
{
logger.LogError(0, ex, "Error with customer: {customer}.", "John Doe");

expectedRequestId = $"|{Activity.Current.TraceId.ToHexString()}.{Activity.Current.SpanId.ToHexString()}.";
expectedRequestId = Activity.Current.SpanId.ToHexString();
expectedOperationId = Activity.Current.TraceId.ToHexString();
}

Expand Down Expand Up @@ -336,7 +335,7 @@ public void LogMetric_NoProperties()
{
logger.LogMetric("CustomMetric", 44.9);

expectedRequestId = $"|{Activity.Current.TraceId.ToHexString()}.{Activity.Current.SpanId.ToHexString()}.";
expectedRequestId = Activity.Current.SpanId.ToHexString();
expectedOperationId = Activity.Current.TraceId.ToHexString();
}

Expand Down Expand Up @@ -402,7 +401,7 @@ public void LogMetric_AllProperties()
string expectedOperationId, expectedRequestId;
using (logger.BeginFunctionScope(CreateFunctionInstance(scopeGuid), _hostInstanceId))
{
expectedRequestId = $"|{Activity.Current.TraceId.ToHexString()}.{Activity.Current.SpanId.ToHexString()}.";
expectedRequestId = Activity.Current.SpanId.ToHexString();
expectedOperationId = Activity.Current.TraceId.ToHexString();

var props = new Dictionary<string, object>
Expand Down Expand Up @@ -462,7 +461,7 @@ public void LogMetric_AllProperties_Lowercase()
};
logger.LogMetric("CustomMetric", 1.1, props);

expectedRequestId = $"|{Activity.Current.TraceId.ToHexString()}.{Activity.Current.SpanId.ToHexString()}.";
expectedRequestId = Activity.Current.SpanId.ToHexString();
expectedOperationId = Activity.Current.TraceId.ToHexString();
}

Expand Down Expand Up @@ -734,7 +733,7 @@ public void ApplicationInsights_RequestIsTrackedIfActivityIsIgnored()
var logger = CreateLogger(LogCategories.Results);

Activity parent = new Activity("foo").Start();
using (logger.BeginScope(new Dictionary<string, object> { ["MS_IgnoreActivity"] = null} ))
using (logger.BeginScope(new Dictionary<string, object> { ["MS_IgnoreActivity"] = null }))
using (logger.BeginFunctionScope(CreateFunctionInstance(_invocationId), _hostInstanceId))
{
logger.LogFunctionResult(result);
Expand Down Expand Up @@ -778,12 +777,7 @@ public void ApplicationInsights_RequestIsTrackedIfTrackActivityIsSpecified()

Assert.Single(_channel.Telemetries.OfType<RequestTelemetry>());
RequestTelemetry telemetry = _channel.Telemetries.OfType<RequestTelemetry>().Single();
Assert.Equal(FormatTelemetryId(current), telemetry.Id);
}

private static string FormatTelemetryId(Activity activity)
{
return "|" + activity.TraceId.ToHexString() + "." + activity.SpanId.ToHexString() + ".";
Assert.Equal(current.SpanId.ToHexString(), telemetry.Id);
}

[Fact]
Expand Down

0 comments on commit 6e15511

Please sign in to comment.