Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Commit

Permalink
Revert "Revert "Make W3C Correlation default and leverage native W3C …
Browse files Browse the repository at this point in the history
…support from new System.Diagnostics.DiagnosticSource Activity (#958)" (#962)"

This reverts commit c2929a9.
  • Loading branch information
cijothomas authored Aug 27, 2019
1 parent c2929a9 commit e507902
Show file tree
Hide file tree
Showing 39 changed files with 1,364 additions and 1,165 deletions.
20 changes: 5 additions & 15 deletions .vsts/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,27 @@ steps:
arguments: "--configuration Release"

- task: DotNetCoreCLI@1
displayName: Test 2.0
displayName: Functional Tests 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: Test 1.1.5
displayName: Unit Tests
continueOnError: true
inputs:
command: "test"
projects: "test/**/*Tests.csproj"
arguments: "--configuration Release -l trx --filter Category!=WindowsOnly"
projects: "test/**/*AspNetCore.Tests.csproj"
arguments: "--configuration Release -l trx"


- 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 @@ -63,4 +53,4 @@ steps:
inputs:
PathtoPublish: "$(build.artifactstagingdirectory)"
ArtifactName: "drop"
ArtifactType: "Container"
ArtifactType: "Container"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# 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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ 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 evens specific to AspNetCore Mvc layer
/// <see cref="IApplicationInsightDiagnosticListener"/> implementation that listens for events 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,6 +40,49 @@ 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 @@ -95,48 +138,5 @@ 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,5 +29,14 @@ 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,18 +111,27 @@ 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 @@ -133,6 +142,9 @@ 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 @@ -143,6 +155,9 @@ 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 @@ -153,6 +168,9 @@ 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 @@ -163,6 +181,9 @@ 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 @@ -172,7 +193,10 @@ 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 @@ -183,6 +207,42 @@ 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

0 comments on commit e507902

Please sign in to comment.