Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .vsts/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,37 @@ steps:
arguments: "--configuration Release"

- task: DotNetCoreCLI@1
displayName: Functional Tests 2.0
displayName: Test 2.0
continueOnError: true
inputs:
command: "test"
projects: "test/**/*Tests20.csproj"
arguments: "--configuration Release -l trx"

- task: DotNetCoreInstaller@0
displayName: install dotnet core 1.1.5
inputs:
version: "1.1.5"

- task: DotNetCoreCLI@1
displayName: Unit Tests
displayName: Test 1.1.5
continueOnError: true
inputs:
command: "test"
projects: "test/**/*AspNetCore.Tests.csproj"
arguments: "--configuration Release -l trx"
projects: "test/**/*Tests.csproj"
arguments: "--configuration Release -l trx --filter Category!=WindowsOnly"


- task: PublishTestResults@2
inputs:
testRunner: "VSTest"
testResultsFiles: "**/*.trx"

- task: DotNetCoreInstaller@0
displayName: install dotnet core 2.1.500
inputs:
version: "2.1.500"

- task: DotNetCoreCLI@1
displayName: Package Nuget
inputs:
Expand All @@ -53,4 +63,4 @@ steps:
inputs:
PathtoPublish: "$(build.artifactstagingdirectory)"
ArtifactName: "drop"
ArtifactType: "Container"
ArtifactType: "Container"
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Changelog

