using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tango.Telemetry.Reporting
{
///
/// Represents a diagnostic snapshot of the telemetry system,
/// providing detailed statistics about published and pending telemetry data,
/// grouped by source type and destination.
///
public class TelemetryReport
{
///
/// Gets or sets the timestamp indicating when the report was generated.
///
public DateTime GeneratedAt { get; set; }
///
/// Gets or sets the total number of telemetry packages that were published
/// successfully since the telemetry system started.
///
public int TotalPublished { get; set; }
///
/// Gets or sets the current number of telemetry packages pending publication in storage.
///
public int TotalPending { get; set; }
///
/// Gets or sets the aggregated telemetry publish summaries, grouped by source type.
/// Each source type contains its respective sources and destination-level statistics.
///
public Dictionary SourceTypes { get; set; }
///
/// Initializes a new instance of the class,
/// initializing the dictionary used for grouping by source type.
///
public TelemetryReport()
{
SourceTypes = new Dictionary();
}
///
/// Returns a human-readable string representation of the report,
/// including summary statistics and breakdowns by source type and destination.
///
/// A formatted string representing the current telemetry report.
public override string ToString()
{
var sb = new StringBuilder();
sb.AppendLine("===== Telemetry Report =====");
sb.AppendLine($"Generated At : {GeneratedAt:u}");
sb.AppendLine($"Total Published : {TotalPublished}");
sb.AppendLine($"Total Pending : {TotalPending}");
sb.AppendLine();
foreach (var sourceTypePair in SourceTypes)
{
sb.AppendLine($"--- Source Type: {sourceTypePair.Key} ---");
foreach (var sourcePair in sourceTypePair.Value.Sources)
{
sb.AppendLine($" Source: {sourcePair.Key}");
foreach (var destinationPair in sourcePair.Value.Destinations)
{
var d = destinationPair.Value;
sb.AppendLine($" {d.DestinationName}: Passed={d.Passed}, Failed={d.Failed}, Postponed={d.Postponed}, Unavailable={d.Unavailable}");
}
sb.AppendLine(); // spacing between sources
}
sb.AppendLine(); // spacing between source types
}
sb.AppendLine("============================");
return sb.ToString();
}
}
}