private static async Task TryLogActivityAsync(ITranscriptLogger logger, IActivity activity)
        {
            try
            {
                await logger.LogActivityAsync(activity).ConfigureAwait(false);
            }
#pragma warning disable CA1031 // Do not catch general exception types (this should probably be addressed later, but for now we just log the error and continue the execution)
            catch (Exception ex)
#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler
            {
                Trace.TraceError($"Transcript logActivity failed with {ex}");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Helper to sequentially flush the transcript queue to the log.
        /// </summary>
        private static async Task TryLogTranscriptAsync(ITranscriptLogger logger, Queue <IActivity> transcript)
        {
            try
            {
                while (transcript.Count > 0)
                {
                    // Process the queue and log all the activities in parallel.
                    var activity = transcript.Dequeue();
                    await logger.LogActivityAsync(activity).ConfigureAwait(false);
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types (this should probably be addressed later, but for now we just log the error and continue the execution)
            catch (Exception ex)
#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler
            {
                Trace.TraceError($"Transcript logActivity failed with {ex}");
            }
        }
        public void Initialize()
        {
            // Get elasticsearch configuration from external file.
            var config = new ConfigurationBuilder()
                         .AddJsonFile("elasticsearchsettings.json")
                         .Build();

            var elasticsearchTranscriptLoggerOptions = new ElasticsearchTranscriptLoggerOptions
            {
                ElasticsearchEndpoint = new Uri(config["Endpoint"]),
                UserName  = config["UserName"],
                Password  = config["Password"],
                IndexName = config["IndexName"]
            };

            elasticsearchEndpoint = config["Endpoint"];

            transcriptLogger = new ElasticsearchTranscriptLogger(elasticsearchTranscriptLoggerOptions);
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TranscriptLoggerMiddleware"/> class.
 /// </summary>
 /// <param name="transcriptLogger">The conversation store to use.</param>
 public TranscriptLoggerMiddleware(ITranscriptLogger transcriptLogger)
 {
     _logger = transcriptLogger ?? throw new ArgumentNullException(nameof(transcriptLogger), "TranscriptLoggerMiddleware requires a ITranscriptLogger implementation.  ");
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TranscriptLoggerWorkaroundMiddleware"/> class.
 /// </summary>
 /// <param name="transcriptLogger">The conversation store to use.</param>
 public TranscriptLoggerWorkaroundMiddleware(ITranscriptLogger transcriptLogger)
 {
     logger = transcriptLogger ?? throw new ArgumentNullException("TranscriptLoggerMiddleware requires a ITranscriptLogger implementation.  ");
 }