diff options
| author | JP Dillingham <jp@dillingham.me> | 2025-11-30 12:51:03 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2025-11-30 12:51:03 -0600 |
| commit | c84f12161fa46ee95c4e0d447864b9a5cf80c6d1 (patch) | |
| tree | 6937a9938af75eff3c76abbcfeb49673c642039a /src | |
| parent | bf8341a9f0eda057b81657017c2dd1f8646a08dd (diff) | |
| download | slskd-c84f12161fa46ee95c4e0d447864b9a5cf80c6d1.tar.gz | |
exceptions
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Telemetry/API/StatisticsController.cs | 194 | ||||
| -rw-r--r-- | src/slskd/Telemetry/StatisticsService.cs | 195 | ||||
| -rw-r--r-- | src/slskd/Telemetry/Types/TransferExceptionDetail.cs | 39 | ||||
| -rw-r--r-- | src/slskd/Telemetry/Types/TransferExceptionSummary.cs | 25 | ||||
| -rw-r--r-- | src/slskd/Telemetry/Types/TransferSummary.cs | 1 |
5 files changed, 368 insertions, 86 deletions
diff --git a/src/slskd/Telemetry/API/StatisticsController.cs b/src/slskd/Telemetry/API/StatisticsController.cs index c0158ed4..5c6e55df 100644 --- a/src/slskd/Telemetry/API/StatisticsController.cs +++ b/src/slskd/Telemetry/API/StatisticsController.cs @@ -27,7 +27,7 @@ using Serilog; using Soulseek; /// <summary> -/// Telemetry. +/// Statistics. /// </summary> [Route("api/v{version:apiVersion}/telemetry/[controller]")] [Tags("Telemetry")] @@ -52,6 +52,7 @@ public class StatisticsController : ControllerBase /// </summary> /// <param name="start">The start time (default: 7 days ago).</param> /// <param name="end">The end time (default: now).</param> + /// <param name="direction">An optional direction by which to filter activity.</param> /// <param name="username">An optional username by which to filter activity.</param> /// <returns>A dictionary keyed by direction and state and containing summary information.</returns> /// <response code="200">The request completed successfully.</response> @@ -65,6 +66,7 @@ public class StatisticsController : ControllerBase public IActionResult GetTransferSummary( [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, + [FromQuery] string direction = null, [FromQuery] string username = null) { var now = DateTime.UtcNow; @@ -77,9 +79,25 @@ public class StatisticsController : ControllerBase return BadRequest("End time must be later than start time"); } + TransferDirection? transferDirection = null; + + if (!string.IsNullOrWhiteSpace(direction)) + { + if (!Enum.TryParse<TransferDirection>(direction, ignoreCase: true, out var parsedDirection)) + { + return BadRequest($"Invalid direction; expected one of: {string.Join(", ", Enum.GetNames(typeof(TransferDirection)))}"); + } + + transferDirection = parsedDirection; + } + try { - return Ok(Telemetry.Statistics.GetTransferSummary(start.Value, end, username: username)); + return Ok(Telemetry.Statistics.GetTransferSummary( + start: start.Value, + end: end, + direction: transferDirection, + username: username)); } catch (Exception ex) { @@ -95,12 +113,13 @@ public class StatisticsController : ControllerBase /// <param name="start">The start time (default: 7 days ago).</param> /// <param name="end">The end time (default: now).</param> /// <param name="interval">The interval, in minutes (default: 60).</param> + /// <param name="direction">An optional direction by which to filter activity.</param> /// <param name="username">An optional username by which to filter activity.</param> /// <returns>A dictionary keyed by direction and state and containing summary information.</returns> /// <response code="200">The request completed successfully.</response> /// <response code="400">Bad request.</response> /// <response code="500">An error occurred.</response> - [HttpGet("transfers/histogram")] + [HttpGet("transfers/summary/histogram")] [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(Dictionary<DateTime, Dictionary<TransferDirection, Dictionary<TransferStates, TransferSummary>>>), 200)] [ProducesResponseType(typeof(string), 400)] @@ -109,6 +128,7 @@ public class StatisticsController : ControllerBase [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, [FromQuery] int interval = 60, + [FromQuery] string direction = null, [FromQuery] string username = null) { var now = DateTime.UtcNow; @@ -128,9 +148,26 @@ public class StatisticsController : ControllerBase var intervalTimeSpan = TimeSpan.FromMinutes(interval); + TransferDirection? transferDirection = null; + + if (!string.IsNullOrWhiteSpace(direction)) + { + if (!Enum.TryParse<TransferDirection>(direction, ignoreCase: true, out var parsedDirection)) + { + return BadRequest($"Invalid direction; expected one of: {string.Join(", ", Enum.GetNames(typeof(TransferDirection)))}"); + } + + transferDirection = parsedDirection; + } + try { - return Ok(Telemetry.Statistics.GetTransferSummaryHistogram(start.Value, end.Value, interval: intervalTimeSpan, username: username)); + return Ok(Telemetry.Statistics.GetTransferSummaryHistogram( + start: start.Value, + end: end.Value, + interval: intervalTimeSpan, + direction: transferDirection, + username: username)); } catch (Exception ex) { @@ -140,77 +177,143 @@ public class StatisticsController : ControllerBase } /// <summary> - /// Returns the top N user summaries by total count and direction. + /// Returns the top N errors by total count and direction. /// </summary> /// <param name="start">The start time.</param> /// <param name="end">The end time.</param> + /// <param name="direction">An optional direction by which to filter activity.</param> + /// <param name="username">An optional username by which to filter exceptions.</param> /// <param name="limit">The number of records to return (Default: 25).</param> /// <param name="offset">The record offset (if paginating).</param> /// <returns></returns> - [HttpGet("transfers/users")] + /// <response code="200">The request completed successfully.</response> + /// <response code="400">Bad request.</response> + /// <response code="500">An error occurred.</response> + [HttpGet("transfers/exceptions")] [Authorize(Policy = AuthPolicy.Any)] - [ProducesResponseType(typeof(Dictionary<TransferDirection, List<UserTransferSummary>>), 200)] - public IActionResult GetSuccessfulTransferSummaryByUsername( + [ProducesResponseType(typeof(Dictionary<TransferDirection, List<TransferExceptionSummary>>), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 500)] + public IActionResult GetTransferExceptions( [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, - [FromQuery] int? limit = null, - [FromQuery] int? offset = null) + [FromQuery] string direction = null, + [FromQuery] string username = null, + [FromQuery] int limit = 25, + [FromQuery] int offset = 0) { start ??= DateTime.MinValue; end ??= DateTime.MaxValue; - limit ??= 25; - offset ??= 0; if (start >= end) { return BadRequest("End time must be later than start time"); } - if (limit <= 0) + TransferDirection? transferDirection = null; + + if (!string.IsNullOrWhiteSpace(direction)) { - return BadRequest("Limit must be greater than zero"); + if (!Enum.TryParse<TransferDirection>(direction, ignoreCase: true, out var parsedDirection)) + { + return BadRequest($"Invalid direction; expected one of: {string.Join(", ", Enum.GetNames(typeof(TransferDirection)))}"); + } + + transferDirection = parsedDirection; } - if (offset < 0) + try { - return BadRequest("Offset must be greater than or equal to zero"); + return Ok(Telemetry.Statistics.GetTransferExceptions( + start: start.Value, + end: end.Value, + limit: limit, + offset: offset, + direction: transferDirection, + username: username)); } - - var downloads = Telemetry.Statistics.GetTransferRanking(direction: TransferDirection.Download, start.Value, end, limit: limit.Value, offset: offset.Value); - var uploads = Telemetry.Statistics.GetTransferRanking(direction: TransferDirection.Upload, start.Value, end, limit: limit.Value, offset: offset.Value); - - var dict = new Dictionary<TransferDirection, List<TransferSummary>>() + catch (Exception ex) { - { TransferDirection.Download, downloads }, - { TransferDirection.Upload, uploads }, - }; - - return Ok(dict); + Log.Error(ex, "Error fetching transfer exceptions over {Start}-{End}: {Message}", start, end, ex.Message); + return StatusCode(500, ex.Message); + } } - [HttpGet("transfers/directories")] + /// <summary> + /// Returns the top N exceptions by total count and direction. + /// </summary> + /// <param name="start">The start time.</param> + /// <param name="end">The end time.</param> + /// <param name="direction">An optional direction by which to filter activity.</param> + /// <param name="username">An optional username by which to filter exceptions.</param> + /// <param name="limit">The number of records to return (Default: 25).</param> + /// <param name="offset">The record offset (if paginating).</param> + /// <returns></returns> + /// <response code="200">The request completed successfully.</response> + /// <response code="400">Bad request.</response> + /// <response code="500">An error occurred.</response> + [HttpGet("transfers/exceptions/pareto")] [Authorize(Policy = AuthPolicy.Any)] - [ProducesResponseType(typeof(Dictionary<string, int>), 200)] - public IActionResult GetTransferSummaryByDirectory( - [FromQuery] int? limit = null, - [FromQuery] int? offset = null) + [ProducesResponseType(typeof(Dictionary<TransferDirection, List<TransferExceptionSummary>>), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 500)] + public IActionResult GetTransferExceptionsPareto( + [FromQuery] DateTime? start = null, + [FromQuery] DateTime? end = null, + [FromQuery] string direction = null, + [FromQuery] string username = null, + [FromQuery] int limit = 25, + [FromQuery] int offset = 0) { - // todo: get a list of all directories downloaded at least once, along with the number of times downloaded (doesn't matter what status) - return null; + start ??= DateTime.MinValue; + end ??= DateTime.MaxValue; + + if (start >= end) + { + return BadRequest("End time must be later than start time"); + } + + TransferDirection? transferDirection = null; + + if (!string.IsNullOrWhiteSpace(direction)) + { + if (!Enum.TryParse<TransferDirection>(direction, ignoreCase: true, out var parsedDirection)) + { + return BadRequest($"Invalid direction; expected one of: {string.Join(", ", Enum.GetNames(typeof(TransferDirection)))}"); + } + + transferDirection = parsedDirection; + } + + try + { + return Ok(Telemetry.Statistics.GetTransferExceptionsPareto( + start: start.Value, + end: end.Value, + limit: limit, + offset: offset, + direction: transferDirection, + username: username)); + } + catch (Exception ex) + { + Log.Error(ex, "Error fetching transfer exceptions over {Start}-{End}: {Message}", start, end, ex.Message); + return StatusCode(500, ex.Message); + } } /// <summary> - /// Returns the top N errors by total count and direction. + /// Returns the top N user summaries by total count and direction. /// </summary> /// <param name="start">The start time.</param> /// <param name="end">The end time.</param> /// <param name="limit">The number of records to return (Default: 25).</param> /// <param name="offset">The record offset (if paginating).</param> /// <returns></returns> - [HttpGet("transfers/errors")] + [HttpGet("transfers/users")] [Authorize(Policy = AuthPolicy.Any)] - [ProducesResponseType(typeof(Dictionary<TransferDirection, Dictionary<TransferStates, TransferSummary>>), 200)] - public IActionResult GetTransferErrorSummary( + [ProducesResponseType(typeof(Dictionary<TransferDirection, List<UserTransferSummary>>), 200)] + public IActionResult GetSuccessfulTransferSummaryByUsername( [FromQuery] DateTime? start = null, [FromQuery] DateTime? end = null, [FromQuery] int? limit = null, @@ -236,10 +339,10 @@ public class StatisticsController : ControllerBase return BadRequest("Offset must be greater than or equal to zero"); } - var downloads = Telemetry.Statistics.GetTransferErrorSummary(start, end, TransferDirection.Download, limit: limit.Value, offset: offset.Value); - var uploads = Telemetry.Statistics.GetTransferErrorSummary(start, end, TransferDirection.Upload, limit: limit.Value, offset: offset.Value); + var downloads = Telemetry.Statistics.GetTransferRanking(direction: TransferDirection.Download, start.Value, end, limit: limit.Value, offset: offset.Value); + var uploads = Telemetry.Statistics.GetTransferRanking(direction: TransferDirection.Upload, start.Value, end, limit: limit.Value, offset: offset.Value); - var dict = new Dictionary<TransferDirection, Dictionary<string, long>>() + var dict = new Dictionary<TransferDirection, List<TransferSummary>>() { { TransferDirection.Download, downloads }, { TransferDirection.Upload, uploads }, @@ -247,4 +350,15 @@ public class StatisticsController : ControllerBase return Ok(dict); } + + [HttpGet("transfers/directories")] + [Authorize(Policy = AuthPolicy.Any)] + [ProducesResponseType(typeof(Dictionary<string, int>), 200)] + public IActionResult GetTransferSummaryByDirectory( + [FromQuery] int? limit = null, + [FromQuery] int? offset = null) + { + // todo: get a list of all directories downloaded at least once, along with the number of times downloaded (doesn't matter what status) + return null; + } } diff --git a/src/slskd/Telemetry/StatisticsService.cs b/src/slskd/Telemetry/StatisticsService.cs index 0b78f57e..a5e55a9b 100644 --- a/src/slskd/Telemetry/StatisticsService.cs +++ b/src/slskd/Telemetry/StatisticsService.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Linq; using Dapper; using Microsoft.Data.Sqlite; +using Serilog; using Soulseek; /// <summary> @@ -38,6 +39,7 @@ public class StatisticsService } private ConnectionStringDictionary ConnectionStrings { get; } + private ILogger Log { get; } = Serilog.Log.ForContext<MetricsController>(); /// <summary> /// Returns a summary of all transfer data grouped by direction and final transfer state. Includes only @@ -75,6 +77,7 @@ public class StatisticsService StateDescription, SUM(Size) AS TotalBytes, COUNT(*) AS Count, + COUNT(DISTINCT Username) AS DistinctUsers, AVG(AverageSpeed) AS AverageSpeed, AVG(strftime('%s', StartedAt) - strftime('%s', EnqueuedAt)) AS AverageWait, AVG(strftime('%s', EndedAt) - strftime('%s', StartedAt)) AS AverageDuration @@ -104,6 +107,7 @@ public class StatisticsService { TotalBytes = result.TotalBytes, Count = result.Count, + DistinctUsers = result.DistinctUsers, AverageSpeed = result.AverageSpeed, AverageWait = result.AverageWait, AverageDuration = result.AverageDuration, @@ -159,6 +163,7 @@ public class StatisticsService StateDescription, SUM(Size) AS TotalBytes, COUNT(*) AS Count, + COUNT(DISTINCT Username) AS Users, AVG(AverageSpeed) AS AverageSpeed, COALESCE(AVG(strftime('%s', StartedAt) - strftime('%s', EnqueuedAt)), 0.0) AS AverageWait, COALESCE(AVG(strftime('%s', EndedAt) - strftime('%s', StartedAt)), 0.0) AS AverageDuration @@ -190,6 +195,7 @@ public class StatisticsService { TotalBytes = result.TotalBytes, Count = result.Count, + DistinctUsers = result.DistinctUsers, AverageSpeed = result.AverageSpeed, AverageWait = result.AverageWait, AverageDuration = result.AverageDuration, @@ -211,22 +217,23 @@ public class StatisticsService } /// <summary> - /// Returns the top <paramref name="limit"/> user summaries by total count and direction, order by total count - /// descending. Only successful transfers are included in counts. + /// Returns a list of transfer exceptions. /// </summary> - /// <param name="direction">The direction (Upload or Download) for the summary.</param> /// <param name="start">The optional start time of the summary window.</param> /// <param name="end">The optional end time of the summary window.</param> + /// <param name="direction">The direction (Upload or Download) for the summary.</param> + /// <param name="username">The optional username by which to filter results.</param> /// <param name="limit">The number of records to return (default: 25).</param> /// <param name="offset">The record offset (if paginating).</param> - /// <returns>A dictionary keyed by username and containing summary information.</returns> + /// <returns>A dictionary keyed by direction and containing a list of exceptions and the number of times they occurred.</returns> /// <exception cref="ArgumentException"> /// Thrown if end time is not later than start time, or limit is not greater than zero. /// </exception> - public List<TransferSummary> GetTransferRanking( - TransferDirection direction, + public Dictionary<TransferDirection, List<TransferExceptionDetail>> GetTransferExceptions( DateTime? start = null, DateTime? end = null, + TransferDirection? direction = null, + string username = null, int limit = 25, int offset = 0) { @@ -238,28 +245,38 @@ public class StatisticsService throw new ArgumentException("End time must be later than start time"); } - if (limit <= 0) + var dict = new Dictionary<TransferDirection, List<TransferExceptionDetail>>() { - throw new ArgumentOutOfRangeException("Limit must be greater than zero"); - } + { TransferDirection.Download, new List<TransferExceptionDetail>() }, + { TransferDirection.Upload, new List<TransferExceptionDetail>() }, + }; var sql = @$" SELECT + Id, Username, Direction, - StateDescription, - SUM(Size) AS TotalBytes, - COUNT(*) AS Count, - AVG(AverageSpeed) AS AverageSpeed, - AVG(strftime('%s', StartedAt) - strftime('%s', EnqueuedAt)) AS AverageWait, - AVG(strftime('%s', EndedAt) - strftime('%s', StartedAt)) AS AverageDuration - FROM Transfers - WHERE Direction = @Direction - AND State = 48 - AND EndedAt IS NOT NULL - AND EndedAt BETWEEN @Start AND @End - GROUP BY Username, Direction, StateDescription - ORDER BY Count DESC, TotalBytes DESC, Username ASC + Filename, + Size, + StartOffset, + State, + RequestedAt + EnqueuedAt, + StartedAt, + EndedAt, + BytesTransferred, + AverageSpeed, + CASE + WHEN INSTR(Exception, ':') > 0 + THEN SUBSTR(Exception, INSTR(Exception, ':') + 2) + ELSE Exception + END as Exception + FROM transfers + WHERE state & ~48 + {(direction is not null ? "AND Direction = @Direction" : string.Empty)} + {(username is not null ? "AND Username = @Username" : string.Empty)} + GROUP BY Direction + ORDER BY EndedAt DESC LIMIT @Limit OFFSET @Offset "; @@ -269,29 +286,27 @@ public class StatisticsService var param = new { Direction = direction.ToString(), - Limit = limit, - Offset = offset, + Username = username, Start = start, End = end, + Limit = limit, + Offset = offset, }; - var results = connection.Query<TransferSummaryRow>(sql, param); + var results = connection.Query<TransferExceptionDetail>(sql, param); - var list = results.Select(row => new TransferSummary + Log.Debug("Result rows for {Method}, filters: {Params}: {Count}", nameof(GetTransferExceptions), param, results?.Count()); + + foreach (var result in results) { - Username = row.Username, - TotalBytes = row.TotalBytes, - Count = row.Count, - AverageSpeed = row.AverageSpeed, - AverageWait = row.AverageWait, - AverageDuration = row.AverageDuration, - }).ToList(); + dict[result.Direction].Add(result); + } - return list; + return dict; } /// <summary> - /// Returns a summary of distinct transfer errors and the number of times they occurred. + /// Returns a summary of distinct transfer exceptions and the number of times they occurred. /// </summary> /// <param name="start">The optional start time of the summary window.</param> /// <param name="end">The optional end time of the summary window.</param> @@ -299,11 +314,11 @@ public class StatisticsService /// <param name="username">The optional username by which to filter results.</param> /// <param name="limit">The number of records to return (default: 25).</param> /// <param name="offset">The record offset (if paginating).</param> - /// <returns></returns> + /// <returns>A dictionary keyed by direction and containing a list of exceptions and the number of times they occurred.</returns> /// <exception cref="ArgumentException"> /// Thrown if end time is not later than start time, or limit is not greater than zero. /// </exception> - public Dictionary<string, long> GetTransferErrorSummary( + public Dictionary<TransferDirection, List<TransferExceptionSummary>> GetTransferExceptionsPareto( DateTime? start = null, DateTime? end = null, TransferDirection? direction = null, @@ -319,12 +334,11 @@ public class StatisticsService throw new ArgumentException("End time must be later than start time"); } - if (limit <= 0) + var dict = new Dictionary<TransferDirection, List<TransferExceptionSummary>>() { - throw new ArgumentOutOfRangeException("Limit must be greater than zero"); - } - - var dict = new Dictionary<string, long>(); + { TransferDirection.Download, new List<TransferExceptionSummary>() }, + { TransferDirection.Upload, new List<TransferExceptionSummary>() }, + }; var sql = @$" SELECT @@ -334,7 +348,8 @@ public class StatisticsService THEN SUBSTR(Exception, INSTR(Exception, ':') + 2) ELSE Exception END as Exception, - COUNT(*) as Count + COUNT(*) as Count, + COUNT(DISTINCT Username) as DistinctUsers FROM transfers WHERE state & ~48 {(direction is not null ? "AND Direction = @Direction" : string.Empty)} @@ -362,16 +377,101 @@ public class StatisticsService Offset = offset, }; - var results = connection.Query<ErrorSummaryRow>(sql, param); + var results = connection.Query<ExceptionSummaryRow>(sql, param); foreach (var result in results) { - dict.Add(result.Exception, result.Count); + dict[result.Direction].Add(new TransferExceptionSummary + { + Exception = result.Exception, + Count = result.Count, + DistinctUsers = result.DistinctUsers, + }); } return dict; } + /// <summary> + /// Returns the top <paramref name="limit"/> user summaries by total count and direction, order by total count + /// descending. Only successful transfers are included in counts. + /// </summary> + /// <param name="direction">The direction (Upload or Download) for the summary.</param> + /// <param name="start">The optional start time of the summary window.</param> + /// <param name="end">The optional end time of the summary window.</param> + /// <param name="limit">The number of records to return (default: 25).</param> + /// <param name="offset">The record offset (if paginating).</param> + /// <returns>A dictionary keyed by username and containing summary information.</returns> + /// <exception cref="ArgumentException"> + /// Thrown if end time is not later than start time, or limit is not greater than zero. + /// </exception> + public List<TransferSummary> GetTransferRanking( + TransferDirection direction, + DateTime? start = null, + DateTime? end = null, + int limit = 25, + int offset = 0) + { + start ??= DateTime.MinValue; + end ??= DateTime.MaxValue; + + if (end <= start) + { + throw new ArgumentException("End time must be later than start time"); + } + + if (limit <= 0) + { + throw new ArgumentOutOfRangeException("Limit must be greater than zero"); + } + + var sql = @$" + SELECT + Username, + Direction, + StateDescription, + SUM(Size) AS TotalBytes, + COUNT(*) AS Count, + AVG(AverageSpeed) AS AverageSpeed, + AVG(strftime('%s', StartedAt) - strftime('%s', EnqueuedAt)) AS AverageWait, + AVG(strftime('%s', EndedAt) - strftime('%s', StartedAt)) AS AverageDuration + FROM Transfers + WHERE Direction = @Direction + AND State = 48 + AND EndedAt IS NOT NULL + AND EndedAt BETWEEN @Start AND @End + GROUP BY Username, Direction, StateDescription + ORDER BY Count DESC, TotalBytes DESC, Username ASC + LIMIT @Limit + OFFSET @Offset + "; + + using var connection = new SqliteConnection(ConnectionStrings[Database.Transfers]); + + var param = new + { + Direction = direction.ToString(), + Limit = limit, + Offset = offset, + Start = start, + End = end, + }; + + var results = connection.Query<TransferSummaryRow>(sql, param); + + var list = results.Select(row => new TransferSummary + { + Username = row.Username, + TotalBytes = row.TotalBytes, + Count = row.Count, + AverageSpeed = row.AverageSpeed, + AverageWait = row.AverageWait, + AverageDuration = row.AverageDuration, + }).ToList(); + + return list; + } + private record TransferSummaryRow { public DateTime? Interval { get; init; } @@ -380,14 +480,17 @@ public class StatisticsService public TransferStates StateDescription { get; init; } public long TotalBytes { get; init; } public long Count { get; init; } + public long DistinctUsers { get; init; } public double AverageSpeed { get; init; } public double AverageWait { get; init; } public double AverageDuration { get; init; } } - private record ErrorSummaryRow + private record ExceptionSummaryRow { + public TransferDirection Direction { get; init; } public string Exception { get; init; } public long Count { get; init; } + public long DistinctUsers { get; init; } } }
\ No newline at end of file diff --git a/src/slskd/Telemetry/Types/TransferExceptionDetail.cs b/src/slskd/Telemetry/Types/TransferExceptionDetail.cs new file mode 100644 index 00000000..a749c6a5 --- /dev/null +++ b/src/slskd/Telemetry/Types/TransferExceptionDetail.cs @@ -0,0 +1,39 @@ +// <copyright file="TransferExceptionDetail.cs" company="slskd Team"> +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// </copyright> + +namespace slskd.Telemetry; + +using System; +using Soulseek; + +public record TransferExceptionDetail +{ + public string Id { get; init; } + public string Username { get; init; } + public TransferDirection Direction { get; init; } + public string Filename { get; init; } + public long Size { get; set; } + public long StartOffset { get; init; } + public TransferStates State { get; set; } = TransferStates.None; + public DateTime RequestedAt { get; set; } + public DateTime? EnqueuedAt { get; set; } + public DateTime? StartedAt { get; set; } + public DateTime? EndedAt { get; set; } + public long BytesTransferred { get; set; } + public double AverageSpeed { get; set; } + public string Exception { get; set; } +}
\ No newline at end of file diff --git a/src/slskd/Telemetry/Types/TransferExceptionSummary.cs b/src/slskd/Telemetry/Types/TransferExceptionSummary.cs new file mode 100644 index 00000000..03b64df5 --- /dev/null +++ b/src/slskd/Telemetry/Types/TransferExceptionSummary.cs @@ -0,0 +1,25 @@ +// <copyright file="TransferExceptionSummary.cs" company="slskd Team"> +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// </copyright> + +namespace slskd.Telemetry; + +public record TransferExceptionSummary +{ + public string Exception { get; init; } + public long Count { get; init; } + public long DistinctUsers { get; init; } +}
\ No newline at end of file diff --git a/src/slskd/Telemetry/Types/TransferSummary.cs b/src/slskd/Telemetry/Types/TransferSummary.cs index 159330fe..c25f81fc 100644 --- a/src/slskd/Telemetry/Types/TransferSummary.cs +++ b/src/slskd/Telemetry/Types/TransferSummary.cs @@ -22,6 +22,7 @@ public record TransferSummary public string Username { get; init; } public long TotalBytes { get; init; } public long Count { get; init; } + public long DistinctUsers { get; init; } public double AverageSpeed { get; init; } public double AverageWait { get; init; } public double AverageDuration { get; init; } |
