diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-06-21 10:41:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-21 10:41:53 -0500 |
| commit | 7497db57e8a44769d1a098ad189247ea4e980a1d (patch) | |
| tree | 189ff962d5125fe2526e4f79dccb009379725fdf /src/slskd/Telemetry/API | |
| parent | 8e152ed6eccd5650179f2875eef4aa21243c8c15 (diff) | |
| parent | 28fa7202724da10075dbddc3244d5d5528b4bdad (diff) | |
| download | slskd-7497db57e8a44769d1a098ad189247ea4e980a1d.tar.gz | |
Merge pull request #1769 from slskd/reports
Collect and broadcast real-time transfer metrics, add a footer to the UI to display them
Diffstat (limited to 'src/slskd/Telemetry/API')
| -rw-r--r-- | src/slskd/Telemetry/API/MetricsHub.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/slskd/Telemetry/API/MetricsHub.cs b/src/slskd/Telemetry/API/MetricsHub.cs new file mode 100644 index 00000000..5dcd4ecc --- /dev/null +++ b/src/slskd/Telemetry/API/MetricsHub.cs @@ -0,0 +1,60 @@ +// <copyright file="MetricsHub.cs" company="JP Dillingham"> +// ▄▄▄▄ ▄▄▄▄ ▄▄▄▄ +// ▄▄▄▄▄▄█ █▄▄▄▄▄█ █▄▄▄▄▄█ █ +// █__ --█ █__ --█ ◄█ - █ +// █▄▄▄▄▄█▄▄█▄▄▄▄▄█▄▄█▄▄█▄▄▄▄▄█ +// ┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━ ━ ━┉ ┉ ┉ +// │ Copyright (c) JP Dillingham. +// │ +// │ 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, version 3. +// │ +// │ 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/. +// │ +// │ This program is distributed with Additional Terms pursuant to Section 7 +// │ of the AGPLv3. See the LICENSE file in the root directory of this +// │ project for the complete terms and conditions. +// │ +// │ https://slskd.org +// │ +// ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ╌ ╌╌╌╌ ╌ +// │ SPDX-FileCopyrightText: JP Dillingham +// │ SPDX-License-Identifier: AGPL-3.0-only +// ╰───────────────────────────────────────────╶──── ─ ─── ─ ── ──┈ ┈ +// </copyright> + +namespace slskd.Telemetry; + +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.SignalR; +using Serilog; + +public interface IMetricsHub +{ + Task Update(object metrics); +} + +[Authorize] +public class MetricsHub : Hub<IMetricsHub> +{ + public MetricsHub(MetricsService metricsService) + { + Metrics = metricsService; + } + + private static ILogger Log { get; } = Serilog.Log.ForContext<MetricsHub>(); + private MetricsService Metrics { get; } + + public override async Task OnConnectedAsync() + { + await Clients.Caller.Update(Metrics.Current()); + } +}
\ No newline at end of file |
