diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Telemetry/TelemetryPublishResult.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Telemetry/TelemetryPublishResult.cs | 81 |
1 files changed, 80 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublishResult.cs b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublishResult.cs index 37c6af412..b423580d2 100644 --- a/Software/Visual_Studio/Tango.Telemetry/TelemetryPublishResult.cs +++ b/Software/Visual_Studio/Tango.Telemetry/TelemetryPublishResult.cs @@ -6,8 +6,15 @@ using System.Threading.Tasks; namespace Tango.Telemetry { + /// <summary> + /// Represents the result of publishing a telemetry package to one or more destinations. + /// Contains the status and metrics per destination and total publish time. + /// </summary> public class TelemetryPublishResult { + /// <summary> + /// Defines the outcome of an attempt to publish to a specific destination. + /// </summary> public enum DestinationStatus { None, @@ -16,26 +23,98 @@ namespace Tango.Telemetry Failed, Postponed } - + + /// <summary> + /// Contains information about the result of publishing telemetry to a specific destination. + /// </summary> public class DestinationResult { + /// <summary> + /// The destination to which the telemetry was attempted to be published. + /// </summary> public ITelemetryDestination Destination { get; set; } + + /// <summary> + /// The result status of the publish attempt. + /// </summary> public DestinationStatus Status { get; set; } + + /// <summary> + /// Any error that occurred during the publish attempt. + /// </summary> public Exception Error { get; set; } + + /// <summary> + /// The amount of time it took to attempt publishing to this destination. + /// </summary> public TimeSpan ElapsedTime { get; set; } + + /// <summary> + /// Number of retry attempts for this destination. + /// </summary> + public int RetryCount { get; internal set; } + + /// <summary> + /// Time until the next eligible retry attempt. + /// </summary> + public TimeSpan RetryDelay { get; internal set; } } + /// <summary> + /// Gets or sets the telemetry source that generated the package associated with this publish result. + /// </summary> + public ITelemetrySource Source { get; set; } + + /// <summary> + /// Gets or sets the source type of the telemetry (e.g., Streaming, ExternalStorage, PendingStorage). + /// </summary> + public TelemetrySourceTypes SourceType { get; set; } + + /// <summary> + /// List of results for each destination that was part of the publish process. + /// </summary> public List<DestinationResult> DestinationsResults { get; set; } + + /// <summary> + /// Total elapsed time taken to publish the telemetry package across all destinations. + /// </summary> public TimeSpan TotalElapsedTime { get; set; } + /// <summary> + /// Time spent outside of destination publishing, typically system overhead or coordination. + /// </summary> public TimeSpan OverheadTime { get { return TimeSpan.FromMilliseconds(TotalElapsedTime.TotalMilliseconds - DestinationsResults.Sum(x => x.ElapsedTime.TotalMilliseconds)); } } + /// <summary> + /// Initializes a new instance of the TelemetryPublishResult class. + /// </summary> public TelemetryPublishResult() { DestinationsResults = new List<DestinationResult>(); } + + public override string ToString() + { + var sb = new StringBuilder(); + + sb.AppendLine($"Source: {Source?.Name ?? "Unknown"} ({SourceType})"); + sb.AppendLine($"Total Elapsed Time: {TotalElapsedTime.TotalMilliseconds:F1} ms"); + sb.AppendLine($"Overhead Time: {OverheadTime.TotalMilliseconds:F1} ms"); + sb.AppendLine("Destination Results:"); + + foreach (var result in DestinationsResults ?? Enumerable.Empty<DestinationResult>()) + { + sb.Append($" - {result.Destination.Name}: {result.Status}, {result.ElapsedTime.TotalMilliseconds:F1} ms"); + if (!string.IsNullOrWhiteSpace(result.Error.ToStringSafe())) + sb.Append($" (Error: {result.Error})"); + + sb.AppendLine(); + } + + return sb.ToString(); + } } } |
