/// <summary>
        /// report exception as an asynchronous operation.
        /// </summary>
        /// <param name="exceptionTelemetryData">The exception telemetry data.</param>
        /// <returns>Task.</returns>
        /// <exception cref="Proteus.Bot.Builder.Extensions.Telemetry.TelemetryException">Failed to write to TelemetryWriters.</exception>
        public async Task ReportExceptionAsync(IExceptionTelemetryData exceptionTelemetryData)
        {
            try
            {
                var tasks = new List <Task>();
                TelemetryWriters.ForEach(tw => { tasks.Add(tw.WriteExceptionAsync(exceptionTelemetryData)); });

                await Task.WhenAll(tasks);
            }
            catch (Exception e)
            {
                if (!Configuration.FailSilently)
                {
                    throw new TelemetryException("Failed to write to TelemetryWriters.", e);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// write exception as an asynchronous operation.
        /// </summary>
        /// <param name="exceptionTelemetryData">The exception telemetry data.</param>
        /// <returns>Task.</returns>
        public async Task WriteExceptionAsync(IExceptionTelemetryData exceptionTelemetryData)
        {
            if (_configuration.Handles(TelemetryTypes.Exceptions))
            {
                await Task.Run(() =>
                {
                    var properties = GetBotContextProperties();

                    properties.Add("json", exceptionTelemetryData.Json);
                    properties.Add("component", exceptionTelemetryData.ExceptionComponent);
                    properties.Add("context", exceptionTelemetryData.ExceptionContext);

                    _telemetry.TrackException(exceptionTelemetryData.Ex, properties);
                    DoPostLogActions();
                });
            }
        }
 /// <summary>
 /// write exception as an asynchronous operation.
 /// </summary>
 /// <param name="exceptionTelemetryData">The exception telemetry data.</param>
 /// <returns>Task.</returns>
 public async Task WriteExceptionAsync(IExceptionTelemetryData exceptionTelemetryData)
 {
     await DoWriteTelemetry(exceptionTelemetryData, TelemetryTypes.Exceptions, OutputFormatter.FormatException);
 }
 /// <summary>
 /// Formats the exception.
 /// </summary>
 /// <param name="exceptionTelemetryData">The exception telemetry data.</param>
 /// <returns>System.String.</returns>
 public string FormatException(IExceptionTelemetryData exceptionTelemetryData)
 {
     return($"{GetDateTimeString()}\t{GetTelemetryContextProperties()}\tException: [{exceptionTelemetryData.ExceptionComponent} with [{exceptionTelemetryData.ExceptionContext}]" + Environment.NewLine + $"\t{exceptionTelemetryData.Ex}");
 }
 /// <summary>
 /// Writes the exception.
 /// </summary>
 /// <param name="exceptionTelemetryData">The exception telemetry data.</param>
 /// <returns>Task.</returns>
 public Task WriteExceptionAsync(IExceptionTelemetryData exceptionTelemetryData)
 {
     DoWriteTelemetry(exceptionTelemetryData, TelemetryTypes.Exceptions, OutputFormatter.FormatException);
     return(Task.Delay(0));
 }
 /// <summary>
 /// Formats the exception.
 /// </summary>
 /// <param name="exceptionTelemetryData">The exception telemetry data.</param>
 /// <returns>System.String.</returns>
 public string FormatException(IExceptionTelemetryData exceptionTelemetryData)
 {
     exceptionTelemetryData.RecordType = "exception";
     return(exceptionTelemetryData.AsStringWith(_context));
 }