public void TraceEtwException(Exception exception, EventLevel eventLevel) { switch (eventLevel) { case EventLevel.Error: case EventLevel.Warning: if (WcfEventSource.Instance.ThrowingEtwExceptionIsEnabled()) { string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); WcfEventSource.Instance.ThrowingEtwException(_eventSourceName, exception != null ? exception.ToString() : string.Empty, serializedException); } break; case EventLevel.Critical: if (WcfEventSource.Instance.EtwUnhandledExceptionIsEnabled()) { string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); WcfEventSource.Instance.EtwUnhandledException(exception != null ? exception.ToString() : string.Empty, serializedException); } break; default: if (WcfEventSource.Instance.ThrowingEtwExceptionVerboseIsEnabled()) { string serializedException = EtwDiagnosticTrace.ExceptionToTraceString(exception, int.MaxValue); WcfEventSource.Instance.ThrowingEtwExceptionVerbose(_eventSourceName, exception != null ? exception.ToString() : string.Empty, serializedException); } break; } }
public ExceptionTrace(string eventSourceName, EtwDiagnosticTrace diagnosticTrace) { Fx.Assert(diagnosticTrace != null, "'diagnosticTrace' MUST NOT be NULL."); _eventSourceName = eventSourceName; _diagnosticTrace = diagnosticTrace; }
/// <summary> /// Gets trace definition like: Pool allocating {0} Bytes. /// Event description ID=131, Level=verbose, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="Size">Parameter 0 for event: Pool allocating {0} Bytes.</param> internal static void BufferPoolAllocation(EtwDiagnosticTrace trace, int Size) { TracePayload payload = trace.GetSerializedPayload(null, null, null); if (TraceCore.IsEtwEventEnabled(trace, 11)) { TraceCore.WriteEtwEvent(trace, 11, null, Size, payload.AppDomainFriendlyName); } }
/// <summary> /// Gets trace definition like: IO Thread scheduler callback invoked. /// Event description ID=133, Level=verbose, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="eventTraceActivity">The event trace activity</param> internal static void ActionItemScheduled(EtwDiagnosticTrace trace, System.Runtime.Diagnostics.EventTraceActivity eventTraceActivity) { TracePayload payload = trace.GetSerializedPayload(null, null, null); if (TraceCore.IsEtwEventEnabled(trace, 13)) { TraceCore.WriteEtwEvent(trace, 13, eventTraceActivity, payload.AppDomainFriendlyName); } }
private static bool WriteEtwEvent(EtwDiagnosticTrace trace, int eventIndex, EventTraceActivity eventParam0, int eventParam1, string eventParam2) { TraceCore.EnsureEventDescriptors(); object[] objArray = new object[2]; objArray[0] = eventParam1; objArray[1] = eventParam2; return(trace.EtwProvider.WriteEvent(ref TraceCore.eventDescriptors[eventIndex], eventParam0, objArray)); }
/// <summary> /// Gets trace definition like: Throwing an exception. Source: {0}. Exception details: {1} /// Event description ID=57409, Level=verbose, Channel=Analytic /// </summary> /// <param name="trace">The trace provider</param> /// <param name="param0">Parameter 0 for event: Throwing an exception. Source: {0}. Exception details: {1}</param> /// <param name="param1">Parameter 1 for event: Throwing an exception. Source: {0}. Exception details: {1}</param> /// <param name="exception">Exception associated with the event</param> internal static void ThrowingEtwExceptionVerbose(EtwDiagnosticTrace trace, string param0, string param1, System.Exception exception) { TracePayload payload = trace.GetSerializedPayload(null, null, exception); if (TraceCore.IsEtwEventEnabled(trace, 19)) { TraceCore.WriteEtwEvent(trace, 19, null, param0, param1, payload.SerializedException, payload.AppDomainFriendlyName); } }
/// <summary> /// Gets trace definition like: BufferPool of size {0}, changing quota by {1}. /// Event description ID=132, Level=verbose, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="PoolSize">Parameter 0 for event: BufferPool of size {0}, changing quota by {1}.</param> /// <param name="Delta">Parameter 1 for event: BufferPool of size {0}, changing quota by {1}.</param> internal static void BufferPoolChangeQuota(EtwDiagnosticTrace trace, int PoolSize, int Delta) { TracePayload payload = trace.GetSerializedPayload(null, null, null); if (TraceCore.IsEtwEventEnabled(trace, 12)) { TraceCore.WriteEtwEvent(trace, 12, null, PoolSize, Delta, payload.AppDomainFriendlyName); } }
internal static void EtwUnhandledException(EtwDiagnosticTrace trace, string param0, Exception exception) { TracePayload serializedPayload = trace.GetSerializedPayload(null, null, exception); if (TraceCore.IsEtwEventEnabled(trace, 17)) { TraceCore.WriteEtwEvent(trace, 17, null, param0, serializedPayload.SerializedException, serializedPayload.AppDomainFriendlyName); } }
internal static void ActionItemCallbackInvoked(EtwDiagnosticTrace trace, EventTraceActivity eventTraceActivity) { TracePayload serializedPayload = trace.GetSerializedPayload(null, null, null); if (TraceCore.IsEtwEventEnabled(trace, 14)) { TraceCore.WriteEtwEvent(trace, 14, eventTraceActivity, serializedPayload.AppDomainFriendlyName); } }
static bool IsEtwEventEnabled(EtwDiagnosticTrace trace, int eventIndex) { if (trace.IsEtwProviderEnabled) { EnsureEventDescriptors(); return(trace.IsEtwEventEnabled(ref eventDescriptors[eventIndex])); } return(false); }
private static EtwDiagnosticTrace InitializeTracing() { //Etw tracing is switched off by not enabling the session s_etwProviderId = EtwDiagnosticTrace.DefaultEtwProviderId; EtwDiagnosticTrace trace = new EtwDiagnosticTrace(baseEventSourceName, s_etwProviderId); return(trace); }
internal static bool ShipAssertExceptionMessageIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Error)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 2)); } }
internal static bool HandledExceptionWarningIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Warning)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 10)); } }
internal static bool AppDomainUnloadIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Informational)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 0)); } }
internal static bool ThrowingExceptionVerboseIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Verbose)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 20)); } }
internal static bool TraceCodeEventLogWarningIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Warning)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 9)); } }
internal static bool TraceCodeEventLogCriticalIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Critical)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 5)); } }
internal static bool UnhandledExceptionIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Critical)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 4)); } }
internal static bool TraceCodeEventLogVerboseIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Verbose)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 8)); } }
internal static bool TraceCodeEventLogInfoIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Informational)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 7)); } }
internal static bool TraceCodeEventLogErrorIsEnabled(EtwDiagnosticTrace trace) { if (trace.ShouldTrace(TraceEventLevel.Error)) { return(true); } else { return(TraceCore.IsEtwEventEnabled(trace, 6)); } }
private static bool IsEtwEventEnabled(EtwDiagnosticTrace trace, int eventIndex) { if (!trace.IsEtwProviderEnabled) { return(false); } else { TraceCore.EnsureEventDescriptors(); return(trace.IsEtwEventEnabled(ref TraceCore.eventDescriptors[eventIndex])); } }
private static void EnsureEtwProviderInitialized() { if (null == FxTrace.s_diagnosticTrace) { lock (FxTrace.s_lockObject) { if (null == FxTrace.s_diagnosticTrace) { FxTrace.s_diagnosticTrace = InitializeTracing(); } } } }
/// <summary> /// Gets trace definition like: An unexpected failure occurred. Applications should not attempt to handle this error. For diagnostic purposes, this English message is associated with the failure: {0}. /// Event description ID=57395, Level=error, Channel=Analytic /// </summary> /// <param name="trace">The trace provider</param> /// <param name="param0">Parameter 0 for event: An unexpected failure occurred. Applications should not attempt to handle this error. For diagnostic purposes, this English message is associated with the failure: {0}.</param> internal static void ShipAssertExceptionMessage(EtwDiagnosticTrace trace, string param0) { TracePayload payload = trace.GetSerializedPayload(null, null, null); if (TraceCore.IsEtwEventEnabled(trace, 2)) { TraceCore.WriteEtwEvent(trace, 2, null, param0, payload.AppDomainFriendlyName); } if (trace.ShouldTraceToTraceSource(TraceEventLevel.Error)) { string description = string.Format(Culture, ResourceManager.GetString("ShipAssertExceptionMessage", Culture), param0); TraceCore.WriteTraceSource(trace, 2, description, payload); } }
/// <summary> /// Gets trace definition like: Throwing an exception. Source: {0}. Exception details: {1} /// Event description ID=57407, Level=verbose, Channel=Analytic /// </summary> /// <param name="trace">The trace provider</param> /// <param name="param0">Parameter 0 for event: Throwing an exception. Source: {0}. Exception details: {1}</param> /// <param name="param1">Parameter 1 for event: Throwing an exception. Source: {0}. Exception details: {1}</param> /// <param name="exception">Exception associated with the event</param> internal static void ThrowingExceptionVerbose(EtwDiagnosticTrace trace, string param0, string param1, System.Exception exception) { TracePayload payload = trace.GetSerializedPayload(null, null, exception); if (TraceCore.IsEtwEventEnabled(trace, 20)) { TraceCore.WriteEtwEvent(trace, 20, null, param0, param1, payload.SerializedException, payload.AppDomainFriendlyName); } if (trace.ShouldTraceToTraceSource(TraceEventLevel.Verbose)) { string description = string.Format(Culture, ResourceManager.GetString("ThrowingExceptionVerbose", Culture), param0, param1); TraceCore.WriteTraceSource(trace, 20, description, payload); } }
private static EtwDiagnosticTrace InitializeTracing() { EtwDiagnosticTrace etwDiagnosticTrace = new EtwDiagnosticTrace("System.Runtime", EtwDiagnosticTrace.DefaultEtwProviderId); if (etwDiagnosticTrace.EtwProvider != null) { EtwDiagnosticTrace etwDiagnosticTrace1 = etwDiagnosticTrace; Action refreshState = etwDiagnosticTrace1.RefreshState; etwDiagnosticTrace1.RefreshState = (Action)Delegate.Combine(refreshState, () => Fx.UpdateLevel()); } Fx.UpdateLevel(etwDiagnosticTrace); return(etwDiagnosticTrace); }
/// <summary> /// Gets trace definition like: Wrote to the EventLog. /// Event description ID=57403, Level=warning, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="traceRecord">Extended data (TraceRecord) for the event</param> internal static void TraceCodeEventLogWarning(EtwDiagnosticTrace trace, TraceRecord traceRecord) { TracePayload payload = trace.GetSerializedPayload(null, traceRecord, null); if (TraceCore.IsEtwEventEnabled(trace, 9)) { TraceCore.WriteEtwEvent(trace, 9, null, payload.ExtendedData, payload.AppDomainFriendlyName); } if (trace.ShouldTraceToTraceSource(TraceEventLevel.Warning)) { string description = string.Format(Culture, ResourceManager.GetString("TraceCodeEventLogWarning", Culture)); TraceCore.WriteTraceSource(trace, 9, description, payload); } }
/// <summary> /// Gets trace definition like: Unhandled exception. Exception details: {0} /// Event description ID=57397, Level=critical, Channel=Operational /// </summary> /// <param name="trace">The trace provider</param> /// <param name="param0">Parameter 0 for event: Unhandled exception. Exception details: {0}</param> /// <param name="exception">Exception associated with the event</param> internal static void UnhandledException(EtwDiagnosticTrace trace, string param0, System.Exception exception) { TracePayload payload = trace.GetSerializedPayload(null, null, exception); if (TraceCore.IsEtwEventEnabled(trace, 4)) { TraceCore.WriteEtwEvent(trace, 4, null, param0, payload.SerializedException, payload.AppDomainFriendlyName); } if (trace.ShouldTraceToTraceSource(TraceEventLevel.Critical)) { string description = string.Format(Culture, ResourceManager.GetString("UnhandledException", Culture), param0); TraceCore.WriteTraceSource(trace, 4, description, payload); } }
static void UpdateLevel(EtwDiagnosticTrace trace) { if (trace == null) { return; } if (TraceCore.ActionItemCallbackInvokedIsEnabled(trace) || TraceCore.ActionItemScheduledIsEnabled(trace)) { trace.SetEnd2EndActivityTracingEnabled(true); } }
/// <summary> /// Gets trace definition like: AppDomain unloading. AppDomain.FriendlyName {0}, ProcessName {1}, ProcessId {2}. /// Event description ID=57393, Level=informational, Channel=Debug /// </summary> /// <param name="trace">The trace provider</param> /// <param name="appdomainName">Parameter 0 for event: AppDomain unloading. AppDomain.FriendlyName {0}, ProcessName {1}, ProcessId {2}.</param> /// <param name="processName">Parameter 1 for event: AppDomain unloading. AppDomain.FriendlyName {0}, ProcessName {1}, ProcessId {2}.</param> /// <param name="processId">Parameter 2 for event: AppDomain unloading. AppDomain.FriendlyName {0}, ProcessName {1}, ProcessId {2}.</param> internal static void AppDomainUnload(EtwDiagnosticTrace trace, string appdomainName, string processName, string processId) { TracePayload payload = trace.GetSerializedPayload(null, null, null); if (TraceCore.IsEtwEventEnabled(trace, 0)) { TraceCore.WriteEtwEvent(trace, 0, null, appdomainName, processName, processId, payload.AppDomainFriendlyName); } if (trace.ShouldTraceToTraceSource(TraceEventLevel.Informational)) { string description = string.Format(Culture, ResourceManager.GetString("AppDomainUnload", Culture), appdomainName, processName, processId); TraceCore.WriteTraceSource(trace, 0, description, payload); } }