private async Task PublishToLogAnalyticsAsync(TestResultAnalysis deviceAnalysis) { string messagesJson = JsonConvert.SerializeObject(deviceAnalysis.MessagesReport, Formatting.Indented); string twinsJson = JsonConvert.SerializeObject(deviceAnalysis.TwinsReport, Formatting.Indented); string directMethodsJson = JsonConvert.SerializeObject(deviceAnalysis.DmReport, Formatting.Indented); string workspaceId = Settings.Current.LogAnalyticsWorkspaceId; string sharedKey = Settings.Current.LogAnalyticsSharedKey; // Upload the data to Log Analytics for our dashboards try { await AzureLogAnalytics.Instance.PostAsync( workspaceId, sharedKey, messagesJson, "messagingReportsLonghaulStress"); await AzureLogAnalytics.Instance.PostAsync( workspaceId, sharedKey, twinsJson, "twinReportsLonghaulStress"); await AzureLogAnalytics.Instance.PostAsync( workspaceId, sharedKey, directMethodsJson, "directMethodReportsLonghaulStress"); } catch (Exception e) { Logger.LogError($"Failed uploading reports to log analytics:", e); } }
public async Task <ContentResult> GetMessagesAsync() { TestResultAnalysis deviceAnalysis = TestResultReporter.GetDeviceReport(Settings.Current.ToleranceInMilliseconds); await this.PublishToLogAnalyticsAsync(deviceAnalysis); return(new ContentResult { Content = JsonConvert.SerializeObject(deviceAnalysis.MessagesReport, Formatting.Indented) }); // explicit serialization needed due to the wrapping list }
public async Task <ContentResult> GetReport() { TestResultAnalysis deviceAnalysis = TestResultReporter.GetDeviceReport(Settings.Current.ToleranceInMilliseconds); await this.PublishToLogAnalyticsAsync(deviceAnalysis); return(new ContentResult { Content = deviceAnalysis.ToString() }); }
async Task PublishToLogAnalyticsAsync(TestResultAnalysis deviceAnalysis) { string messagesJson = JsonConvert.SerializeObject(deviceAnalysis.MessagesReport, Formatting.Indented); string twinsJson = JsonConvert.SerializeObject(deviceAnalysis.TwinsReport, Formatting.Indented); string directMethodsJson = JsonConvert.SerializeObject(deviceAnalysis.DmReport, Formatting.Indented); string workspaceId = Settings.Current.LogAnalyticsWorkspaceId; string sharedKey = Settings.Current.LogAnalyticsSharedKey; string logType = Settings.Current.LogAnalyticsLogType; // Upload the data to Log Analytics for our dashboards try { Task reportMessages = AzureLogAnalytics.Instance.PostAsync( workspaceId, sharedKey, messagesJson, logType); Task reportTwins = AzureLogAnalytics.Instance.PostAsync( workspaceId, sharedKey, twinsJson, logType); Task reportDirectMethods = AzureLogAnalytics.Instance.PostAsync( workspaceId, sharedKey, directMethodsJson, logType); await Task.WhenAll(reportMessages, reportTwins, reportDirectMethods); } catch (Exception e) { Logger.LogError($"Failed uploading reports to log analytics:", e); } }