## Version 2.8.0-beta3
- [Make W3C Correlation default and leverage native W3C support from Activity.](https://github.com/microsoft/ApplicationInsights-aspnetcore/pull/958)
- [Fixes Azure Functions performance degradation when W3C enabled.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/900)
- [Fix: AppId is never set is Response Headers.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/956)

## Version 2.8.0-beta2
- [Fix MVCBeforeAction property fetcher to work with .NET Core 3.0 changes.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/936)
- [Catch generic exception from DiagnosticSourceListeners and log instead of failing user request.](https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/957)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners
{
#if NET451 || NET46
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
#else
using System.Threading;
#endif

/// <summary>
/// Represents ambient data that is local to a given asynchronous control flow, such as an asynchronous method.
/// </summary>
/// <typeparam name="T">The type of the ambient data. </typeparam>
internal class ContextData<T>
{
#if NET451 || NET46
private static readonly string Key = typeof(ContextData<T>).FullName;

/// <summary>
/// Gets or sets the value of the ambient data.
/// </summary>
/// <returns>The value of the ambient data. </returns>
public T Value
{
get
{
var handle = CallContext.LogicalGetData(Key) as ObjectHandle;
return handle != null ? (T)handle.Unwrap() : default(T);
}

set
{
CallContext.LogicalSetData(Key, new ObjectHandle(value));
}
}
#else
private readonly AsyncLocal<T> storage = new AsyncLocal<T>();

/// <summary>
/// Gets or sets the value of the ambient data.
/// </summary>
/// <returns>The value of the ambient data. </returns>
public T Value
{
get { return this.storage.Value; }
set { this.storage.Value = value; }
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public static StringValues SetHeaderKeyValue(string[] currentHeaders, string key
/// Http Headers only allow Printable US-ASCII characters.
/// Remove all other characters.
/// </summary>
/// <returns>sanitized string.</returns>
public static string SanitizeString(string input)
{
if (string.IsNullOrWhiteSpace(input))
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ namespace Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners
using Microsoft.AspNetCore.Http;

/// <summary>
/// <see cref="IApplicationInsightDiagnosticListener"/> implementation that listens for events specific to AspNetCore Mvc layer.
/// <see cref="IApplicationInsightDiagnosticListener"/> implementation that listens for evens specific to AspNetCore Mvc layer
/// </summary>
[Obsolete("This class was merged with HostingDiagnosticsListener to optimize Diagnostics Source subscription performance")]
public class MvcDiagnosticsListener : IApplicationInsightDiagnosticListener
{
/// <inheritdoc />
public string ListenerName { get; } = "Microsoft.AspNetCore";

private readonly PropertyFetcher httpContextFetcher = new PropertyFetcher("httpContext");
private readonly PropertyFetcher routeDataFetcher = new PropertyFetcher("routeData");
private readonly PropertyFetcher routeValuesFetcher = new PropertyFetcher("Values");

/// <inheritdoc />
public string ListenerName { get; } = "Microsoft.AspNetCore";

/// <summary>
/// Diagnostic event handler method for 'Microsoft.AspNetCore.Mvc.BeforeAction' event.
/// Diagnostic event handler method for 'Microsoft.AspNetCore.Mvc.BeforeAction' event
/// </summary>
public void OnBeforeAction(HttpContext httpContext, IDictionary<string, object> routeValues)
{
Expand All @@ -40,49 +40,6 @@ public void OnBeforeAction(HttpContext httpContext, IDictionary<string, object>
}
}

/// <inheritdoc />
public void OnSubscribe()
{
}

/// <inheritdoc />
public void OnNext(KeyValuePair<string, object> value)
{
try
{
if (value.Key == "Microsoft.AspNetCore.Mvc.BeforeAction")
{
var context = this.httpContextFetcher.Fetch(value.Value) as HttpContext;
var routeData = this.routeDataFetcher.Fetch(value.Value);
var routeValues = this.routeValuesFetcher.Fetch(routeData) as IDictionary<string, object>;

if (context != null && routeValues != null)
{
this.OnBeforeAction(context, routeValues);
}
}
}
catch (Exception ex)
{
AspNetCoreEventSource.Instance.DiagnosticListenerWarning("MvcDiagnosticsListener", value.Key, ex.Message);
}
}

/// <inheritdoc />
public void OnError(Exception error)
{
}

/// <inheritdoc />
public void OnCompleted()
{
}

/// <inheritdoc />
public void Dispose()
{
}

private string GetNameFromRouteContext(IDictionary<string, object> routeValues)
{
string name = null;
Expand Down Expand Up @@ -138,5 +95,48 @@ private string GetNameFromRouteContext(IDictionary<string, object> routeValues)

return name;
}

/// <inheritdoc />
public void OnSubscribe()
{
}

/// <inheritdoc />
public void OnNext(KeyValuePair<string, object> value)
{
try
{
if (value.Key == "Microsoft.AspNetCore.Mvc.BeforeAction")
{
var context = this.httpContextFetcher.Fetch(value.Value) as HttpContext;
var routeData = routeDataFetcher.Fetch(value.Value);
var routeValues = routeValuesFetcher.Fetch(routeData) as IDictionary<string, object>;

if (context != null && routeValues != null)
{
this.OnBeforeAction(context, routeValues);
}
}
}
catch (Exception ex)
{
AspNetCoreEventSource.Instance.DiagnosticListenerWarning("MvcDiagnosticsListener", value.Key, ex.Message);
}
}

/// <inheritdoc />
public void OnError(Exception error)
{
}

/// <inheritdoc />
public void OnCompleted()
{
}

/// <inheritdoc />
public void Dispose()
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,5 @@ internal static class RequestResponseHeaders
/// Correlation-Context header.
/// </summary>
public const string CorrelationContextHeader = "Correlation-Context";

//
// Summary:
// W3C traceparent header name.
public const string TraceParentHeader = "traceparent";
//
// Summary:
// W3C tracestate header name.
public const string TraceStateHeader = "tracestate";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,18 @@ public void LogHostingDiagnosticListenerOnHttpRequestInStartActivityNull(string
this.WriteEvent(9, this.ApplicationName);
}

/// <summary>
/// Logs an event when a TelemetryModule is not found to configure.
/// </summary>
[Event(11, Message = "Unable to configure module {0} as it is not found in service collection.", Level = EventLevel.Warning, Keywords = Keywords.Diagnostics)]
public void UnableToFindModuleToConfigure(string moduleType, string appDomainName = "Incorrect")
{
this.WriteEvent(11, moduleType, this.ApplicationName);
}

/// <summary>
/// Logs an event when QuickPulseTelemetryModule is not found in service collection.
/// </summary>
[Event(12, Message = "Unable to find QuickPulseTelemetryModule in service collection. LiveMetrics feature will not be available. Please add QuickPulseTelemetryModule to services collection in the ConfigureServices method of your application Startup class.", Level = EventLevel.Error, Keywords = Keywords.Diagnostics)]
public void UnableToFindQuickPulseModuleInDI(string appDomainName = "Incorrect")
{
this.WriteEvent(12, this.ApplicationName);
}

/// <summary>
/// Logs an event when telemetry is not tracked as the Listener is not active.
/// </summary>
[Event(
13,
Keywords = Keywords.Diagnostics,
Expand All @@ -142,9 +133,6 @@ public void NotActiveListenerNoTracking(string evntName, string activityId, stri
this.WriteEvent(13, evntName, activityId, this.ApplicationName);
}

/// <summary>
/// Logs an event for when generic error occur within the SDK.
/// </summary>
[Event(
14,
Keywords = Keywords.Diagnostics,
Expand All @@ -155,9 +143,6 @@ public void LogError(string errorMessage, string appDomainName = "Incorrect")
this.WriteEvent(14, errorMessage, this.ApplicationName);
}

/// <summary>
/// Logs an event when RequestTrackingModule failed to initialize.
/// </summary>
[Event(
15,
Keywords = Keywords.Diagnostics,
Expand All @@ -168,9 +153,6 @@ public void RequestTrackingModuleInitializationFailed(string errorMessage, strin
this.WriteEvent(15, errorMessage, this.ApplicationName);
}

/// <summary>
/// Logs an event when any error occurs within DiagnosticListener callback.
/// </summary>
[Event(
16,
Keywords = Keywords.Diagnostics,
Expand All @@ -181,9 +163,6 @@ public void DiagnosticListenerWarning(string callback, string errorMessage, stri
this.WriteEvent(16, callback, errorMessage, this.ApplicationName);
}

/// <summary>
/// Logs an event when TelemetryConfiguration configure has failed.
/// </summary>
[Event(
17,
Keywords = Keywords.Diagnostics,
Expand All @@ -193,10 +172,7 @@ public void TelemetryConfigurationSetupFailure(string errorMessage, string appDo
{
this.WriteEvent(17, errorMessage, this.ApplicationName);
}

/// <summary>
/// Logs an event when a telemetry item is sampled out at head.
/// </summary>

[Event(
18,
Keywords = Keywords.Diagnostics,
Expand All @@ -207,42 +183,6 @@ public void TelemetryItemWasSampledOutAtHead(string operationId, string appDomai
this.WriteEvent(18, operationId, this.ApplicationName);
}

/// <summary>
/// Logs an informational event from Hosting listeners.
/// </summary>
[Event(
19,
Message = "Hosting Major Version: '{0}'. Informational Message: '{1}'.",
Level = EventLevel.Informational)]
public void HostingListenerInformational(string hostingVersion, string message, string appDomainName = "Incorrect")
{
this.WriteEvent(19, hostingVersion, message, this.ApplicationName);
}

/// <summary>
/// Logs a verbose event.
/// </summary>
[Event(
20,
Message = "Message: '{0}'.",
Level = EventLevel.Verbose)]
public void HostingListenerVerboe(string message, string appDomainName = "Incorrect")
{
this.WriteEvent(20, message, this.ApplicationName);
}

/// <summary>
/// Logs an event for RequestTelemetry created.
/// </summary>
[Event(
21,
Message = "RequestTelemetry created. CorrelationFormat: '{0}', RequestID: '{1}', OperationId : '{2}' ",
Level = EventLevel.Informational)]
public void RequestTelemetryCreated(string correlationFormat, string requestId, string requestOperationId, string appDomainName = "Incorrect")
{
this.WriteEvent(21, correlationFormat, requestId, requestOperationId, this.ApplicationName);
}

/// <summary>
/// Keywords for the AspNetEventSource.
/// </summary>
Expand Down
Loading