From fa7bf40f472887389a396ba1adb099e143585a71 Mon Sep 17 00:00:00 2001 From: Rhys Bevilaqua Date: Fri, 11 Sep 2026 16:29:06 +0800 Subject: [PATCH] Remove error messages from the event log --- docs/eventlog-design.md | 2 +- .../When_a_message_has_failed.cs | 25 ------------------- .../When_hosting_error_ingestion_only.cs | 25 ------------------- .../EventLog/MessageFailedDefinition.cs | 20 --------------- .../Recoverability/RecoverabilityComponent.cs | 1 - 5 files changed, 1 insertion(+), 72 deletions(-) delete mode 100644 src/ServiceControl/Recoverability/EventLog/MessageFailedDefinition.cs diff --git a/docs/eventlog-design.md b/docs/eventlog-design.md index b9b9f8208f..1e42cec0a5 100644 --- a/docs/eventlog-design.md +++ b/docs/eventlog-design.md @@ -2,7 +2,7 @@ ## What it is -The event log is the primary instance's activity feed: the chronological "what has this instance noticed" list that ServicePulse shows. Message failures, retries, redirects, heartbeats, custom checks and integration failures all surface here. +The event log is the primary instance's activity feed: the chronological "what has this instance noticed" list that ServicePulse shows. Retries, redirects, heartbeats, custom checks and integration failures all surface here. Message failures do not: they are visible on the failed messages screen instead, and recording one row per failure in the feed was removed as write and retention overhead on the hot ingest path. It is a **projection of domain events, not a log file**. Nothing writes to it directly. Components raise domain events for their own reasons, and the event log turns a chosen subset of those into feed items. An event only appears if someone has declared how it should read, which makes the feed an editorial selection rather than a dump. diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs index fc8bae05e9..6abcbaa004 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/MessageFailures/When_a_message_has_failed.cs @@ -12,7 +12,6 @@ namespace ServiceControl.AcceptanceTests.Recoverability.MessageFailures using AcceptanceTesting; using AcceptanceTesting.EndpointTemplates; using CompositeViews.Messages; - using EventLog; using Infrastructure; using NServiceBus; using NServiceBus.AcceptanceTesting; @@ -169,30 +168,6 @@ public async Task Should_be_listed_in_the_messages_list(CancellationToken cancel } } - [Test] - public async Task Should_add_an_event_log_item() - { - EventLogItem entry = null; - - var context = await Define() - .WithEndpoint(b => b.When(bus => bus.SendLocal(new MyMessage())).DoNotFailOnErrorMessages()) - .Done(async c => - { - var result = await this.TryGetSingle("/api/eventlogitems/", e => e.RelatedTo.Any(r => r.Contains(c.UniqueMessageId)) && e.EventType == nameof(Contracts.MessageFailures.MessageFailed)); - entry = result; - return result; - }) - .Run(); - - using (Assert.EnterMultipleScope()) - { - Assert.That(entry.Severity, Is.EqualTo(Severity.Error), "Failures should be treated as errors"); - Assert.That(entry.Description, Does.Contain("exception"), "For failed messages, the description should contain the exception information"); - Assert.That(entry.RelatedTo.Any(item => item == "/message/" + context.UniqueMessageId), Is.True, "Should contain the api url to retrieve additional details about the failed message"); - Assert.That(entry.RelatedTo.Any(item => item == "/endpoint/" + context.EndpointNameOfReceivingEndpoint), Is.True, "Should contain the api url to retrieve additional details about the endpoint where the message failed"); - } - } - [Test] public async Task Should_be_able_to_search_queueaddresses() { diff --git a/src/ServiceControl.AcceptanceTests/Recoverability/When_hosting_error_ingestion_only.cs b/src/ServiceControl.AcceptanceTests/Recoverability/When_hosting_error_ingestion_only.cs index c9472b6b94..8be5d6e88d 100644 --- a/src/ServiceControl.AcceptanceTests/Recoverability/When_hosting_error_ingestion_only.cs +++ b/src/ServiceControl.AcceptanceTests/Recoverability/When_hosting_error_ingestion_only.cs @@ -136,10 +136,6 @@ public async Task Should_ingest_a_failed_message_into_the_shared_database() Assert.That(knownEndpoints.Select(endpoint => endpoint.Name), Does.Contain("IngestOnly.Receiver")); } - await WaitFor(host, async dbContext => await dbContext.EventLogItems.AsNoTracking() - .AnyAsync(item => item.EventType == "MessageFailed" && item.Description == "Simulated failure"), - "an event log entry for the failure"); - using var client = host.GetTestClient(); var liveness = await client.GetAsync("/health"); @@ -212,27 +208,6 @@ await infrastructure.Dispatcher.Dispatch( } } - static async Task WaitFor(IHost host, Func> condition, string description) - { - var scopeFactory = host.Services.GetRequiredService(); - var timeout = Stopwatch.StartNew(); - - while (timeout.Elapsed < TimeSpan.FromSeconds(60)) - { - await using var scope = scopeFactory.CreateAsyncScope(); - var dbContext = scope.ServiceProvider.GetRequiredService(); - - if (await condition(dbContext)) - { - return; - } - - await Task.Delay(TimeSpan.FromMilliseconds(200)); - } - - Assert.Fail($"Timed out waiting for {description}."); - } - static async Task WaitForFailedMessage(IHost host, string messageId) { var scopeFactory = host.Services.GetRequiredService(); diff --git a/src/ServiceControl/Recoverability/EventLog/MessageFailedDefinition.cs b/src/ServiceControl/Recoverability/EventLog/MessageFailedDefinition.cs deleted file mode 100644 index 8a81ddfd88..0000000000 --- a/src/ServiceControl/Recoverability/EventLog/MessageFailedDefinition.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace ServiceControl.Recoverability.EventLog -{ - using Contracts.MessageFailures; - using ServiceControl.EventLog; - - class MessageFailedDefinition : EventLogMappingDefinition - { - public MessageFailedDefinition() - { - TreatAsError(); - - Description(m => m.FailureDetails.Exception.Message); - - RelatesToMessage(m => m.FailedMessageId); - RelatesToEndpoint(m => m.EndpointId); - - RaisedAt(m => m.FailureDetails.TimeOfFailure); - } - } -} \ No newline at end of file diff --git a/src/ServiceControl/Recoverability/RecoverabilityComponent.cs b/src/ServiceControl/Recoverability/RecoverabilityComponent.cs index ab17793427..2e4c99b451 100644 --- a/src/ServiceControl/Recoverability/RecoverabilityComponent.cs +++ b/src/ServiceControl/Recoverability/RecoverabilityComponent.cs @@ -125,7 +125,6 @@ public override void Configure(Settings settings, ITransportCustomization transp services.AddEventLogMapping(); services.AddEventLogMapping(); services.AddEventLogMapping(); - services.AddEventLogMapping(); services.AddEventLogMapping(); services.AddEventLogMapping(); services.AddEventLogMapping();