/// <summary> /// Reports the start of an activity /// </summary> /// <param name="activity">The name of the activity</param> /// <param name="activityData">The data of the activity</param> /// <returns>A generated ID for the activity that was reported</returns> /// <typeparam name="T">the type of the activity data object</typeparam> public int ReportActivityStartIfAllowed <T>(string activity, T activityData) { if (this.isTelemetryAllowed) { EventSourceOptions telemetryOption = TelemetryEventSource.TelemetryOptions(); Interlocked.Increment(ref this.lastUsedActivityId); this.activitiesMap[this.lastUsedActivityId] = activity; this.eventSource.Write( string.Format("Activity{0}Started", activity), telemetryOption, new TelemetryEventData.ActivityEventData <T> { CorrelationId = this.correlationId, Time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond, ActivityId = this.lastUsedActivityId, ActivityData = activityData }); return(this.lastUsedActivityId); } return(0); }
/// <summary> /// Logs a tag with associated event data /// </summary> /// <typeparam name="T">The type of the event data</typeparam> /// <param name="tag">The event tag to log</param> /// <param name="data">The event data to log (default null)</param> private static void Log <T>(string tag, T data = null) where T : class { EventSource logger = TraceLoggingProvider.GetProvider(); logger?.Write(tag, TelemetryEventSource.MeasuresOptions(), data); }
/// <summary> /// Logs Xps OM Printing being enabled/disabled /// </summary> internal static void LogXpsOMStatus(bool enabled) { EventSource logger = TraceLoggingProvider.GetProvider(); logger?.Write(XpsOMEnabled, TelemetryEventSource.MeasuresOptions(), new XpsOMStatus() { Enabled = enabled }); }
static WorkflowInstance() { try { using (TelemetryEventSource eventSource = new TelemetryEventSource()) { eventSource.V2Runtime(); } } catch { } }
static InternalTransaction() { try { // Emit a telemetry event to indicate that System.Transactions is being used on the first time // InternalTransaction is used. using (TelemetryEventSource eventSource = new TelemetryEventSource()) { eventSource.InternalTransaction(); } } catch { } }
/// <summary> /// Reports the end of the session /// </summary> /// <param name="exitCode">Exit code of the program</param> public void ReportSessionEndIfAllowed(int exitCode) { if (this.isTelemetryAllowed) { EventSourceOptions telemetryOption = TelemetryEventSource.TelemetryOptions(); this.eventSource.Write( "SessionEnded", telemetryOption, new TelemetryEventData.SessionEndEventData { CorrelationId = this.correlationId, Time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond, ExitCode = exitCode }); } }
public static void LogRequest( string codePath, string locatorStrategy, string timeElapsed, string guid, string result) { using (EventSource eventSource = new TelemetryEventSource(eventSourceName: "Microsoft.Windows.WinAppDriver")) { eventSource.Write(eventName: "SearchElement", options: TelemetryCriticalOption, data: new { _1 = PartA_PrivTags.ProductAndServicePerformance, CodePath = codePath, LocatorStrategy = locatorStrategy, RequestTime = timeElapsed, GUID = guid, Result = result }); } }
/// <summary> /// Reports the start of a session /// </summary> public void ReportSessionStartIfAllowed() { if (this.isTelemetryAllowed) { EventSourceOptions telemetryOption = TelemetryEventSource.TelemetryOptions(); this.eventSource.Write( "SessionStarted", telemetryOption, new TelemetryEventData.SessionStartEventData { CorrelationId = this.correlationId, Time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond, CommandLineArgs = EntryAssemblyArgs, Version = EntryAssemblyVersion, OsVersion = CurrentWindowsVersion }); } }
/// <summary> /// Reports the end of the specified activity /// </summary> /// <param name="activityId">The ID of the activity, generated by ReportActivityStartIfAllowed</param> /// <param name="activityData">The data of the activity</param> /// <typeparam name="T">the type of the activity data object</typeparam> public void ReportActivityEndIfAllowed <T>(int activityId, T activityData) { if (this.isTelemetryAllowed) { EventSourceOptions telemetryOption = TelemetryEventSource.TelemetryOptions(); string activity = this.activitiesMap[activityId]; this.eventSource.Write( string.Format("Activity{0}Ended", activity), telemetryOption, new TelemetryEventData.ActivityEventData <T> { CorrelationId = this.correlationId, Time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond, ActivityId = activityId, ActivityData = activityData }); } }
/// <summary> /// Registers the provider and returns the instance /// </summary> /// <returns>EventSource logger if successful, null otherwise</returns> internal static EventSource GetProvider() { if (_logger == null) { lock (_lockObject) { if (_logger == null) { try { _logger = new TelemetryEventSource(ProviderName); } catch (ArgumentException) { // do nothing as we expect _logger to be null in case exception } } } } return(_logger); }
/// <summary> /// Reports an exception that occurred during the execution of a activity, if an activity id is specified. /// </summary> /// <param name="exp">The exception that occurred</param> /// <param name="activityId">The ID of activity during which the exception occurred, generated by ReportActivityStartIfAllowed</param> public void ReportExceptionIfAllowed(Exception exp, int?activityId = null) { if (this.isTelemetryAllowed) { exp = exp.InnerException ?? exp; EventSourceOptions errorOption = TelemetryEventSource.TelemetryOptions(); errorOption.Level = EventLevel.Error; this.eventSource.Write( "ExceptionThrown", errorOption, new TelemetryEventData.ExceptionThrownEventData { CorrelationId = this.correlationId, Time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond, ActivityId = activityId, Message = exp.Message, StackTrace = exp.StackTrace, }); } }
// Token: 0x06003F80 RID: 16256 RVA: 0x00124DF4 File Offset: 0x00122FF4 private void UpdateRunningAverageAndLogDebugInfo(long endTicks) { try { long num = endTicks - this._beginTicks; object lockObject = SpellerCOMActionTraceLogger._lockObject; lock (lockObject) { Dictionary <SpellerCOMActionTraceLogger.Actions, long> numCallsMeasured = this._instanceInfo.NumCallsMeasured; SpellerCOMActionTraceLogger.Actions action = this._action; long num2 = numCallsMeasured[action]; numCallsMeasured[action] = num2 + 1L; Dictionary <SpellerCOMActionTraceLogger.Actions, long> cumulativeCallTime100Ns = this._instanceInfo.CumulativeCallTime100Ns; action = this._action; cumulativeCallTime100Ns[action] += num; } long num3 = (long)Math.Floor(1.0 * (double)this._instanceInfo.CumulativeCallTime100Ns[this._action] / (double)this._instanceInfo.NumCallsMeasured[this._action]); if (this._action == SpellerCOMActionTraceLogger.Actions.RegisterUserDictionary || this._action == SpellerCOMActionTraceLogger.Actions.UnregisterUserDictionary || num > SpellerCOMActionTraceLogger._timeLimits100Ns[this._action] || num3 > 2L * SpellerCOMActionTraceLogger._timeLimits100Ns[this._action]) { EventSource provider = TraceLoggingProvider.GetProvider(); EventSourceOptions options = TelemetryEventSource.MeasuresOptions(); SpellerCOMActionTraceLogger.SpellerCOMTimingData data = new SpellerCOMActionTraceLogger.SpellerCOMTimingData { TextBoxBaseIdentifier = this._instanceInfo.Id.ToString(), SpellerCOMAction = this._action.ToString(), CallTimeForCOMCallMs = (long)Math.Floor((double)num * 1.0 / 10000.0), RunningAverageCallTimeForCOMCallsMs = (long)Math.Floor((double)num3 * 1.0 / 10000.0) }; if (provider != null) { provider.Write <SpellerCOMActionTraceLogger.SpellerCOMTimingData>(SpellerCOMActionTraceLogger.SpellerCOMLatencyMeasurement, options, data); } } } catch { } }
/// <summary> /// Initializes the singleton instance of this class for the specified provider. /// </summary> /// <param name="providerName">The name of the provider (event source) through which telemetry events will be written.</param> public void Initialize(string providerName) { this.eventSource = new TelemetryEventSource(providerName, TelemetryGroup.WindowsCoreTelemetry); this.isTelemetryAllowed = GetTelemetryLevel() != 0; this.correlationId = Guid.NewGuid(); }
/// <summary> /// Logs a tag with no associated data /// </summary> /// <param name="tag">The event tag to log</param> private static void Log(string tag) { EventSource logger = TraceLoggingProvider.GetProvider(); logger?.Write(tag, TelemetryEventSource.MeasuresOptions()); }