| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Abstractions; |
| | | 3 | | using Elsa.Diagnostics.StructuredLogs.Contracts; |
| | | 4 | | using Elsa.Diagnostics.StructuredLogs.Models; |
| | | 5 | | using Elsa.Diagnostics.StructuredLogs.Permissions; |
| | | 6 | | using JetBrains.Annotations; |
| | | 7 | | |
| | | 8 | | namespace Elsa.Diagnostics.StructuredLogs.Endpoints.StructuredLogs.Storage; |
| | | 9 | | |
| | | 10 | | [PublicAPI] |
| | 0 | 11 | | internal class Endpoint(IEnumerable<IStructuredLogStorageDiagnostics> storageDiagnostics) : ElsaEndpointWithoutRequest<S |
| | | 12 | | { |
| | | 13 | | public override void Configure() |
| | | 14 | | { |
| | 0 | 15 | | Get("/diagnostics/structured-logs/storage"); |
| | 0 | 16 | | RequirePermission(StructuredLogsResourcePermissions.StructuredLogs, CoreVerbs.View); |
| | 0 | 17 | | } |
| | | 18 | | |
| | | 19 | | public override Task<StructuredLogStorageDiagnostics> ExecuteAsync(CancellationToken cancellationToken) |
| | | 20 | | { |
| | 0 | 21 | | var diagnostics = storageDiagnostics.ToList(); |
| | 0 | 22 | | var droppedWriteCount = diagnostics.Aggregate(0L, (acc, x) => checked(acc + x.DroppedWriteCount)); |
| | 0 | 23 | | return Task.FromResult(new StructuredLogStorageDiagnostics(droppedWriteCount, diagnostics.Count > 0)); |
| | | 24 | | } |
| | | 25 | | } |