add event log events for correlation
This commit is contained in:
Родитель
7533468b32
Коммит
26a407e3f6
|
@ -207,12 +207,14 @@
|
|||
InjectionGuardConstants.TraceParentHeaderMaxLength);
|
||||
originalParentId = parentTraceParent;
|
||||
traceParentPresent = true;
|
||||
AspNetCoreEventSource.Instance.HostingListenerInformational("2", "Retrieved trace parent from headers.");
|
||||
}
|
||||
|
||||
// Scenario #1. No incoming correlation headers.
|
||||
if (originalParentId == null)
|
||||
{
|
||||
// Nothing to do here.
|
||||
AspNetCoreEventSource.Instance.HostingListenerInformational("2", "OriginalParentId is null.");
|
||||
}
|
||||
else if (traceParentPresent)
|
||||
{
|
||||
|
@ -220,6 +222,7 @@
|
|||
// We need to ignore the Activity created by Hosting, as it did not take W3CTraceParent into consideration.
|
||||
newActivity = new Activity(ActivityCreatedByHostingDiagnosticListener);
|
||||
newActivity.SetParentId(originalParentId);
|
||||
AspNetCoreEventSource.Instance.HostingListenerInformational("2", "Ignoring original Activity from Hosting to create new one using traceparent header retrieved by sdk.");
|
||||
|
||||
// read and populate tracestate
|
||||
ReadTraceState(httpContext.Request.Headers, newActivity);
|
||||
|
@ -238,6 +241,7 @@
|
|||
{
|
||||
newActivity = new Activity(ActivityCreatedByHostingDiagnosticListener);
|
||||
newActivity.SetParentId(ActivityTraceId.CreateFromString(traceId), default(ActivitySpanId), ActivityTraceFlags.None);
|
||||
AspNetCoreEventSource.Instance.HostingListenerInformational("2", "Ignoring original Activity from Hosting to create new one using w3c compatible request-id.");
|
||||
|
||||
foreach (var bag in currentActivity.Baggage)
|
||||
{
|
||||
|
@ -248,6 +252,7 @@
|
|||
{
|
||||
// store rootIdFromOriginalParentId in custom Property
|
||||
legacyRootId = ExtractOperationIdFromRequestId(originalParentId);
|
||||
AspNetCoreEventSource.Instance.HostingListenerInformational("2", "Incoming Request-ID is not W3C Compatible, and hence will be ignored for ID generation, but stored in custom property legacy_rootID.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -581,6 +586,8 @@
|
|||
activity.AddBaggage(itemName, itemValue);
|
||||
}
|
||||
}
|
||||
|
||||
AspNetCoreEventSource.Instance.HostingListenerVerboe("Correlation-Context retrived from header and stored into activity baggage.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -593,6 +600,7 @@
|
|||
// make in the request context can continue propogation
|
||||
// of tracestate.
|
||||
activity.TraceStateString = traceState;
|
||||
AspNetCoreEventSource.Instance.HostingListenerVerboe("TraceState retrived from header and stored into activity.TraceState");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -673,11 +681,13 @@
|
|||
var traceId = activity.TraceId.ToHexString();
|
||||
requestTelemetry.Id = FormatTelemetryId(traceId, activity.SpanId.ToHexString());
|
||||
requestTelemetry.Context.Operation.Id = traceId;
|
||||
AspNetCoreEventSource.Instance.RequestTelemetryCreated("W3C", requestTelemetry.Id, traceId);
|
||||
}
|
||||
else
|
||||
{
|
||||
requestTelemetry.Context.Operation.Id = activity.RootId;
|
||||
requestTelemetry.Id = activity.Id;
|
||||
AspNetCoreEventSource.Instance.RequestTelemetryCreated("Hierrarchical", requestTelemetry.Id, requestTelemetry.Context.Operation.Id);
|
||||
}
|
||||
|
||||
if (this.proactiveSamplingEnabled
|
||||
|
|
|
@ -193,7 +193,7 @@ namespace Microsoft.ApplicationInsights.AspNetCore.Extensibility.Implementation.
|
|||
{
|
||||
this.WriteEvent(17, errorMessage, this.ApplicationName);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logs an event when a telemetry item is sampled out at head.
|
||||
/// </summary>
|
||||
|
@ -207,6 +207,42 @@ namespace Microsoft.ApplicationInsights.AspNetCore.Extensibility.Implementation.
|
|||
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>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
public class RequestCollectionOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates new instance of <see cref="RequestCollectionOptions"/> class and fills default values.
|
||||
/// Initializes a new instance of the <see cref="RequestCollectionOptions"/> class
|
||||
/// and populates default values.
|
||||
/// </summary>
|
||||
public RequestCollectionOptions()
|
||||
{
|
||||
|
@ -23,17 +24,19 @@
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets value indicating whether Request-Context header is injected into the response.
|
||||
/// Gets or sets a value indicating whether Request-Context header is injected into the response.
|
||||
/// </summary>
|
||||
public bool InjectResponseHeaders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets value indicating whether exceptions are be tracked.
|
||||
/// Gets or sets a value indicating whether exceptions are be tracked by the RequestCOllectionModule.
|
||||
/// Exceptions could be tracked by ApplicationInsightsLoggerProvider as well which is not affected by
|
||||
/// this setting.
|
||||
/// </summary>
|
||||
public bool TrackExceptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets value indicating whether W3C distributed tracing standard is enabled.
|
||||
/// Gets or sets a value indicating whether W3C distributed tracing standard is enabled.
|
||||
/// </summary>
|
||||
public bool EnableW3CDistributedTracing { get; set; }
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Microsoft.ApplicationInsights.AspNetCore
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RequestTrackingTelemetryModule"/> class.
|
||||
/// </summary>
|
||||
public RequestTrackingTelemetryModule()
|
||||
public RequestTrackingTelemetryModule()
|
||||
: this(null)
|
||||
{
|
||||
this.CollectionOptions = new RequestCollectionOptions();
|
||||
|
|
Загрузка…
Ссылка в новой задаче