NServiceBus icon indicating copy to clipboard operation
NServiceBus copied to clipboard

Diagnostics can be added after they are written

Open mikeminutillo opened this issue 2 years ago • 3 comments

NServiceBus provides an api AddStartupDiagnosticsSection(..) for adding to the diagnostic file written at startup. This can be called after the diagnostics have already been written (for example in the transport initialization). Sections added after the diagnostics have already been written are only ever kept in memory, and are effectively lost.

It would be better if the diagnostics section were frozen after it is written. Subsequent attempts to add new sections could throw an exception so we could detect this situation earlier.

mikeminutillo avatar Jan 09 '23 05:01 mikeminutillo

@mikeminutillo as far as I understand, the problem is even deeper than just preventing to add diagnostics. Even though the transport gets passed the hostSettings which contains the StartupDiagnostics writing capability, it can never add anything there because the diagnostics have already been written, which means effectively a transport cannot add any diagnostics. The only sane way to add diagnostics entry would be in

        public override async Task<TransportInfrastructure> Initialize(HostSettings hostSettings,
            ReceiveSettings[] receivers, string[] sendingAddresses, CancellationToken cancellationToken = default)

Doesn't that mean the Core order requires changes? // @SzymonPobiega

danielmarbach avatar Jan 19 '23 11:01 danielmarbach

Doesn't that mean the Core order requires changes?

I am afraid so.

SzymonPobiega avatar Jan 19 '23 12:01 SzymonPobiega

@danielmarbach Yes. There is currently no way for a transport to add diagnostic entries that will be written. I believe that ASB is the only transport that does.

If we froze the diagnostic entries and threw we might have discovered this issue sooner.

mikeminutillo avatar Jan 20 '23 06:01 mikeminutillo