public void OnNext(KeyValuePair <string, object?> value) { var activity = Activity.Current; if (activity == null) { return; } if (value.Key.EndsWith(".Stop")) { var serviceAttribute = activity.Tags.FirstOrDefault(tag => tag.Key == CouchbaseTags.Service); if (serviceAttribute.Value == null) { return; } if (_serviceThresholds.TryGetValue(serviceAttribute.Value, out var threshold)) { if (activity.Duration > threshold) { var summary = ThresholdSummary.FromActivity(activity); ServiceThresholdQueue.AddByService(serviceAttribute.Value, summary); } } } }
public static void LogReportSummaries(object?state) { var reportSummaries = ServiceThresholdQueue.ReportSummaries(); var reportJson = JArray.FromObject(reportSummaries); if (reportJson.HasValues && state is ILogger logger) { logger.LogInformation(LoggingEvents.ThresholdEvent, reportJson.ToString(Formatting.None)); } }